Browse Source

Merge pull request #7 from clowwindy/master

Merge with upstream
pull/146/head
Sharuru 10 years ago
parent
commit
87a5dbfa9f
16 changed files with 62 additions and 62 deletions
  1. +4
    -0
      CHANGES
  2. +0
    -2
      README.md
  3. +21
    -0
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  4. BIN
      shadowsocks-csharp/Data/libeay32.dll.gz
  5. BIN
      shadowsocks-csharp/Data/polarssl.dll.gz
  6. BIN
      shadowsocks-csharp/Data/polipo.exe.gz
  7. BIN
      shadowsocks-csharp/Data/ss32.ico
  8. +0
    -17
      shadowsocks-csharp/Encrypt/PolarSSL.cs
  9. +0
    -36
      shadowsocks-csharp/Encrypt/PolarSSLEncryptor.cs
  10. +2
    -1
      shadowsocks-csharp/Program.cs
  11. +1
    -1
      shadowsocks-csharp/Properties/AssemblyInfo.cs
  12. +30
    -0
      shadowsocks-csharp/Util/Util.cs
  13. +0
    -1
      shadowsocks-csharp/View/ConfigForm.Designer.cs
  14. +1
    -1
      shadowsocks-csharp/View/ConfigForm.cs
  15. +2
    -2
      shadowsocks-csharp/View/MenuViewController.cs
  16. +1
    -1
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 4
- 0
CHANGES View File

@@ -1,3 +1,7 @@
2.0.10 2014-11-18
- Minor fixes
- Optimize code

2.0.9 2014-11-13
- Fix startup path
- Fix allowed port range for polipo


+ 0
- 2
README.md View File

@@ -3,8 +3,6 @@ Shadowsocks for Windows

[![Build Status]][Appveyor]

Currently beta. Please file an issue if you find any bugs.

### Features

1. Native Windows UI


+ 21
- 0
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -14,6 +14,8 @@ namespace Shadowsocks.Controller
// manipulates UI
// interacts with low level logic
private Thread _ramThread;
private Local local;
private PACServer pacServer;
private Configuration _config;
@@ -58,6 +60,7 @@ namespace Shadowsocks.Controller
}
UpdateSystemProxy();
StartReleasingMemory();
}
public Server GetCurrentServer()
@@ -161,6 +164,8 @@ namespace Shadowsocks.Controller
{
ConfigChanged(this, new EventArgs());
}
Util.Util.ReleaseMemory();
}
@@ -180,5 +185,21 @@ namespace Shadowsocks.Controller
{
UpdateSystemProxy();
}
private void StartReleasingMemory()
{
_ramThread = new Thread(new ThreadStart(ReleaseMemory));
_ramThread.IsBackground = true;
_ramThread.Start();
}
private void ReleaseMemory()
{
while (true)
{
Util.Util.ReleaseMemory();
Thread.Sleep(30 * 1000);
}
}
}
}

BIN
shadowsocks-csharp/Data/libeay32.dll.gz View File


BIN
shadowsocks-csharp/Data/polarssl.dll.gz View File


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


BIN
shadowsocks-csharp/Data/ss32.ico View File

Before After

+ 0
- 17
shadowsocks-csharp/Encrypt/PolarSSL.cs View File

@@ -61,22 +61,5 @@ namespace Shadowsocks.Encrypt
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public extern static int arc4_crypt(IntPtr ctx, int length, byte[] input, byte[] output);
public const int BLOWFISH_CTX_SIZE = 4168;
public const int BLOWFISH_ENCRYPT = 1;
public const int BLOWFISH_DECRYPT = 0;
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public extern static void blowfish_init(IntPtr ctx);
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public extern static void blowfish_free(IntPtr ctx);
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public extern static int blowfish_setkey(IntPtr ctx, byte[] key, int keysize);
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public extern static int blowfish_crypt_cfb64(IntPtr ctx, int mode, int length, ref int iv_off, byte[] iv, byte[] input, byte[] output);
}
}

