diff --git a/shadowsocks-csharp/Controller/Service/PolipoRunner.cs b/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs similarity index 87% rename from shadowsocks-csharp/Controller/Service/PolipoRunner.cs rename to shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs index 284f4141..631a65f4 100644 --- a/shadowsocks-csharp/Controller/Service/PolipoRunner.cs +++ b/shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs @@ -16,21 +16,21 @@ using Shadowsocks.Util.ProcessManagement; namespace Shadowsocks.Controller { - class PolipoRunner + class PrivoxyRunner { private static int Uid; private static string UniqueConfigFile; - private static Job PolipoJob; + private static Job PrivoxyJob; private Process _process; private int _runningPort; - static PolipoRunner() + static PrivoxyRunner() { try { - Uid = Application.StartupPath.GetHashCode(); // Currently we use ss's StartupPath to identify different polipo instance. + Uid = Application.StartupPath.GetHashCode(); // Currently we use ss's StartupPath to identify different Privoxy instance. UniqueConfigFile = $"privoxy_{Uid}.conf"; - PolipoJob = new Job(); + PrivoxyJob = new Job(); FileManager.UncompressFile(Utils.GetTempPath("ss_privoxy.exe"), Resources.privoxy_exe); FileManager.UncompressFile(Utils.GetTempPath("mgwz.dll"), Resources.mgwz_dll); @@ -54,17 +54,17 @@ namespace Shadowsocks.Controller Server server = configuration.GetCurrentServer(); if (_process == null) { - Process[] existingPolipo = Process.GetProcessesByName("ss_privoxy"); - foreach (Process p in existingPolipo.Where(IsChildProcess)) + Process[] existingPrivoxy = Process.GetProcessesByName("ss_privoxy"); + foreach (Process p in existingPrivoxy.Where(IsChildProcess)) { KillProcess(p); } - string polipoConfig = Resources.privoxy_conf; + string privoxyConfig = Resources.privoxy_conf; _runningPort = this.GetFreePort(); - polipoConfig = polipoConfig.Replace("__SOCKS_PORT__", configuration.localPort.ToString()); - polipoConfig = polipoConfig.Replace("__POLIPO_BIND_PORT__", _runningPort.ToString()); - polipoConfig = polipoConfig.Replace("__POLIPO_BIND_IP__", configuration.shareOverLan ? "0.0.0.0" : "127.0.0.1"); - FileManager.ByteArrayToFile(Utils.GetTempPath(UniqueConfigFile), Encoding.UTF8.GetBytes(polipoConfig)); + privoxyConfig = privoxyConfig.Replace("__SOCKS_PORT__", configuration.localPort.ToString()); + privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_PORT__", _runningPort.ToString()); + privoxyConfig = privoxyConfig.Replace("__PRIVOXY_BIND_IP__", configuration.shareOverLan ? "0.0.0.0" : "127.0.0.1"); + FileManager.ByteArrayToFile(Utils.GetTempPath(UniqueConfigFile), Encoding.UTF8.GetBytes(privoxyConfig)); _process = new Process(); // Configure the process using the StartInfo properties. @@ -80,7 +80,7 @@ namespace Shadowsocks.Controller * Add this process to job obj associated with this ss process, so that * when ss exit unexpectedly, this process will be forced killed by system. */ - PolipoJob.AddProcess(_process.Handle); + PrivoxyJob.AddProcess(_process.Handle); } RefreshTrayArea(); } diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index a26676f3..6340213a 100644 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -28,7 +28,7 @@ namespace Shadowsocks.Controller private PACServer _pacServer; private Configuration _config; private StrategyManager _strategyManager; - private PolipoRunner polipoRunner; + private PrivoxyRunner privoxyRunner; private GFWListUpdater gfwListUpdater; public AvailabilityStatistics availabilityStatistics = AvailabilityStatistics.Instance; public StatisticsStrategyConfiguration StatisticsConfiguration { get; private set; } @@ -264,9 +264,9 @@ namespace Shadowsocks.Controller { _listener.Stop(); } - if (polipoRunner != null) + if (privoxyRunner != null) { - polipoRunner.Stop(); + privoxyRunner.Stop(); } if (_config.enabled) { @@ -417,9 +417,9 @@ namespace Shadowsocks.Controller _config = Configuration.Load(); StatisticsConfiguration = StatisticsStrategyConfiguration.Load(); - if (polipoRunner == null) + if (privoxyRunner == null) { - polipoRunner = new PolipoRunner(); + privoxyRunner = new PrivoxyRunner(); } if (_pacServer == null) { @@ -441,11 +441,11 @@ namespace Shadowsocks.Controller { _listener.Stop(); } - // don't put polipoRunner.Start() before pacServer.Stop() + // don't put PrivoxyRunner.Start() before pacServer.Stop() // or bind will fail when switching bind address from 0.0.0.0 to 127.0.0.1 // though UseShellExecute is set to true now // http://stackoverflow.com/questions/10235093/socket-doesnt-close-after-application-exits-if-a-launched-process-is-open - polipoRunner.Stop(); + privoxyRunner.Stop(); try { var strategy = GetCurrentStrategy(); @@ -454,7 +454,7 @@ namespace Shadowsocks.Controller strategy.ReloadServers(); } - polipoRunner.Start(_config); + privoxyRunner.Start(_config); TCPRelay tcpRelay = new TCPRelay(this, _config); UDPRelay udpRelay = new UDPRelay(this); @@ -462,7 +462,7 @@ namespace Shadowsocks.Controller services.Add(tcpRelay); services.Add(udpRelay); services.Add(_pacServer); - services.Add(new PortForwarder(polipoRunner.RunningPort)); + services.Add(new PortForwarder(privoxyRunner.RunningPort)); _listener = new Listener(services); _listener.Start(_config); } diff --git a/shadowsocks-csharp/Data/privoxy_conf.txt b/shadowsocks-csharp/Data/privoxy_conf.txt index 98267fa6..5d274c4c 100644 --- a/shadowsocks-csharp/Data/privoxy_conf.txt +++ b/shadowsocks-csharp/Data/privoxy_conf.txt @@ -1,4 +1,4 @@ -listen-address __POLIPO_BIND_IP__:__POLIPO_BIND_PORT__ +listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__ show-on-task-bar 0 activity-animation 0 forward-socks5 / 127.0.0.1:__SOCKS_PORT__ . diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index 297c8965..36ef328d 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -198,7 +198,7 @@ ConfigForm.cs - +