Browse Source

add Pac support for IPv6

tags/4.1.7
Yifei0727 6 years ago
parent
commit
58c914d8ed
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      shadowsocks-csharp/Controller/Service/PACServer.cs

+ 6
- 4
shadowsocks-csharp/Controller/Service/PACServer.cs View File

@@ -51,7 +51,7 @@ namespace Shadowsocks.Controller
PacSecret = ""; 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 (!secretMatch)
{ {
if(line.IndexOf(PacSecret, StringComparison.Ordinal) >= 0)
if (line.IndexOf(PacSecret, StringComparison.Ordinal) >= 0)
{ {
secretMatch = true; secretMatch = true;
} }
@@ -255,7 +255,7 @@ Connection: Close
if (UserRuleFileChanged != null) if (UserRuleFileChanged != null)
{ {
Logging.Info($"Detected: User Rule file '{e.Name}' was {e.ChangeType.ToString().ToLower()}."); Logging.Info($"Detected: User Rule file '{e.Name}' was {e.ChangeType.ToString().ToLower()}.");
Task.Factory.StartNew(()=>
Task.Factory.StartNew(() =>
{ {
((FileSystemWatcher)sender).EnableRaisingEvents = false; ((FileSystemWatcher)sender).EnableRaisingEvents = false;
System.Threading.Thread.Sleep(10); System.Threading.Thread.Sleep(10);
@@ -268,7 +268,9 @@ Connection: Close
private string GetPACAddress(IPEndPoint localEndPoint, bool useSocks) 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};";
} }
} }
} }

Loading…
Cancel
Save