diff --git a/shadowsocks-csharp/Controller/Service/PACServer.cs b/shadowsocks-csharp/Controller/Service/PACServer.cs index 63d0b5bd..b53648fc 100644 --- a/shadowsocks-csharp/Controller/Service/PACServer.cs +++ b/shadowsocks-csharp/Controller/Service/PACServer.cs @@ -51,7 +51,7 @@ namespace Shadowsocks.Controller PacSecret = ""; } - PacUrl = $"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}{PacSecret}"; + PacUrl = $"http://{config.LocalHost}:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}{PacSecret}"; } @@ -101,7 +101,7 @@ namespace Shadowsocks.Controller } if (!secretMatch) { - if(line.IndexOf(PacSecret, StringComparison.Ordinal) >= 0) + if (line.IndexOf(PacSecret, StringComparison.Ordinal) >= 0) { secretMatch = true; } @@ -255,7 +255,7 @@ Connection: Close if (UserRuleFileChanged != null) { Logging.Info($"Detected: User Rule file '{e.Name}' was {e.ChangeType.ToString().ToLower()}."); - Task.Factory.StartNew(()=> + Task.Factory.StartNew(() => { ((FileSystemWatcher)sender).EnableRaisingEvents = false; System.Threading.Thread.Sleep(10); @@ -268,7 +268,9 @@ Connection: Close private string GetPACAddress(IPEndPoint localEndPoint, bool useSocks) { - return $"{(useSocks ? "SOCKS5" : "PROXY")} {localEndPoint.Address}:{_config.localPort};"; + return localEndPoint.AddressFamily == AddressFamily.InterNetworkV6 + ? $"{(useSocks ? "SOCKS5" : "PROXY")} [{localEndPoint.Address}]:{_config.localPort};" + : $"{(useSocks ? "SOCKS5" : "PROXY")} {localEndPoint.Address}:{_config.localPort};"; } } }