fix: patch update support tun

This commit is contained in:
adlyq
2022-05-03 19:13:37 +08:00
parent 52d559bb38
commit eca7615f08
4 changed files with 91 additions and 19 deletions

View File

@ -23,18 +23,14 @@ import (
)
// New TunAdapter
func New(tunConf *config.Tun, dnsConf *config.DNS, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.Stack, error) {
var tunAddressPrefix string
if dnsConf.FakeIPRange != nil {
tunAddressPrefix = dnsConf.FakeIPRange.IPNet().String()
}
func New(tunConf *config.Tun, tunAddressPrefix *netip.Prefix, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.Stack, error) {
var (
tunAddress, _ = netip.ParsePrefix(tunAddressPrefix)
devName = tunConf.Device
stackType = tunConf.Stack
autoRoute = tunConf.AutoRoute
mtu = 9000
tunAddress = netip.Prefix{}
devName = tunConf.Device
stackType = tunConf.Stack
autoRoute = tunConf.AutoRoute
mtu = 9000
tunDevice device.Device
tunStack ipstack.Stack
@ -42,6 +38,10 @@ func New(tunConf *config.Tun, dnsConf *config.DNS, tcpIn chan<- C.ConnContext, u
err error
)
if tunAddressPrefix != nil {
tunAddress = *tunAddressPrefix
}
if devName == "" {
devName = generateDeviceName()
}