From c968104a199591b6763147657e03fadef5434bdb Mon Sep 17 00:00:00 2001 From: Skyxim Date: Tue, 14 Jun 2022 12:35:24 +0800 Subject: [PATCH] fix: udp listen use udp4 when general.ipv6 is false; general.ipv6 default value is true --- component/dialer/dialer.go | 4 ++++ config/config.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/component/dialer/dialer.go b/component/dialer/dialer.go index 091f2efa0..e0401d426 100644 --- a/component/dialer/dialer.go +++ b/component/dialer/dialer.go @@ -57,6 +57,10 @@ func ListenPacket(ctx context.Context, network, address string, options ...Optio o(cfg) } + if DisableIPv6 { + network = "udp4" + } + lc := &net.ListenConfig{} if cfg.interfaceName != "" { addr, err := bindIfaceToListenConfig(cfg.interfaceName, lc, network, address) diff --git a/config/config.go b/config/config.go index a38c90b25..604e38b7e 100644 --- a/config/config.go +++ b/config/config.go @@ -254,6 +254,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) { rawCfg := &RawConfig{ AllowLan: false, BindAddress: "*", + IPv6: true, Mode: T.Rule, GeodataMode: C.GeodataMode, GeodataLoader: "memconservative", @@ -281,6 +282,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) { }, DNS: RawDNS{ Enable: false, + IPv6: false, UseHosts: true, EnhancedMode: C.DNSMapping, FakeIPRange: "198.18.0.1/16",