fix: npe
This commit is contained in:
parent
e1a61503e4
commit
9b999e72ce
@ -115,7 +115,7 @@ type Tun struct {
|
|||||||
DNSHijack []netip.AddrPort `yaml:"dns-hijack" json:"dns-hijack"`
|
DNSHijack []netip.AddrPort `yaml:"dns-hijack" json:"dns-hijack"`
|
||||||
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
|
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
|
||||||
AutoDetectInterface bool `yaml:"auto-detect-interface" json:"auto-detect-interface"`
|
AutoDetectInterface bool `yaml:"auto-detect-interface" json:"auto-detect-interface"`
|
||||||
TunAddressPrefix *netip.Prefix `yaml:"-" json:"-"`
|
TunAddressPrefix netip.Prefix `yaml:"-" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPTables config
|
// IPTables config
|
||||||
@ -910,9 +910,11 @@ func parseTun(rawTun RawTun, general *General, dnsCfg *DNS) (*Tun, error) {
|
|||||||
dnsHijack = append(dnsHijack, addrPort)
|
dnsHijack = append(dnsHijack, addrPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tunAddressPrefix *netip.Prefix
|
var tunAddressPrefix netip.Prefix
|
||||||
if dnsCfg.FakeIPRange != nil {
|
if dnsCfg.FakeIPRange != nil {
|
||||||
tunAddressPrefix = dnsCfg.FakeIPRange.IPNet()
|
tunAddressPrefix = *dnsCfg.FakeIPRange.IPNet()
|
||||||
|
} else {
|
||||||
|
tunAddressPrefix = netip.MustParsePrefix("198.18.0.1/16")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Tun{
|
return &Tun{
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
func New(tunConf *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.Stack, error) {
|
func New(tunConf *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.Stack, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
tunAddress = netip.Prefix{}
|
tunAddress = tunConf.TunAddressPrefix
|
||||||
devName = tunConf.Device
|
devName = tunConf.Device
|
||||||
stackType = tunConf.Stack
|
stackType = tunConf.Stack
|
||||||
autoRoute = tunConf.AutoRoute
|
autoRoute = tunConf.AutoRoute
|
||||||
@ -38,10 +38,6 @@ func New(tunConf *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if tunConf.TunAddressPrefix != nil {
|
|
||||||
tunAddress = *tunConf.TunAddressPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
if devName == "" {
|
if devName == "" {
|
||||||
devName = generateDeviceName()
|
devName = generateDeviceName()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user