diff --git a/go.mod b/go.mod index d374cb2fb..79ea6f4ba 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ replace github.com/Psiphon-Labs/psiphon-tunnel-core => github.com/uoosef/psiphon require ( github.com/MakeNowJust/heredoc/v2 v2.0.1 github.com/Psiphon-Labs/psiphon-tunnel-core v0.0.0-00010101000000-000000000000 - github.com/bepass-org/proxy v0.0.0-20240103080554-a7e12466f91f + github.com/bepass-org/proxy v0.0.0-20240201095508-c86216dd0aea github.com/go-ini/ini v1.67.0 github.com/refraction-networking/conjure v0.7.10-0.20231110193225-e4749a9dedc9 github.com/refraction-networking/utls v1.3.3 diff --git a/main.go b/main.go index 62a215c74..7c9dedac3 100644 --- a/main.go +++ b/main.go @@ -92,6 +92,7 @@ func runWarp(bindAddress, endpoint, confPath string, verbose, wait bool, startPr // Wait for interrupt signal if wait { + log.Printf("Serving on %s\n", bindAddress) <-sigChan } @@ -114,6 +115,7 @@ func runWarpWithPsiphon(bindAddress, endpoint, country string, verbose bool) { // run psiphon psiphonCtx := psiphon.RunPsiphon(warpBindAddress, bindAddress, country) + log.Printf("Serving on %s\n", bindAddress) // Wait for interrupt signal <-sigChan diff --git a/warp/account.go b/warp/account.go index 19167ebac..d7ac98e19 100644 --- a/warp/account.go +++ b/warp/account.go @@ -26,6 +26,8 @@ const ( var ( identityFile = "wgcf-identity.json" profileFile = "wgcf-profile.ini" + dnsAddresses = []string{"8.8.8.8", "8.8.4.4"} + dc = 0 ) var defaultHeaders = makeDefaultHeaders() @@ -470,7 +472,8 @@ func getWireguardConfig(privateKey, address1, address2, publicKey, endpoint stri buffer.WriteString("[Interface]\n") buffer.WriteString(fmt.Sprintf("PrivateKey = %s\n", privateKey)) - buffer.WriteString("DNS = 1.1.1.1\n") + buffer.WriteString(fmt.Sprintf("DNS = %s\n", dnsAddresses[dc%len(dnsAddresses)])) + dc++ buffer.WriteString(fmt.Sprintf("Address = %s\n", address1+"/24")) buffer.WriteString(fmt.Sprintf("Address = %s\n", address2+"/128")) diff --git a/wiresocks/config.go b/wiresocks/config.go index 47615db34..a6835fa9a 100644 --- a/wiresocks/config.go +++ b/wiresocks/config.go @@ -38,6 +38,11 @@ type Configuration struct { Device *DeviceConfig } +var ( + dnsAddresses = []string{"8.8.8.8", "8.8.4.4"} + dc = 0 +) + func parseString(section *ini.Section, keyName string) (string, error) { key := section.Key(strings.ToLower(keyName)) if key == nil { @@ -79,6 +84,10 @@ func parseNetIP(section *ini.Section, keyName string) ([]netip.Addr, error) { var ips []netip.Addr for _, str := range key.StringsWithShadows(",") { str = strings.TrimSpace(str) + if str == "1.1.1.1" { + str = dnsAddresses[dc%len(dnsAddresses)] + dc++ + } ip, err := netip.ParseAddr(str) if err != nil { return nil, err diff --git a/wiresocks/proxy.go b/wiresocks/proxy.go index e167c8c0a..6773ce625 100644 --- a/wiresocks/proxy.go +++ b/wiresocks/proxy.go @@ -14,12 +14,28 @@ type VirtualTun struct { Tnet *netstack.Net SystemDNS bool Verbose bool + Logger DefaultLogger +} + +type DefaultLogger struct { + verbose bool +} + +func (l DefaultLogger) Debug(v ...interface{}) { + if l.verbose { + log.Println(v...) + } +} + +func (l DefaultLogger) Error(v ...interface{}) { + log.Println(v...) } // StartProxy spawns a socks5 server. func (vt *VirtualTun) StartProxy(bindAddress string) { proxy := mixed.NewProxy( - mixed.WithBinAddress(bindAddress), + mixed.WithBindAddress(bindAddress), + mixed.WithLogger(vt.Logger), mixed.WithUserHandler(func(request *statute.ProxyRequest) error { return vt.generalHandler(request) }), diff --git a/wiresocks/udpfw.go b/wiresocks/udpfw.go index 3fb4388de..95bf6c7ef 100644 --- a/wiresocks/udpfw.go +++ b/wiresocks/udpfw.go @@ -54,7 +54,9 @@ func NewVtunUDPForwarder(localBind, dest string, vtun *VirtualTun, mtu int) erro fmt.Println("Error reading from connection:", err) continue } - listener.WriteMsgUDP(buffer[:n], nil, remoteAddr) + if remoteAddr != nil { + listener.WriteMsgUDP(buffer[:n], nil, remoteAddr) + } } }() return nil diff --git a/wiresocks/wiresocks.go b/wiresocks/wiresocks.go index ddb490ec9..526b4e874 100644 --- a/wiresocks/wiresocks.go +++ b/wiresocks/wiresocks.go @@ -90,5 +90,8 @@ func StartWireguard(conf *DeviceConfig, verbose bool) (*VirtualTun, error) { Tnet: tnet, SystemDNS: len(setting.dns) == 0, Verbose: verbose, + Logger: DefaultLogger{ + verbose: verbose, + }, }, nil }