+ 0
- 36
shadowsocks-csharp/Encrypt/PolarSSLEncryptor.cs View File

@@ -12,13 +12,11 @@ namespace Shadowsocks.Encrypt
{
const int CIPHER_AES = 1;
const int CIPHER_RC4 = 2;
const int CIPHER_BF = 3;
static Dictionary<string, int[]> ciphers = new Dictionary<string, int[]> {
{"aes-128-cfb", new int[]{16, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}},
{"aes-192-cfb", new int[]{24, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}},
{"aes-256-cfb", new int[]{32, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}},
{"bf-cfb", new int[]{16, 8, CIPHER_BF, PolarSSL.BLOWFISH_CTX_SIZE}},
{"rc4", new int[]{16, 0, CIPHER_RC4, PolarSSL.ARC4_CTX_SIZE}},
{"rc4-md5", new int[]{16, 16, CIPHER_RC4, PolarSSL.ARC4_CTX_SIZE}},
};
@@ -133,22 +131,6 @@ namespace Shadowsocks.Encrypt
Array.Copy(iv, _decryptIV, ivLen);
}
}
else if (_cipher == CIPHER_BF)
{
PolarSSL.blowfish_init(ctx);
// PolarSSL takes key length by bit
PolarSSL.blowfish_setkey(ctx, realkey, keyLen * 8);
if (isCipher)
{
_encryptIV = new byte[ivLen];
Array.Copy(iv, _encryptIV, ivLen);
}
else
{
_decryptIV = new byte[ivLen];
Array.Copy(iv, _decryptIV, ivLen);
}
}
else if (_cipher == CIPHER_RC4)
{
PolarSSL.arc4_init(ctx);
@@ -180,9 +162,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_crypt_cfb128(_encryptCtx, PolarSSL.AES_ENCRYPT, length, ref _encryptIVOffset, _encryptIV, buf, tempbuf);
break;
case CIPHER_BF:
PolarSSL.blowfish_crypt_cfb64(_encryptCtx, PolarSSL.BLOWFISH_ENCRYPT, length, ref _encryptIVOffset, _encryptIV, buf, tempbuf);
break;
case CIPHER_RC4:
PolarSSL.arc4_crypt(_encryptCtx, length, buf, tempbuf);
break;
@@ -204,9 +183,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_crypt_cfb128(_encryptCtx, PolarSSL.AES_ENCRYPT, length, ref _encryptIVOffset, _encryptIV, buf, outbuf);
break;
case CIPHER_BF:
PolarSSL.blowfish_crypt_cfb64(_encryptCtx, PolarSSL.BLOWFISH_ENCRYPT, length, ref _encryptIVOffset, _encryptIV, buf, outbuf);
break;
case CIPHER_RC4:
PolarSSL.arc4_crypt(_encryptCtx, length, buf, outbuf);
break;
@@ -233,9 +209,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_crypt_cfb128(_decryptCtx, PolarSSL.AES_DECRYPT, length - ivLen, ref _decryptIVOffset, _decryptIV, tempbuf, outbuf);
break;
case CIPHER_BF:
PolarSSL.blowfish_crypt_cfb64(_decryptCtx, PolarSSL.BLOWFISH_DECRYPT, length - ivLen, ref _decryptIVOffset, _decryptIV, tempbuf, outbuf);
break;
case CIPHER_RC4:
PolarSSL.arc4_crypt(_decryptCtx, length - ivLen, tempbuf, outbuf);
break;
@@ -254,9 +227,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_crypt_cfb128(_decryptCtx, PolarSSL.AES_DECRYPT, length, ref _decryptIVOffset, _decryptIV, buf, outbuf);
break;
case CIPHER_BF:
PolarSSL.blowfish_crypt_cfb64(_decryptCtx, PolarSSL.BLOWFISH_DECRYPT, length, ref _decryptIVOffset, _decryptIV, buf, outbuf);
break;
case CIPHER_RC4:
PolarSSL.arc4_crypt(_decryptCtx, length, buf, outbuf);
break;
@@ -298,9 +268,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_free(_encryptCtx);
break;
case CIPHER_BF:
PolarSSL.blowfish_free(_encryptCtx);
break;
case CIPHER_RC4:
PolarSSL.arc4_free(_encryptCtx);
break;
@@ -315,9 +282,6 @@ namespace Shadowsocks.Encrypt
case CIPHER_AES:
PolarSSL.aes_free(_decryptCtx);
break;
case CIPHER_BF:
PolarSSL.blowfish_free(_decryptCtx);
break;
case CIPHER_RC4:
PolarSSL.arc4_free(_decryptCtx);
break;


+ 2
- 1
shadowsocks-csharp/Program.cs View File

@@ -12,13 +12,13 @@ namespace Shadowsocks
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Util.Util.ReleaseMemory();
using (Mutex mutex = new Mutex(false, "Global\\" + "71981632-A427-497F-AB91-241CD227EC1F"))
{
Application.EnableVisualStyles();
@@ -41,6 +41,7 @@ namespace Shadowsocks
ShadowsocksController controller = new ShadowsocksController();
MenuViewController viewController = new MenuViewController(controller);
Util.Util.ReleaseMemory();
Application.Run();
}
}


