Browse Source

kill existed ss_polipo

tags/2.3
clowwindy 10 years ago
parent
commit
35c9e78757
2 changed files with 11 additions and 4 deletions
  1. +3
    -2
      shadowsocks-csharp/Form1.cs
  2. +8
    -2
      shadowsocks-csharp/PolipoRunner.cs

+ 3
- 2
shadowsocks-csharp/Form1.cs View File

@@ -61,14 +61,15 @@ namespace shadowsocks_csharp
polipoRunner.Stop();
}
}
local = new Local(config);
local.Start();
if (polipoRunner == null)
{
polipoRunner = new PolipoRunner();
}
polipoRunner.Start(config);
local = new Local(config);
local.Start();
}
private void Config_Click(object sender, EventArgs e)


+ 8
- 2
shadowsocks-csharp/PolipoRunner.cs View File

@@ -32,15 +32,21 @@ namespace shadowsocks_csharp
{
if (process == null)
{
Process[] existingPolipo = Process.GetProcessesByName("ss_polipo");
foreach (Process p in existingPolipo)
{
p.Kill();
p.WaitForExit();
}
string temppath = Path.GetTempPath();
string polipoConfig = Resources.polipo_config;
polipoConfig = polipoConfig.Replace("__SOCKS_PORT__", config.local_port.ToString());
ByteArrayToFile(temppath + "/polipo.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig));
ByteArrayToFile(temppath + "/polipo.exe", Resources.polipo);
ByteArrayToFile(temppath + "/ss_polipo.exe", Resources.polipo);
process = new Process();
// Configure the process using the StartInfo properties.
process.StartInfo.FileName = temppath + "/polipo.exe";
process.StartInfo.FileName = temppath + "/ss_polipo.exe";
process.StartInfo.Arguments = "-c \"" + temppath + "/polipo.conf\"";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;


Loading…
Cancel
Save