Skip to content

Commit

Permalink
feat(listener): handle verify change to prevent update error
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream authored and Kinplemelon committed Apr 24, 2024
1 parent 51ea485 commit 60191a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/ListenerDrawer/ListenerDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
:is-edit="isEdit"
:base-path="SSLConfigKey"
:verify-label="t('Base.tlsVerifyClient')"
@verify-change="handleTLSVerifyChange"
/>
</el-col>
<template v-if="!isQUIC && listenerRecord[SSLConfigKey].verify !== 'verify_none'">
Expand Down Expand Up @@ -440,6 +441,7 @@ const {
listenerFormRules,
submit,
onDelete,
handleTLSVerifyChange,
} = useListenerDialog(props, emit)
const isUDP = computed(() => listenerRecord.value.type === ListenerTypeForGateway.UDP)
Expand Down
7 changes: 6 additions & 1 deletion src/components/TLSConfig/TLSEnableConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:disabled="readonly || disabledVerify"
:active-value="SSL_VERIFY_VALUE_MAP.get(true)"
:inactive-value="SSL_VERIFY_VALUE_MAP.get(false)"
@change="handleVerifyChange"
/>
</el-form-item>
<CustomFormItem
Expand Down Expand Up @@ -152,7 +153,7 @@ const props = defineProps({
},
})
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'verifyChange'])
const record: WritableComputedRef<SSL> = computed({
get() {
Expand Down Expand Up @@ -180,6 +181,10 @@ const getFormItemProp = (key: string) => {
}
return undefined
}
const handleVerifyChange = (val: string | number | boolean) => {
emit('verifyChange', val)
}
</script>

<style lang="scss">
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/Config/useListenerDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface UseListenerDialogReturns {
submit: () => Promise<void>
onDelete: () => void
transPort: (port: string) => string
handleTLSVerifyChange: (val: string | number | boolean) => void
}

export default (props: Props, emit: Emit): UseListenerDialogReturns => {
Expand Down Expand Up @@ -316,6 +317,14 @@ export default (props: Props, emit: Emit): UseListenerDialogReturns => {
}
})

// If 'fail_if_no_peer_cert' is true while TLS verification is 'verify_none', it will cause an update error
const handleTLSVerifyChange = (val: string | number | boolean) => {
const { fail_if_no_peer_cert } = listenerRecord.value[SSLConfigKey.value]
if (val === 'verify_none' && fail_if_no_peer_cert === true) {
listenerRecord.value[SSLConfigKey.value].fail_if_no_peer_cert = false
}
}

return {
showDialog,
isLoading,
Expand All @@ -339,5 +348,6 @@ export default (props: Props, emit: Emit): UseListenerDialogReturns => {
submit,
onDelete,
transPort,
handleTLSVerifyChange,
}
}

0 comments on commit 60191a3

Please sign in to comment.