use local port in pac

This commit is contained in:
clowwindy
2015-01-18 17:12:59 +08:00
parent 43a952d3d7
commit 5aa2822904
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -17,6 +17,7 @@ namespace Shadowsocks.Controller
public static string PAC_FILE = "pac.txt";
FileSystemWatcher watcher;
private Configuration _config;
public event EventHandler PACFileChanged;
@@ -25,6 +26,11 @@ namespace Shadowsocks.Controller
this.WatchPacFile();
}
public void UpdateConfiguration(Configuration config)
{
this._config = config;
}
public bool Handle(byte[] firstPacket, int length, Socket socket)
{
try
@@ -159,7 +165,7 @@ Connection: Close
private string GetPACAddress(byte[] requestBuf, int length, IPEndPoint localEndPoint)
{
return "PROXY " + localEndPoint.Address + ":8123;";
return "PROXY " + localEndPoint.Address + ":" + this._config.localPort + ";";
}
}
}
@@ -196,6 +196,7 @@ namespace Shadowsocks.Controller
_pacServer = new PACServer();
_pacServer.PACFileChanged += pacServer_PACFileChanged;
}
_pacServer.UpdateConfiguration(_config);
if (gfwListUpdater == null)
{
gfwListUpdater = new GFWListUpdater();