From bf21dbef41d5c18359c89cfe9ed5f1282f076550 Mon Sep 17 00:00:00 2001 From: xxf098 Date: Sat, 11 Jul 2020 21:27:20 -0400 Subject: [PATCH] UseIPv6 config --- common.go | 8 ++++++-- tun2socks.go | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common.go b/common.go index 01fe9b2..1c5b8cf 100644 --- a/common.go +++ b/common.go @@ -319,8 +319,12 @@ func createVmessOutboundDetourConfig(profile *Vmess) conf.OutboundDetourConfig { return vmessOutboundDetourConfig } -func createFreedomOutboundDetourConfig() conf.OutboundDetourConfig { - outboundsSettings2, _ := json.Marshal(v2ray.OutboundsSettings{DomainStrategy: "UseIP"}) +func createFreedomOutboundDetourConfig(useIPv6 bool) conf.OutboundDetourConfig { + domainStrategy := "useipv4" + if useIPv6 { + domainStrategy = "useip" + } + outboundsSettings2, _ := json.Marshal(v2ray.OutboundsSettings{DomainStrategy: domainStrategy}) outboundsSettingsMsg2 := json.RawMessage(outboundsSettings2) return conf.OutboundDetourConfig{ Protocol: "freedom", diff --git a/tun2socks.go b/tun2socks.go index b205d56..8a6ea25 100644 --- a/tun2socks.go +++ b/tun2socks.go @@ -63,11 +63,12 @@ type Vmess struct { Security string // vnext.Security RouteMode int // for SSRRAY DNS string // DNS Config + UseIPv6 bool Loglevel string } // TODO: default value -func NewVmess(Host string, Path string, TLS string, Add string, Port int, Aid int, Net string, ID string, Type string, Security string, RouteMode int, DNS string, Loglevel string) *Vmess { +func NewVmess(Host string, Path string, TLS string, Add string, Port int, Aid int, Net string, ID string, Type string, Security string, RouteMode int, DNS string, UseIPv6 bool, Loglevel string) *Vmess { return &Vmess{ Host: Host, Path: Path, @@ -81,6 +82,7 @@ func NewVmess(Host string, Path string, TLS string, Add string, Port int, Aid in Security: Security, RouteMode: RouteMode, DNS: DNS, + UseIPv6: UseIPv6, Loglevel: Loglevel, } } @@ -237,7 +239,7 @@ func loadVmessConfig(profile *Vmess) (*conf.Config, error) { // }, // } vmessOutboundDetourConfig := createVmessOutboundDetourConfig(profile) - freedomOutboundDetourConfig := createFreedomOutboundDetourConfig() + freedomOutboundDetourConfig := createFreedomOutboundDetourConfig(profile.UseIPv6) // order matters // GFWList mode, use 'direct' as default if profile.RouteMode == 4 {