Skip to content

Commit

Permalink
don't unpack polipo every time
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jan 13, 2015
1 parent 179eb81 commit 4dae44c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions shadowsocks-csharp/Controller/PolipoRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -31,12 +45,10 @@ public void Start(Configuration configuration)
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.
Expand Down

0 comments on commit 4dae44c

Please sign in to comment.