From 17769e1a8f6eab4b1c0a244c9c89baaf8dc8b6a3 Mon Sep 17 00:00:00 2001 From: gVisor bot 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 091f2efa..e0401d42 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 a38c90b2..604e38b7 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",