From 4dae44c59bfb14d49b87eaee59ed2a0c976763c1 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Wed, 14 Jan 2015 01:17:41 +0800 Subject: [PATCH] don't unpack polipo every time --- shadowsocks-csharp/Controller/PolipoRunner.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/shadowsocks-csharp/Controller/PolipoRunner.cs b/shadowsocks-csharp/Controller/PolipoRunner.cs index a44e5ea1..42bf3bfa 100755 --- a/shadowsocks-csharp/Controller/PolipoRunner.cs +++ b/shadowsocks-csharp/Controller/PolipoRunner.cs @@ -12,6 +12,20 @@ namespace Shadowsocks.Controller class PolipoRunner { private Process _process; + private static string temppath; + + static PolipoRunner() + { + temppath = Path.GetTempPath(); + try + { + FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe); + } + catch (IOException e) + { + Logging.LogUsefulException(e); + } + } public void Start(Configuration configuration) { @@ -31,12 +45,10 @@ namespace Shadowsocks.Controller Console.WriteLine(e.ToString()); } } - string temppath = Path.GetTempPath(); string polipoConfig = Resources.polipo_config; polipoConfig = polipoConfig.Replace("__SOCKS_PORT__", server.local_port.ToString()); polipoConfig = polipoConfig.Replace("__POLIPO_BIND_IP__", configuration.shareOverLan ? "0.0.0.0" : "127.0.0.1"); FileManager.ByteArrayToFile(temppath + "/polipo.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig)); - FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe); _process = new Process(); // Configure the process using the StartInfo properties.