full tls override in inbound multi-domain

This commit is contained in:
Alireza Ahmadi
2025-01-05 19:36:01 +01:00
parent dbee22b637
commit 751066ac6c
10 changed files with 75 additions and 109 deletions
+5 -46
View File
@@ -24,30 +24,7 @@
</v-text-field> </v-text-field>
</v-col> </v-col>
</v-row> </v-row>
<v-row> <OutTLS :outbound="addr" v-if="optionTLS" />
<v-col cols="12" sm="6" md="4" v-if="optionTLS">
<v-switch
:label="$t('tls.enable')"
color="primary"
hide-details
@update:model-value="updateTls($event)"
v-model="addr.tls" />
</v-col>
<v-col cols="12" sm="6" md="4" v-if="optionSNI">
<v-text-field
label="SNI"
hide-details
v-model="addr.server_name">
</v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4" v-if="optionInsecure">
<v-switch
:label="$t('tls.insecure')"
hide-details
color="primary"
v-model="addr.insecure" />
</v-col>
</v-row>
<v-row> <v-row>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-col cols="auto" align="end" justify="center"> <v-col cols="auto" align="end" justify="center">
@@ -63,12 +40,6 @@
<v-list-item v-if="hasTls"> <v-list-item v-if="hasTls">
<v-switch v-model="optionTLS" color="primary" :label="$t('objects.tls')" hide-details></v-switch> <v-switch v-model="optionTLS" color="primary" :label="$t('objects.tls')" hide-details></v-switch>
</v-list-item> </v-list-item>
<v-list-item v-if="addr.tls">
<v-switch v-model="optionSNI" color="primary" label="SNI" hide-details></v-switch>
</v-list-item>
<v-list-item v-if="addr.tls">
<v-switch v-model="optionInsecure" color="primary" :label="$t('tls.insecure')" hide-details></v-switch>
</v-list-item>
</v-list> </v-list>
</v-card> </v-card>
</v-menu> </v-menu>
@@ -77,6 +48,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import OutTLS from '@/components/tls/OutTLS.vue'
export default { export default {
props: ['addr', 'hasTls'], props: ['addr', 'hasTls'],
data() { data() {
@@ -87,28 +59,15 @@ export default {
computed: { computed: {
optionTLS: { optionTLS: {
get(): boolean { return this.$props.addr.tls != undefined }, get(): boolean { return this.$props.addr.tls != undefined },
set(v:boolean) { this.$props.addr.tls = v ? true : undefined; this.updateTls(v) } set(v:boolean) { this.$props.addr.tls = v ? { enabled: true } : undefined; }
},
optionSNI: {
get(): boolean { return this.$props.addr.server_name != undefined },
set(v:boolean) { this.$props.addr.server_name = v ? '' : undefined }
}, },
optionRemark: { optionRemark: {
get(): boolean { return this.$props.addr.remark != undefined }, get(): boolean { return this.$props.addr.remark != undefined },
set(v:boolean) { this.$props.addr.remark = v ? '' : undefined } set(v:boolean) { this.$props.addr.remark = v ? '' : undefined }
},
optionInsecure: {
get(): boolean { return this.$props.addr.insecure != undefined },
set(v:boolean) { this.$props.addr.insecure = v ? false : undefined }
} }
}, },
methods: { components: {
updateTls(v:boolean) { OutTLS
if (!v) {
delete this.$props.addr.insecure
delete this.$props.addr.server_name
}
}
} }
} }
</script> </script>
+1 -1
View File
@@ -161,7 +161,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { acme } from '@/types/inTls' import { acme } from '@/types/tls'
export default { export default {
props: ['tls'], props: ['tls'],
+1 -1
View File
@@ -79,7 +79,7 @@
<script lang="ts"> <script lang="ts">
import { i18n } from '@/locales' import { i18n } from '@/locales'
import HttpUtils from '@/plugins/httputil' import HttpUtils from '@/plugins/httputil'
import { ech } from '@/types/inTls' import { ech } from '@/types/tls'
import { push } from 'notivue' import { push } from 'notivue'
export default { export default {
+2 -2
View File
@@ -216,7 +216,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { oTls, defaultOutTls } from '@/types/outTls' import { oTls, defaultOutTls } from '@/types/tls'
export default { export default {
props: ['outbound'], props: ['outbound'],
data() { data() {
@@ -275,7 +275,7 @@ export default {
}, },
tlsEnable: { tlsEnable: {
get() { return Object.hasOwn(this.tls, 'enabled') ? this.tls.enabled : false }, get() { return Object.hasOwn(this.tls, 'enabled') ? this.tls.enabled : false },
set(newValue: boolean) { this.$props.outbound.tls = newValue ? { enabled: true } : {} } set(newValue: boolean) { this.$props.outbound.tls = newValue ? { enabled: true } : { enabled: false } }
}, },
disable_sni: { disable_sni: {
get() { return this.tls.disable_sni ?? false }, get() { return this.tls.disable_sni ?? false },
+1 -1
View File
@@ -64,7 +64,7 @@
<template v-for="addr,index in inbound.addrs"> <template v-for="addr,index in inbound.addrs">
{{ $t('in.addr') }} #{{ (index+1) }} <v-icon icon="mdi-delete" @click="inbound.addrs?.splice(index,1)" /> {{ $t('in.addr') }} #{{ (index+1) }} <v-icon icon="mdi-delete" @click="inbound.addrs?.splice(index,1)" />
<v-divider></v-divider> <v-divider></v-divider>
<AddrVue :addr="addr" :hasTls="Object.hasOwn(inbound,'tls')" /> <AddrVue :addr="addr" :hasTls="HasTls.includes(inbound.type)" />
</template> </template>
</v-card> </v-card>
</v-window-item> </v-window-item>
+4 -5
View File
@@ -289,8 +289,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { iTls, defaultInTls } from '@/types/inTls' import { tls, iTls, defaultInTls, oTls, defaultOutTls } from '@/types/tls'
import { oTls, defaultOutTls } from '@/types/outTls'
import AcmeVue from '@/components/tls/Acme.vue' import AcmeVue from '@/components/tls/Acme.vue'
import EchVue from '@/components/tls/Ech.vue' import EchVue from '@/components/tls/Ech.vue'
import HttpUtils from '@/plugins/httputil' import HttpUtils from '@/plugins/httputil'
@@ -302,7 +301,7 @@ export default {
emits: ['close', 'save'], emits: ['close', 'save'],
data() { data() {
return { return {
tls: { id: 0, name: '', server: <iTls>{ enabled: true }, client: <oTls>{} }, tls: <tls>{ id: 0, name: '', server: <iTls>{ enabled: true }, client: <oTls>{} },
title: "add", title: "add",
loading: false, loading: false,
menu: false, menu: false,
@@ -355,7 +354,7 @@ export default {
methods: { methods: {
updateData() { updateData() {
if (this.$props.id > 0) { if (this.$props.id > 0) {
const newData = JSON.parse(this.$props.data) const newData = <tls>JSON.parse(this.$props.data)
this.tls = newData this.tls = newData
if (this.tls.server == null) this.tls.server = {} if (this.tls.server == null) this.tls.server = {}
if (this.tls.client == null) this.tls.client = {} if (this.tls.client == null) this.tls.client = {}
@@ -364,7 +363,7 @@ export default {
this.title = "edit" this.title = "edit"
} }
else { else {
this.tls = { id: 0, name: '', server: {enabled: true}, client: {} } this.tls = <tls>{ id: 0, name: '', server: {enabled: true}, client: {} }
this.tlsType = 0 this.tlsType = 0
this.usePath = 0 this.usePath = 0
this.title = "add" this.title = "add"
+1 -1
View File
@@ -1,5 +1,5 @@
import { iMultiplex } from "./multiplex" import { iMultiplex } from "./multiplex"
import { iTls } from "./inTls" import { iTls } from "./tls"
import { Dial } from "./outbounds" import { Dial } from "./outbounds"
import { Transport } from "./transport" import { Transport } from "./transport"
-50
View File
@@ -1,50 +0,0 @@
export interface oTls {
enabled?: boolean
disable_sni?: boolean
server_name?: string
insecure?: boolean
alpn?: string[]
min_version?: string
max_version?: string
cipher_suites?: string[]
certificate?: string
certificate_path?: string
ech?: {
enabled: boolean
pq_signature_schemes_enabled?: boolean
dynamic_record_sizing_disabled?: boolean
config?: string[],
config_path?: string
},
utls?: {
enabled: boolean
fingerprint: string
},
reality?: {
enabled: boolean
public_key: string
short_id: string
}
}
export const defaultOutTls: oTls = {
alpn: ['h3', 'h2', 'http/1.1'],
min_version: "1.2",
max_version: "1.3",
cipher_suites: [],
utls: {
enabled: true,
fingerprint: "chrome",
},
reality: {
enabled: true,
public_key: "",
short_id: "",
},
ech: {
enabled: true,
pq_signature_schemes_enabled: false,
dynamic_record_sizing_disabled: false,
config_path: "",
}
}
@@ -1,5 +1,12 @@
import { Dial } from "./dial" import { Dial } from "./dial"
export interface tls {
id: number
name: string
server: iTls
client: oTls
}
export interface iTls { export interface iTls {
enabled?: boolean enabled?: boolean
server_name?: string server_name?: string
@@ -63,3 +70,54 @@ export const defaultInTls: iTls = {
max_version: "1.3", max_version: "1.3",
cipher_suites: [], cipher_suites: [],
} }
export interface oTls {
enabled?: boolean
disable_sni?: boolean
server_name?: string
insecure?: boolean
alpn?: string[]
min_version?: string
max_version?: string
cipher_suites?: string[]
certificate?: string
certificate_path?: string
ech?: {
enabled: boolean
pq_signature_schemes_enabled?: boolean
dynamic_record_sizing_disabled?: boolean
config?: string[],
config_path?: string
},
utls?: {
enabled: boolean
fingerprint: string
},
reality?: {
enabled: boolean
public_key: string
short_id: string
}
}
export const defaultOutTls: oTls = {
alpn: ['h3', 'h2', 'http/1.1'],
min_version: "1.2",
max_version: "1.3",
cipher_suites: [],
utls: {
enabled: true,
fingerprint: "chrome",
},
reality: {
enabled: true,
public_key: "",
short_id: "",
},
ech: {
enabled: true,
pq_signature_schemes_enabled: false,
dynamic_record_sizing_disabled: false,
config_path: "",
}
}
+2 -2
View File
@@ -88,9 +88,9 @@
import TlsVue from '@/layouts/modals/Tls.vue' import TlsVue from '@/layouts/modals/Tls.vue'
import Data from '@/store/modules/data' import Data from '@/store/modules/data'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { Inbound, inboundWithUsers } from '@/types/inbounds' import { Inbound } from '@/types/inbounds'
import { Client } from '@/types/clients' import { Client } from '@/types/clients'
import { Link, LinkUtil } from '@/plugins/link' import { tls } from '@/types/tls'
const tlsConfigs = computed((): any[] => { const tlsConfigs = computed((): any[] => {
return Data().tlsConfigs return Data().tlsConfigs