add tun inbound #207

This commit is contained in:
Alireza Ahmadi
2024-10-29 01:19:18 +01:00
parent fecb29f6ab
commit 7554b02a61
10 changed files with 123 additions and 10 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
<template> <template>
<v-card :subtitle="$t('objects.listen')"> <v-card :subtitle="$t('objects.listen')">
<v-row> <v-row v-if="inbound.type != 'tun'">
<v-col cols="12" sm="6" md="4"> <v-col cols="12" sm="6" md="4">
<v-text-field <v-text-field
:label="$t('in.addr')" :label="$t('in.addr')"
@@ -78,7 +78,7 @@
</v-select> </v-select>
</v-col> </v-col>
</v-row> </v-row>
<v-card-actions class="pt-0"> <v-card-actions class="pt-0" v-if="inbound.type != 'tun'">
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-menu v-model="menu" :close-on-content-click="false" location="start"> <v-menu v-model="menu" :close-on-content-click="false" location="start">
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
+62
View File
@@ -0,0 +1,62 @@
<template>
<v-card subtitle="Tun">
<v-row>
<v-col cols="12" sm="8">
<v-text-field v-model="addrs" :label="$t('types.tun.addr') + ' ' + $t('commaSeparated')" hide-details></v-text-field>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="6" md="4">
<v-text-field v-model="data.interface_name" :label="$t('types.tun.ifName')" hide-details></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field type="number" v-model.number="data.mtu" label="MTU" hide-details></v-text-field>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="6" md="4">
<v-text-field
type="number"
v-model.number="udpTimeout"
label="UDP timeout"
min="1"
:suffix="$t('date.m')"
hide-details>
</v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-select
v-model="data.stack"
label="Stack"
:items="['system','gvisor','mixed']"
hide-details
></v-select>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-switch v-model="data.endpoint_independent_nat" color="primary" label="Independent NAT" hide-details></v-switch>
</v-col>
</v-row>
</v-card>
</template>
<script lang="ts">
export default {
props: ['data'],
data() {
return {
menu: false
}
},
computed: {
addrs: {
get() { return this.$props.data.address?.join(',') },
set(v:string) { this.$props.data.address = v.length > 0 ? v.split(',') : undefined }
},
udpTimeout: {
get() { return this.$props.data.udp_timeout ? parseInt(this.$props.data.udp_timeout.replace('m','')) : 5 },
set(v:number) { this.$props.data.udp_timeout = v > 0 ? v + 'm' : '5m' }
}
},
}
</script>
+7 -4
View File
@@ -41,6 +41,7 @@
<Naive v-if="inbound.type == inTypes.Naive" :inbound="inbound" /> <Naive v-if="inbound.type == inTypes.Naive" :inbound="inbound" />
<ShadowTls v-if="inbound.type == inTypes.ShadowTLS" direction="in" :data="inbound" :outTags="outTags" /> <ShadowTls v-if="inbound.type == inTypes.ShadowTLS" direction="in" :data="inbound" :outTags="outTags" />
<Tuic v-if="inbound.type == inTypes.TUIC" direction="in" :data="inbound" /> <Tuic v-if="inbound.type == inTypes.TUIC" direction="in" :data="inbound" />
<Tun v-if="inbound.type == inTypes.Tun" :data="inbound" />
<TProxy v-if="inbound.type == inTypes.TProxy" :inbound="inbound" /> <TProxy v-if="inbound.type == inTypes.TProxy" :inbound="inbound" />
<Transport v-if="Object.hasOwn(inbound,'transport')" :data="inbound" /> <Transport v-if="Object.hasOwn(inbound,'transport')" :data="inbound" />
<Users v-if="HasOptionalUser.includes(inbound.type)" :inbound="inbound" /> <Users v-if="HasOptionalUser.includes(inbound.type)" :inbound="inbound" />
@@ -101,6 +102,7 @@ import Hysteria2 from '@/components/protocols/Hysteria2.vue'
import Naive from '@/components/protocols/Naive.vue' import Naive from '@/components/protocols/Naive.vue'
import ShadowTls from '@/components/protocols/ShadowTls.vue' import ShadowTls from '@/components/protocols/ShadowTls.vue'
import Tuic from '@/components/protocols/Tuic.vue' import Tuic from '@/components/protocols/Tuic.vue'
import Tun from '@/components/protocols/Tun.vue'
import InTls from '@/components/tls/InTLS.vue' import InTls from '@/components/tls/InTLS.vue'
import TProxy from '@/components/protocols/TProxy.vue' import TProxy from '@/components/protocols/TProxy.vue'
import Multiplex from '@/components/Multiplex.vue' import Multiplex from '@/components/Multiplex.vue'
@@ -164,11 +166,12 @@ export default {
this.side = "s" this.side = "s"
}, },
changeType() { changeType() {
// Tag change only in add outbound if (!this.inbound.listen_port) this.inbound.listen_port = RandomUtil.randomIntRange(10000, 60000)
// Tag change only in add inbound
const tag = this.$props.index != -1 ? this.inbound.tag : this.inbound.type + "-" + this.inbound.listen_port const tag = this.$props.index != -1 ? this.inbound.tag : this.inbound.type + "-" + this.inbound.listen_port
// Use previous data // Use previous data
const prevConfig = { tag: tag ,listen: this.inbound.listen, listen_port: this.inbound.listen_port } const prevConfig = { tag: tag ,listen: this.inbound.listen?? "::", listen_port: this.inbound.listen_port }
this.inbound = createInbound(this.inbound.type, prevConfig) this.inbound = createInbound(this.inbound.type, this.inbound.type != this.inTypes.Tun ? prevConfig : { tag: tag })
if (this.HasInData.includes(this.inbound.type)){ if (this.HasInData.includes(this.inbound.type)){
if (this.inData.id == -1) this.inData.id = 0 if (this.inData.id == -1) this.inData.id = 0
this.inData.outJson = {} this.inData.outJson = {}
@@ -201,7 +204,7 @@ export default {
}, },
components: { components: {
Listen, InTls, Hysteria2, Naive, Direct, Shadowsocks, Listen, InTls, Hysteria2, Naive, Direct, Shadowsocks,
Users, Hysteria, ShadowTls, TProxy, Multiplex, Tuic, Transport, Users, Hysteria, ShadowTls, TProxy, Multiplex, Tuic, Tun, Transport,
AddrVue, OutJsonVue AddrVue, OutJsonVue
} }
} }
+4
View File
@@ -207,6 +207,10 @@ export default {
authTimeout: "Authentication Timeout", authTimeout: "Authentication Timeout",
hb: "Heartbeat", hb: "Heartbeat",
}, },
tun: {
addr: "Addresses",
ifName: "Interface Name",
},
vless: { vless: {
flow: "Flow", flow: "Flow",
udpEnc: "UDP Packet Encoding", udpEnc: "UDP Packet Encoding",
+4
View File
@@ -206,6 +206,10 @@ export default {
authTimeout: "مهلت احراز هویت", authTimeout: "مهلت احراز هویت",
hb: "ضربان قلب", hb: "ضربان قلب",
}, },
tun: {
addr: "آدرس‌ها",
ifName: "نام اینترفیس",
},
vless: { vless: {
flow: "جریان", flow: "جریان",
udpEnc: "کدگذاری بسته UDP", udpEnc: "کدگذاری بسته UDP",
+4
View File
@@ -207,6 +207,10 @@ export default {
authTimeout: "Таймаут аутентификации", authTimeout: "Таймаут аутентификации",
hb: "Сердцебиение", hb: "Сердцебиение",
}, },
tun: {
addr: "Адреса",
ifName: "Имя интерфейса",
},
vless: { vless: {
flow: "Поток", flow: "Поток",
udpEnc: "Кодирование UDP пакетов", udpEnc: "Кодирование UDP пакетов",
+4
View File
@@ -207,6 +207,10 @@ export default {
authTimeout: "Thời gian chờ Xác thực", authTimeout: "Thời gian chờ Xác thực",
hb: "Nhịp tim", hb: "Nhịp tim",
}, },
tun: {
addr: "Địa chỉ",
ifName: "Tên Giao diện",
},
vless: { vless: {
flow: "Luồng", flow: "Luồng",
udpEnc: "Mã hóa Gói UDP", udpEnc: "Mã hóa Gói UDP",
+4
View File
@@ -207,6 +207,10 @@ export default {
authTimeout: "认证超时", authTimeout: "认证超时",
hb: "心跳包", hb: "心跳包",
}, },
tun: {
addr: "地址",
ifName: "接口名称",
},
vless: { vless: {
flow: "流控", flow: "流控",
udpEnc: "UDP 数据包编码", udpEnc: "UDP 数据包编码",
+4
View File
@@ -208,6 +208,10 @@ export default {
authTimeout: "身份驗證超時", authTimeout: "身份驗證超時",
hb: "心跳", hb: "心跳",
}, },
tun: {
addr: "地址",
ifName: "介面名稱",
},
vless: { vless: {
flow: "流量", flow: "流量",
udpEnc: "UDP 封包編碼", udpEnc: "UDP 封包編碼",
+28 -4
View File
@@ -17,7 +17,7 @@ export const InTypes = {
TUIC: 'tuic', TUIC: 'tuic',
Hysteria2: 'hysteria2', Hysteria2: 'hysteria2',
VLESS: 'vless', VLESS: 'vless',
// Tun: 'tun', Tun: 'tun',
Redirect: 'redirect', Redirect: 'redirect',
TProxy: 'tproxy', TProxy: 'tproxy',
} }
@@ -165,7 +165,31 @@ export interface Hysteria2 extends InboundBasics {
brutal_debug?: boolean brutal_debug?: boolean
} }
export interface Tun extends InboundBasics { export interface Tun extends InboundBasics {
[otherProperties: string]: any interface_name?: string
address?: string[]
mtu?: number
endpoint_independent_nat?: boolean
udp_timeout?: string
stack?: string
// auto_route?: boolean
// gso?: boolean
// strict_route?: boolean
// iproute2_table_index?: number
// iproute2_rule_index?: number
// auto_redirect?: boolean
// auto_redirect_input_mark?: string
// auto_redirect_output_mark?: string
// route_address?: string[]
// route_exclude_address?: string[]
// include_interface?: string[]
// exclude_interface?: string[]
// include_uid?: string[]
// include_uid_range?: string[]
// exclude_uid?: number[]
// exclude_uid_range?: string[]
// include_android_user?: number[]
// include_package?: string[]
// exclude_package?: string[]
} }
export interface Redirect extends InboundBasics {} export interface Redirect extends InboundBasics {}
export interface TProxy extends InboundBasics { export interface TProxy extends InboundBasics {
@@ -187,7 +211,7 @@ type InterfaceMap = {
tuic: TUIC tuic: TUIC
hysteria2: Hysteria2 hysteria2: Hysteria2
vless: VLESS vless: VLESS
// tun: Tun tun: Tun
redirect: Redirect redirect: Redirect
tproxy: TProxy tproxy: TProxy
} }
@@ -228,7 +252,7 @@ const defaultValues: Record<InType, Inbound> = {
tuic: <TUIC>{ type: InTypes.TUIC, users: <TuicUser[]>[], congestion_control: "cubic", tls: { enabled: true } }, tuic: <TUIC>{ type: InTypes.TUIC, users: <TuicUser[]>[], congestion_control: "cubic", tls: { enabled: true } },
hysteria2: <Hysteria2>{ type: InTypes.Hysteria2, users: <NamePass[]>[], tls: { enabled: true } }, hysteria2: <Hysteria2>{ type: InTypes.Hysteria2, users: <NamePass[]>[], tls: { enabled: true } },
vless: <VLESS>{ type: InTypes.VLESS, users: <VlessUser[]>[], tls: {}, multiplex: {}, transport: {} }, vless: <VLESS>{ type: InTypes.VLESS, users: <VlessUser[]>[], tls: {}, multiplex: {}, transport: {} },
// tun: <Tun>{ type: InTypes.Tun }, tun: <Tun>{ type: InTypes.Tun, mtu: 9000, stack: 'system', udp_timeout: '5m' },
redirect: <Redirect>{ type: InTypes.Redirect }, redirect: <Redirect>{ type: InTypes.Redirect },
tproxy: <TProxy>{ type: InTypes.TProxy }, tproxy: <TProxy>{ type: InTypes.TProxy },
} }