Browse Source

compress polipo

tags/2.3
clowwindy 10 years ago
parent
commit
c68afffe6f
6 changed files with 42 additions and 14 deletions
  1. +28
    -1
      shadowsocks-csharp/PolipoRunner.cs
  2. +10
    -10
      shadowsocks-csharp/Properties/Resources.Designer.cs
  3. +3
    -3
      shadowsocks-csharp/Properties/Resources.resx
  4. BIN
      shadowsocks-csharp/polipo.exe
  5. BIN
      shadowsocks-csharp/polipo.exe.gz
  6. +1
    -0
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 28
- 1
shadowsocks-csharp/PolipoRunner.cs View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace shadowsocks_csharp
@@ -28,6 +29,32 @@ namespace shadowsocks_csharp
}
return false;
}
public static void UncompressFile(string fileName, byte[] content)
{
FileStream destinationFile = File.Create(fileName);
// Because the uncompressed size of the file is unknown,
// we are using an arbitrary buffer size.
byte[] buffer = new byte[4096];
int n;
using (GZipStream input = new GZipStream(new MemoryStream(content),
CompressionMode.Decompress, false))
{
while (true)
{
n = input.Read(buffer, 0, buffer.Length);
if (n == 0)
{
break;
}
destinationFile.Write(buffer, 0, n);
}
}
destinationFile.Close();
}
public void Start(Config config)
{
if (process == null)
@@ -42,7 +69,7 @@ namespace shadowsocks_csharp
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 + "/ss_polipo.exe", Resources.polipo);
UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe);
process = new Process();
// Configure the process using the StartInfo properties.


+ 10
- 10
shadowsocks-csharp/Properties/Resources.Designer.cs View File

@@ -60,16 +60,6 @@ namespace shadowsocks_csharp.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] polipo {
get {
object obj = ResourceManager.GetObject("polipo", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized string similar to # Sample configuration file for Polipo. -*-sh-*-
///
@@ -95,6 +85,16 @@ namespace shadowsocks_csharp.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] polipo_exe {
get {
object obj = ResourceManager.GetObject("polipo_exe", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized string similar to // Generated by gfwlist2pac
///// https://github.com/clowwindy/gfwlist2pac


+ 3
- 3
shadowsocks-csharp/Properties/Resources.resx View File

@@ -118,12 +118,12 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="polipo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\polipo.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="polipo_config" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value>
</data>
<data name="polipo_exe" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\polipo.exe.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="proxy_pac" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\proxy.pac.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value>
</data>

BIN
shadowsocks-csharp/polipo.exe View File


BIN
shadowsocks-csharp/polipo.exe.gz View File


+ 1
- 0
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -115,6 +115,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="polipo.exe.gz" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>


Loading…
Cancel
Save