+ 1
- 1
shadowsocks-csharp/Properties/AssemblyInfo.cs View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.9")]
[assembly: AssemblyVersion("2.0.10")]
// [assembly: AssemblyFileVersion("2.0.0")]

+ 30
- 0
shadowsocks-csharp/Util/Util.cs View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
namespace Shadowsocks.Util
{
public class Util
{
public static void ReleaseMemory()
{
// release any unused pages
// making the numbers look good in task manager
// this is totally nonsense in programming
// but good for those users who care
// making them happier with their everyday life
// which is part of user experience
GC.Collect(GC.MaxGeneration);
GC.WaitForPendingFinalizers();
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle,
(UIntPtr)0xFFFFFFFF, (UIntPtr)0xFFFFFFFF);
}
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetProcessWorkingSetSize(IntPtr process,
UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);
}
}

+ 0
- 1
shadowsocks-csharp/View/ConfigForm.Designer.cs View File

@@ -209,7 +209,6 @@
"aes-256-cfb",
"aes-192-cfb",
"aes-128-cfb",
"bf-cfb",
"rc4"});
this.EncryptionSelect.Location = new System.Drawing.Point(74, 86);
this.EncryptionSelect.Name = "EncryptionSelect";


+ 1
- 1
shadowsocks-csharp/View/ConfigForm.cs View File

@@ -180,7 +180,7 @@ namespace Shadowsocks.View
return;
}
controller.SaveServers(_modifiedConfiguration.configs);
this.Hide();
this.Close();
}
private void CancelButton_Click(object sender, EventArgs e)


+ 2
- 2
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -86,6 +86,7 @@ namespace Shadowsocks.View
icon = Resources.ss24;
}
notifyIcon1 = new NotifyIcon();
notifyIcon1.Text = "Shadowsocks";
notifyIcon1.Icon = Icon.FromHandle(icon.GetHicon());
notifyIcon1.Visible = true;
@@ -299,8 +300,7 @@ namespace Shadowsocks.View
void configForm_FormClosed(object sender, FormClosedEventArgs e)
{
configForm = null;
GC.Collect();
GC.WaitForPendingFinalizers();
Util.Util.ReleaseMemory();
ShowFirstTimeBalloon();
}


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

@@ -84,6 +84,7 @@
<Compile Include="Controller\PACServer.cs" />
<Compile Include="Model\Server.cs" />
<Compile Include="Model\Configuration.cs" />
<Compile Include="Util\Util.cs" />
<Compile Include="View\ConfigForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -124,7 +125,6 @@
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Data\libeay32.dll.gz" />
<None Include="Data\polarssl.dll.gz" />
<None Include="Data\polipo.exe.gz" />
<None Include="Properties\Settings.settings">


Loading…
Cancel
Save