Compare commits

...
19 Commits
Author SHA1 Message Date
Syrone Wong 89b7043a4e Update CHANGES and bump version
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-21 09:57:08 +08:00
Syrone Wong 9c438ee745 Misc
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-21 08:17:28 +08:00
Syrone Wong ce26bc15a9 Refine random generator handling
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-20 08:15:47 +08:00
Syrone Wong 4b99a5c210 Make registry opening more generic
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-20 08:05:25 +08:00
Syrone Wong 5721769c6d Refine Remote Access Service query for WinVista and later
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-16 16:43:11 +08:00
Syrone Wong 1c1cc62235 System proxy support for Remote Access Service
e.g. Dial-up connection and VPN

- use INTERNET_OPTION_PROXY_SETTINGS_CHANGED instead of INTERNET_OPTION_SETTINGS_CHANGED

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-16 12:36:12 +08:00
Jiangzhuo 3fe8484b8b Fix link to GFWList (#793)
Thanks to @jiangzhuo
2016-10-14 19:46:20 +08:00
Syrone Wong 131114f0c2 Fix #779
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-12 09:36:17 +08:00
Syrone Wong 74ad98d9ce Distinguish unhandled error type
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-12 07:40:42 +08:00
Syrone Wong 90ae73057e Misc
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-11 17:00:19 +08:00
Syrone Wong a12ae96443 Update CHANGES and bump version
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-10 13:53:45 +08:00
Syrone Wong 0ca7d1751b Cleanup refs
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-09 21:20:32 +08:00
Syrone Wong 10702a029c Misc
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-09 11:01:43 +08:00
Syrone Wong e099e92d1a Fix typo
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-08 14:13:08 +08:00
Syrone Wong ebc8d9c5bd Catch more exceptions
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-07 10:11:32 +08:00
Syrone Wong af139d7587 Only integer is allowed for timeout
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-07 08:57:55 +08:00
Syrone Wong 04ed25e16f Add timeout support for server and forward proxy
Also, fix typo in ProxyForm

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-06 21:03:45 +08:00
Syrone Wong a74fa34d45 Upgrade to .NET Framework 4.6.2
Be sure to install develop package and runtime library if needed
since Visual Studio has 4.6.1 included.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-06 16:45:11 +08:00
Syrone Wong 70bff7d7cc Use wininet API to setup system proxy
Get rid of tricky registry handling

Several files come from https://code.msdn.microsoft.com/windowsapps/CSWebBrowserWithProxy-c8535715/view/SourceCode

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-06 16:12:35 +08:00
33 changed files with 1678 additions and 1027 deletions
+11
View File
@@ -1,3 +1,14 @@
3.3.4 2016-10-21
- Fix IE dial-up and VPN connection proxy settings
not changed since release 3.3.3.
- Fix a UI bug
3.3.3 2016-10-10
- Add timeout support for server and forward proxy,
only integer is allowed
- Use wininet API to setup system proxy
- Upgrade to .NET Framework 4.6.2
3.3.2 2016-10-03
- Add HTTP forward proxy support
- Bug fixes and improvements
+1 -1
View File
@@ -32,7 +32,7 @@ port in `Servers -> Edit Servers`
1. You can change PAC rules by editing the PAC file. When you save the PAC file
with any editor, Shadowsocks will notify browsers about the change automatically
2. You can also update PAC file from [GFWList] (maintained by 3rd party)
2. You can also update PAC file from [GFWList] \(maintained by 3rd party)
3. You can also use online PAC URL
#### Server Auto Switching
@@ -95,7 +95,6 @@ namespace Shadowsocks.Controller
class TCPHandler
{
class AsyncSession
{
public IProxy Remote { get; }
@@ -121,6 +120,8 @@ namespace Shadowsocks.Controller
}
}
private readonly int _serverTimeout;
private readonly int _proxyTimeout;
// Size of receive buffer.
public static readonly int RecvSize = 8192;
@@ -169,10 +170,12 @@ namespace Shadowsocks.Controller
public TCPHandler(ShadowsocksController controller, Configuration config, TCPRelay tcprelay, Socket socket)
{
this._controller = controller;
this._config = config;
this._tcprelay = tcprelay;
this._connection = socket;
_controller = controller;
_config = config;
_tcprelay = tcprelay;
_connection = socket;
_proxyTimeout = config.proxy.proxyTimeout * 1000;
_serverTimeout = config.GetCurrentServer().timeout * 1000;
lastActivity = DateTime.Now;
}
@@ -442,7 +445,7 @@ namespace Shadowsocks.Controller
var session = new AsyncSession(remote);
_currentRemoteSession = session;
ProxyTimer proxyTimer = new ProxyTimer(3000);
ProxyTimer proxyTimer = new ProxyTimer(_proxyTimeout);
proxyTimer.AutoReset = false;
proxyTimer.Elapsed += proxyConnectTimer_Elapsed;
proxyTimer.Enabled = true;
@@ -515,7 +518,7 @@ namespace Shadowsocks.Controller
}
_startConnectTime = DateTime.Now;
ServerTimer connectTimer = new ServerTimer(3000);
ServerTimer connectTimer = new ServerTimer(_serverTimeout);
connectTimer.AutoReset = false;
connectTimer.Elapsed += destConnectTimer_Elapsed;
connectTimer.Enabled = true;
@@ -23,7 +23,7 @@ namespace Shadowsocks.Controller
public string LatestVersionLocalName;
public event EventHandler CheckUpdateCompleted;
public const string Version = "3.3.2";
public const string Version = "3.3.4";
private class CheckUpdateTimer : System.Timers.Timer
{
@@ -15,7 +15,7 @@ namespace Shadowsocks.Controller
try
{
string path = Application.ExecutablePath;
runKey = Utils.OpenUserRegKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
runKey = Utils.OpenRegKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if ( runKey == null ) {
Logging.Error( @"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Run" );
return false;
@@ -54,7 +54,7 @@ namespace Shadowsocks.Controller
try
{
string path = Application.ExecutablePath;
runKey = Utils.OpenUserRegKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
runKey = Utils.OpenRegKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (runKey == null) {
Logging.Error(@"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Run");
return false;
@@ -1,34 +1,11 @@
using System.Windows.Forms;
using Microsoft.Win32;
using System;
using System.Runtime.InteropServices;
using System.IO;
using System;
using Shadowsocks.Model;
using Shadowsocks.Util;
using Shadowsocks.Util.SystemProxy;
namespace Shadowsocks.Controller
{
public static class SystemProxy
{
[DllImport("wininet.dll")]
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;
public const int INTERNET_OPTION_REFRESH = 37;
static bool _settingsReturn, _refreshReturn;
public static void NotifyIE()
{
// These lines implement the Interface in the beginning of program
// They cause the OS to refresh the settings, causing IP to realy update
_settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
_refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
}
private static readonly DateTime UnixEpoch
= new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long ToUnixEpochMilliseconds(this DateTime dt)
=> (long)(dt - UnixEpoch).TotalMilliseconds;
private static string GetTimestamp(DateTime value)
{
return value.ToString("yyyyMMddHHmmssfff");
@@ -43,139 +20,27 @@ namespace Shadowsocks.Controller
{
enabled = false;
}
RegistryKey registry = null;
try {
registry = Utils.OpenUserRegKey( @"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true );
if ( registry == null ) {
Logging.Error( @"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" );
return;
}
if ( enabled ) {
if ( global ) {
registry.SetValue( "ProxyEnable", 1 );
registry.SetValue( "ProxyServer", "127.0.0.1:" + config.localPort.ToString() );
registry.SetValue( "AutoConfigURL", "" );
} else {
string pacUrl;
if ( config.useOnlinePac && ! config.pacUrl.IsNullOrEmpty() )
pacUrl = config.pacUrl;
else
pacUrl = $"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp( DateTime.Now )}";
registry.SetValue( "ProxyEnable", 0 );
var readProxyServer = registry.GetValue( "ProxyServer" );
registry.SetValue( "ProxyServer", "" );
registry.SetValue( "AutoConfigURL", pacUrl );
}
} else {
registry.SetValue( "ProxyEnable", 0 );
registry.SetValue( "ProxyServer", "" );
registry.SetValue( "AutoConfigURL", "" );
}
//Set AutoDetectProxy
IEAutoDetectProxy( ! enabled );
NotifyIE();
//Must Notify IE first, or the connections do not chanage
CopyProxySettingFromLan();
} catch ( Exception e ) {
Logging.LogUsefulException( e );
// TODO this should be moved into views
MessageBox.Show( I18N.GetString( "Failed to update registry" ) );
} finally {
if ( registry != null ) {
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
}
private static void CopyProxySettingFromLan()
{
RegistryKey registry = null;
try {
registry = Utils.OpenUserRegKey( @"Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", true );
if ( registry == null ) {
Logging.Error( @"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" );
return;
}
var defaultValue = registry.GetValue( "DefaultConnectionSettings" );
var connections = registry.GetValueNames();
foreach ( var each in connections ) {
switch ( each.ToUpperInvariant() ) {
case "DEFAULTCONNECTIONSETTINGS":
case "LAN CONNECTION":
case "SAVEDLEGACYSETTINGS":
continue;
default:
//set all the connections's proxy as the lan
registry.SetValue( each, defaultValue );
continue;
}
}
NotifyIE();
} catch ( IOException e ) {
Logging.LogUsefulException( e );
} finally {
if ( registry != null ) {
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
}
/// <summary>
/// Checks or unchecks the IE Options Connection setting of "Automatically detect Proxy"
/// </summary>
/// <param name="set">Provide 'true' if you want to check the 'Automatically detect Proxy' check box. To uncheck, pass 'false'</param>
private static void IEAutoDetectProxy(bool set)
{
RegistryKey registry = null;
try {
registry = Utils.OpenUserRegKey( @"Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", true );
if ( registry == null ) {
Logging.Error( @"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" );
return;
}
var defConnection = ( byte[] ) registry.GetValue( "DefaultConnectionSettings" );
var savedLegacySetting = ( byte[] ) registry.GetValue( "SavedLegacySettings" );
const int versionOffset = 4;
const int optionsOffset = 8;
if ( set ) {
defConnection[ optionsOffset ] = ( byte ) ( defConnection[ optionsOffset ] | 8 );
savedLegacySetting[ optionsOffset ] = ( byte ) ( savedLegacySetting[ optionsOffset ] | 8 );
} else {
defConnection[ optionsOffset ] = ( byte ) ( defConnection[ optionsOffset ] & ~8 );
savedLegacySetting[ optionsOffset ] = ( byte ) ( savedLegacySetting[ optionsOffset ] & ~8 );
}
BitConverter.GetBytes(unchecked( BitConverter.ToUInt32( defConnection, versionOffset ) + 1 ) )
.CopyTo( defConnection, versionOffset );
BitConverter.GetBytes(unchecked( BitConverter.ToUInt32( savedLegacySetting, versionOffset ) + 1 ) )
.CopyTo( savedLegacySetting, versionOffset );
registry.SetValue( "DefaultConnectionSettings", defConnection );
registry.SetValue( "SavedLegacySettings", savedLegacySetting );
} catch ( Exception e ) {
Logging.LogUsefulException( e );
} finally {
if (registry != null)
if (enabled)
{
if (global)
{
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
WinINet.SetIEProxy(true, true, "127.0.0.1:" + config.localPort.ToString(), "");
}
else
{
string pacUrl;
if (config.useOnlinePac && !config.pacUrl.IsNullOrEmpty())
pacUrl = config.pacUrl;
else
pacUrl = $"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}";
WinINet.SetIEProxy(true, false, "", pacUrl);
}
}
else
{
WinINet.SetIEProxy(false, false, "", "");
}
}
}
}
}
+3
View File
@@ -47,6 +47,7 @@ Password=密码
Encryption=加密
Proxy Port=代理端口
Remarks=备注
Timeout(Sec)=超时(秒)
Onetime Authentication=一次性认证
OK=确定
Cancel=取消
@@ -103,6 +104,7 @@ Reg All=注册全部热键
Shadowsocks Error: {0}=Shadowsocks 错误: {0}
Port already in use=端口已被占用
Illegal port number format=非法端口格式
Illegal timeout format=非法超时格式
Please add at least one server=请添加至少一个服务器
Server IP can not be blank=服务器 IP 不能为空
Password can not be blank=密码不能为空
@@ -132,3 +134,4 @@ Proxy request failed=代理请求失败
Proxy handshake failed=代理握手失败
Register hotkey failed=注册热键失败
Cannot parse hotkey: {0}=解析热键失败: {0}
Timeout is invalid, it should not exceed {0}=超时无效,不应超过 {0}
+3
View File
@@ -47,6 +47,7 @@ Password=密碼
Encryption=加密
Proxy Port=代理連接埠
Remarks=備註
Timeout(Sec)=超時(秒)
Onetime Authentication=單次驗證
OK=確定
Cancel=取消
@@ -103,6 +104,7 @@ Reg All=註冊全部捷徑鍵
Shadowsocks Error: {0}=Shadowsocks 錯誤: {0}
Port already in use=連接埠號碼已被占用
Illegal port number format=非法連接埠號碼格式
Illegal timeout format=非法超時格式
Please add at least one server=請新增至少一個伺服器
Server IP can not be blank=伺服器 IP 不能為空
Password can not be blank=密碼不能為空
@@ -132,3 +134,4 @@ Proxy request failed=代理請求失敗
Proxy handshake failed=代理握手失敗
Register hotkey failed=註冊捷徑鍵失敗
Cannot parse hotkey: {0}=解析捷徑鍵失敗: {0}
Timeout is invalid, it should not exceed {0}=超時無效,不應超過 {0}
+4 -4
View File
@@ -237,10 +237,10 @@ namespace Shadowsocks.Encryption
protected static void randBytes(byte[] buf, int length)
{
byte[] temp = new byte[length];
RNGCryptoServiceProvider rngServiceProvider = new RNGCryptoServiceProvider();
rngServiceProvider.GetBytes(temp);
temp.CopyTo(buf, 0);
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(buf, 0, length);
}
}
public override void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength)
+4 -4
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Caseless StringComparison="Ordinal"/>
<Costura/>
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Caseless StringComparison="Ordinal"/>
<Costura/>
</Weavers>
@@ -44,6 +44,7 @@ namespace Shadowsocks.Model
CheckPort(server.server_port);
CheckPassword(server.password);
CheckServer(server.server);
CheckTimeout(server.timeout, Server.MaxServerTimeoutSec);
}
public static Configuration Load()
@@ -147,5 +148,12 @@ namespace Shadowsocks.Model
if (server.IsNullOrEmpty())
throw new ArgumentException(I18N.GetString("Server IP can not be blank"));
}
public static void CheckTimeout(int timeout, int maxTimeout)
{
if (timeout <= 0 || timeout > maxTimeout)
throw new ArgumentException(string.Format(
I18N.GetString("Timeout is invalid, it should not exceed {0}"), maxTimeout));
}
}
}
+5
View File
@@ -8,10 +8,14 @@ namespace Shadowsocks.Model
public const int PROXY_SOCKS5 = 0;
public const int PROXY_HTTP = 1;
public const int MaxProxyTimeoutSec = 10;
private const int DefaultProxyTimeoutSec = 3;
public bool useProxy;
public int proxyType;
public string proxyServer;
public int proxyPort;
public int proxyTimeout;
public ProxyConfig()
{
@@ -19,6 +23,7 @@ namespace Shadowsocks.Model
proxyType = PROXY_SOCKS5;
proxyServer = "";
proxyPort = 0;
proxyTimeout = DefaultProxyTimeoutSec;
}
}
}
+5
View File
@@ -15,12 +15,16 @@ namespace Shadowsocks.Model
DetailsParser = new Regex("^((?<method>.+?)(?<auth>-auth)??:(?<password>.*)@(?<hostname>.+?)" +
":(?<port>\\d+?))$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private const int DefaultServerTimeoutSec = 5;
public const int MaxServerTimeoutSec = 20;
public string server;
public int server_port;
public string password;
public string method;
public string remarks;
public bool auth;
public int timeout;
public override int GetHashCode()
{
@@ -67,6 +71,7 @@ namespace Shadowsocks.Model
password = "";
remarks = "";
auth = false;
timeout = DefaultServerTimeoutSec;
}
public Server(string ssURL) : this()
+22 -8
View File
@@ -32,14 +32,17 @@ namespace Shadowsocks
}
Utils.ReleaseMemory(true);
using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode()))
using (Mutex mutex = new Mutex(false, $"Global\\Shadowsocks_{Application.StartupPath.GetHashCode()}"))
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// handle UI exceptions
Application.ThreadException += Application_ThreadException;
// handle non-UI exceptions
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ApplicationExit += Application_ApplicationExit;
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += (sender, args) => HotKeys.Destroy();
if (!mutex.WaitOne(0, false))
{
@@ -48,8 +51,9 @@ namespace Shadowsocks
{
Process oldProcess = oldProcesses[0];
}
MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" +
I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.")
+ Environment.NewLine
+ I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
I18N.GetString("Shadowsocks is already running."));
return;
}
@@ -78,14 +82,23 @@ namespace Shadowsocks
if (Interlocked.Increment(ref exited) == 1)
{
Logging.Error(e.ExceptionObject?.ToString());
MessageBox.Show(I18N.GetString("Unexpected error, shadowsocks will exit. Please report to") +
" https://github.com/shadowsocks/shadowsocks-windows/issues " +
Environment.NewLine + (e.ExceptionObject?.ToString()),
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(
$"{I18N.GetString("Unexpected error, shadowsocks will exit. Please report to")} https://github.com/shadowsocks/shadowsocks-windows/issues {Environment.NewLine}{e.ExceptionObject?.ToString()}",
"Shadowsocks non-UI Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
string errorMsg = $"Exception Type: {e.Exception.GetType().Name}{Environment.NewLine}Stack Trace:{Environment.NewLine}{e.Exception.StackTrace}";
Logging.Error(errorMsg);
MessageBox.Show(
$"{I18N.GetString("Unexpected error, shadowsocks will exit. Please report to")} https://github.com/shadowsocks/shadowsocks-windows/issues {Environment.NewLine}{errorMsg}",
"Shadowsocks UI Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
switch (e.Mode)
@@ -136,6 +149,7 @@ namespace Shadowsocks
private static void Application_ApplicationExit(object sender, EventArgs e)
{
HotKeys.Destroy();
if (_controller != null)
{
_controller.Stop();
+79 -59
View File
@@ -1,24 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Shadowsocks.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@@ -31,9 +31,9 @@ namespace Shadowsocks.Properties {
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@@ -45,10 +45,10 @@ namespace Shadowsocks.Properties {
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@@ -59,9 +59,9 @@ namespace Shadowsocks.Properties {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] abp_js {
get {
@@ -69,9 +69,9 @@ namespace Shadowsocks.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized string similar to # translation for Simplified Chinese
/// 查找类似 # translation for Simplified Chinese
///
///Shadowsocks=Shadowsocks
///
@@ -83,7 +83,9 @@ namespace Shadowsocks.Properties {
///Global=全局模式
///Servers=服务器
///Edit Servers...=编辑服务器...
///Statistics Config...=统计配置...
///Start on Boot=开机启动
///Forward Proxy...=正向代理设置...
///Allow Clients from LAN=允许来自局域网的连接
///Local PAC=使用本地 PAC
///Online PAC=使用在线 PAC
@@ -91,30 +93,16 @@ namespace Shadowsocks.Properties {
///Update Local PAC from GFWList=从 GFWList 更新本地 PAC
///Edit User Rule for GFWList...=编辑 GFWList 的用户规则...
///Show QRCode...=显示二维码...
///Scan QRCode from Screen...=扫描屏幕上的二维码...
///Availability Statistic [rest of string was truncated]&quot;;.
///Scan [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string cn {
get {
return ResourceManager.GetString("cn", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to # translation for Traditional Chinese
///
///Shadowsocks=Shadowsocks
///
///# Menu items
/// </summary>
internal static string zh_tw {
get {
return ResourceManager.GetString("zh_tw", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] libsscrypto_dll {
get {
@@ -122,9 +110,9 @@ namespace Shadowsocks.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] mgwz_dll {
get {
@@ -132,22 +120,23 @@ namespace Shadowsocks.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized string similar to listen-address __POLIPO_BIND_IP__:8123
/// 查找类似 listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__
///show-on-task-bar 0
///activity-animation 0
///forward-socks5 / 127.0.0.1:__SOCKS_PORT__ .
///hide-console.
///forward-socks5 / 127.0.0.1:__SOCKS_PORT__ .
///hide-console
/// 的本地化字符串。
/// </summary>
internal static string privoxy_conf {
get {
return ResourceManager.GetString("privoxy_conf", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] privoxy_exe {
get {
@@ -155,9 +144,9 @@ namespace Shadowsocks.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] proxy_pac_txt {
get {
@@ -165,9 +154,9 @@ namespace Shadowsocks.Properties {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss16 {
get {
@@ -175,9 +164,9 @@ namespace Shadowsocks.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss20 {
get {
@@ -185,9 +174,9 @@ namespace Shadowsocks.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss24 {
get {
@@ -197,7 +186,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ssIn24 {
get {
@@ -207,7 +196,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ssOut24 {
get {
@@ -217,7 +206,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ssw128 {
get {
@@ -225,16 +214,47 @@ namespace Shadowsocks.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to ! Put user rules line by line in this file.
/// 查找类似 ! Put user rules line by line in this file.
///! See https://adblockplus.org/en/filter-cheatsheet
///.
/// 的本地化字符串。
/// </summary>
internal static string user_rule {
get {
return ResourceManager.GetString("user_rule", resourceCulture);
}
}
/// <summary>
/// 查找类似 # translation for Traditional Chinese
///
///Shadowsocks=Shadowsocks
///
///# Menu items
///
///Enable System Proxy=啟用系統代理
///Mode=系統代理模式
///PAC=PAC 模式
///Global=全局模式
///Servers=伺服器
///Edit Servers...=編輯伺服器...
///Statistics Config...=統計配置...
///Start on Boot=開機啟動
///Forward Proxy...=正向代理設置...
///Allow Clients from LAN=允許來自區域網路的連接
///Local PAC=使用本地 PAC
///Online PAC=使用在線 PAC
///Edit Local PAC File...=編輯本地 PAC 文件...
///Update Local PAC from GFWList=從 GFWList 更新本地 PAC
///Edit User Rule for GFWList...=編輯 GFWList 的用戶規則...
///Show QRCode...=顯示 QR 碼...
///Scan QRCode from Screen [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string zh_tw {
get {
return ResourceManager.GetString("zh_tw", resourceCulture);
}
}
}
}
+314 -314
View File
@@ -1,314 +1,314 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
#if EXPOSE_EVERYTHING || EXPOSE_STRINGEX
public
#endif
static partial class StringEx
{
#pragma warning disable 1591
public static StringComparison GlobalDefaultComparison { get; set; } = StringComparison.Ordinal;
[ThreadStatic]
private static StringComparison? _DefaultComparison;
public static StringComparison DefaultComparison
{
get { return _DefaultComparison ?? GlobalDefaultComparison; }
set { _DefaultComparison = value; }
}
#region basic String methods
public static bool IsNullOrEmpty(this string value)
=> string.IsNullOrEmpty(value);
public static bool IsNullOrWhiteSpace(this string value)
=> string.IsNullOrWhiteSpace(value);
public static bool IsWhiteSpace(this string value)
{
foreach (var c in value)
{
if (char.IsWhiteSpace(c)) continue;
return false;
}
return true;
}
#if !PCL
public static string IsInterned(this string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
return string.IsInterned(value);
}
public static string Intern(this string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
return string.Intern(value);
}
#endif
#if UNSAFE
public static unsafe string ToLowerForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
value = string.Copy(value);
fixed (char* low = value)
{
var end = low + value.Length;
for (var p = low; p < end; p++)
{
var c = *p;
if (c < 'A' || c > 'Z')
continue;
*p = (char)(c + 0x20);
}
}
return value;
}
public static unsafe string ToUpperForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
value = string.Copy(value);
fixed (char* low = value)
{
var end = low + value.Length;
for (var p = low; p < end; p++)
{
var c = *p;
if (c < 'a' || c > 'z')
continue;
*p = (char)(c - 0x20);
}
}
return value;
}
#else
public static string ToLowerForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
var sb = new StringBuilder(value.Length);
foreach (var c in value)
{
if (c < 'A' || c > 'Z')
sb.Append(c);
else
sb.Append((char)(c + 0x20));
}
return sb.ToString();
}
public static string ToUpperForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
var sb = new StringBuilder(value.Length);
foreach (var c in value)
{
if (c < 'a' || c > 'z')
sb.Append(c);
else
sb.Append((char)(c - 0x20));
}
return sb.ToString();
}
#endif
#endregion
#region comparing
#region Is
public static bool Is(this string a, string b)
=> string.Equals(a, b, DefaultComparison);
public static bool Is(this string a, string b, StringComparison comparisonType)
=> string.Equals(a, b, comparisonType);
#endregion
#region BeginWith
public static bool BeginWith(this string s, char c)
{
if (s.IsNullOrEmpty()) return false;
return s[0] == c;
}
public static bool BeginWithAny(this string s, IEnumerable<char> chars)
{
if (s.IsNullOrEmpty()) return false;
return chars.Contains(s[0]);
}
public static bool BeginWithAny(this string s, params char[] chars)
=> s.BeginWithAny(chars.AsEnumerable());
public static bool BeginWith(this string a, string b)
{
if (a == null || b == null) return false;
return a.StartsWith(b, DefaultComparison);
}
public static bool BeginWith(this string a, string b, StringComparison comparisonType)
{
if (a == null || b == null) return false;
return a.StartsWith(b, comparisonType);
}
#if !PCL
public static bool BeginWith(this string a, string b, bool ignoreCase, CultureInfo culture)
{
if (a == null || b == null) return false;
return a.StartsWith(b, ignoreCase, culture);
}
#endif
#endregion
#region FinishWith
public static bool FinishWith(this string s, char c)
{
if (s.IsNullOrEmpty()) return false;
return s.Last() == c;
}
public static bool FinishWithAny(this string s, IEnumerable<char> chars)
{
if (s.IsNullOrEmpty()) return false;
return chars.Contains(s.Last());
}
public static bool FinishWithAny(this string s, params char[] chars)
=> s.FinishWithAny(chars.AsEnumerable());
public static bool FinishWith(this string a, string b)
{
if (a == null || b == null) return false;
return a.EndsWith(b, DefaultComparison);
}
public static bool FinishWith(this string a, string b, StringComparison comparisonType)
{
if (a == null || b == null) return false;
return a.EndsWith(b, comparisonType);
}
#if !PCL
public static bool FinishWith(this string a, string b, bool ignoreCase, CultureInfo culture)
{
if (a == null || b == null) return false;
return a.EndsWith(b, ignoreCase, culture);
}
#endif
#endregion
#endregion
#region ToLines
public static IEnumerable<string> ToLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
yield return line;
}
public static IEnumerable<string> NonEmptyLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line == "") continue;
yield return line;
}
}
public static IEnumerable<string> NonWhiteSpaceLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.IsWhiteSpace()) continue;
yield return line;
}
}
#endregion
#region others
private static readonly char[][] Quotes = new[]
{
"\"\"",
"''",
"“”",
"‘’",
"『』",
"「」",
"〖〗",
"【】",
}.Select(s => s.ToCharArray()).ToArray();
public static string Enquote(this string value)
{
if (value == null)
return "(null)";
foreach (var pair in Quotes)
{
if (value.IndexOfAny(pair) < 0)
return pair[0] + value + pair[1];
}
return '"' + value.Replace("\\", @"\\").Replace("\"", @"\""") + '"';
}
public static string Replace(this string value, string find, string rep, StringComparison comparsionType)
{
if (find.IsNullOrEmpty())
throw new ArgumentException(null, nameof(find));
if (rep == null)
rep = "";
if (value.IsNullOrEmpty())
return value;
var sb = new StringBuilder(value.Length);
var last = 0;
var len = find.Length;
var idx = value.IndexOf(find, DefaultComparison);
while (idx != -1)
{
sb.Append(value.Substring(last, idx - last));
sb.Append(rep);
idx += len;
last = idx;
idx = value.IndexOf(find, idx, comparsionType);
}
sb.Append(value.Substring(last));
return sb.ToString();
}
public static string ReplaceEx(this string value, string find, string rep)
=> value.Replace(find, rep, DefaultComparison);
#endregion
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
#if EXPOSE_EVERYTHING || EXPOSE_STRINGEX
public
#endif
static partial class StringEx
{
#pragma warning disable 1591
public static StringComparison GlobalDefaultComparison { get; set; } = StringComparison.Ordinal;
[ThreadStatic]
private static StringComparison? _DefaultComparison;
public static StringComparison DefaultComparison
{
get { return _DefaultComparison ?? GlobalDefaultComparison; }
set { _DefaultComparison = value; }
}
#region basic String methods
public static bool IsNullOrEmpty(this string value)
=> string.IsNullOrEmpty(value);
public static bool IsNullOrWhiteSpace(this string value)
=> string.IsNullOrWhiteSpace(value);
public static bool IsWhiteSpace(this string value)
{
foreach (var c in value)
{
if (char.IsWhiteSpace(c)) continue;
return false;
}
return true;
}
#if !PCL
public static string IsInterned(this string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
return string.IsInterned(value);
}
public static string Intern(this string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
return string.Intern(value);
}
#endif
#if UNSAFE
public static unsafe string ToLowerForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
value = string.Copy(value);
fixed (char* low = value)
{
var end = low + value.Length;
for (var p = low; p < end; p++)
{
var c = *p;
if (c < 'A' || c > 'Z')
continue;
*p = (char)(c + 0x20);
}
}
return value;
}
public static unsafe string ToUpperForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
value = string.Copy(value);
fixed (char* low = value)
{
var end = low + value.Length;
for (var p = low; p < end; p++)
{
var c = *p;
if (c < 'a' || c > 'z')
continue;
*p = (char)(c - 0x20);
}
}
return value;
}
#else
public static string ToLowerForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
var sb = new StringBuilder(value.Length);
foreach (var c in value)
{
if (c < 'A' || c > 'Z')
sb.Append(c);
else
sb.Append((char)(c + 0x20));
}
return sb.ToString();
}
public static string ToUpperForASCII(this string value)
{
if (value.IsNullOrWhiteSpace())
return value;
var sb = new StringBuilder(value.Length);
foreach (var c in value)
{
if (c < 'a' || c > 'z')
sb.Append(c);
else
sb.Append((char)(c - 0x20));
}
return sb.ToString();
}
#endif
#endregion
#region comparing
#region Is
public static bool Is(this string a, string b)
=> string.Equals(a, b, DefaultComparison);
public static bool Is(this string a, string b, StringComparison comparisonType)
=> string.Equals(a, b, comparisonType);
#endregion
#region BeginWith
public static bool BeginWith(this string s, char c)
{
if (s.IsNullOrEmpty()) return false;
return s[0] == c;
}
public static bool BeginWithAny(this string s, IEnumerable<char> chars)
{
if (s.IsNullOrEmpty()) return false;
return chars.Contains(s[0]);
}
public static bool BeginWithAny(this string s, params char[] chars)
=> s.BeginWithAny(chars.AsEnumerable());
public static bool BeginWith(this string a, string b)
{
if (a == null || b == null) return false;
return a.StartsWith(b, DefaultComparison);
}
public static bool BeginWith(this string a, string b, StringComparison comparisonType)
{
if (a == null || b == null) return false;
return a.StartsWith(b, comparisonType);
}
#if !PCL
public static bool BeginWith(this string a, string b, bool ignoreCase, CultureInfo culture)
{
if (a == null || b == null) return false;
return a.StartsWith(b, ignoreCase, culture);
}
#endif
#endregion
#region FinishWith
public static bool FinishWith(this string s, char c)
{
if (s.IsNullOrEmpty()) return false;
return s.Last() == c;
}
public static bool FinishWithAny(this string s, IEnumerable<char> chars)
{
if (s.IsNullOrEmpty()) return false;
return chars.Contains(s.Last());
}
public static bool FinishWithAny(this string s, params char[] chars)
=> s.FinishWithAny(chars.AsEnumerable());
public static bool FinishWith(this string a, string b)
{
if (a == null || b == null) return false;
return a.EndsWith(b, DefaultComparison);
}
public static bool FinishWith(this string a, string b, StringComparison comparisonType)
{
if (a == null || b == null) return false;
return a.EndsWith(b, comparisonType);
}
#if !PCL
public static bool FinishWith(this string a, string b, bool ignoreCase, CultureInfo culture)
{
if (a == null || b == null) return false;
return a.EndsWith(b, ignoreCase, culture);
}
#endif
#endregion
#endregion
#region ToLines
public static IEnumerable<string> ToLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
yield return line;
}
public static IEnumerable<string> NonEmptyLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line == "") continue;
yield return line;
}
}
public static IEnumerable<string> NonWhiteSpaceLines(this TextReader reader)
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.IsWhiteSpace()) continue;
yield return line;
}
}
#endregion
#region others
private static readonly char[][] Quotes = new[]
{
"\"\"",
"''",
"“”",
"‘’",
"『』",
"「」",
"〖〗",
"【】",
}.Select(s => s.ToCharArray()).ToArray();
public static string Enquote(this string value)
{
if (value == null)
return "(null)";
foreach (var pair in Quotes)
{
if (value.IndexOfAny(pair) < 0)
return pair[0] + value + pair[1];
}
return '"' + value.Replace("\\", @"\\").Replace("\"", @"\""") + '"';
}
public static string Replace(this string value, string find, string rep, StringComparison comparsionType)
{
if (find.IsNullOrEmpty())
throw new ArgumentException(null, nameof(find));
if (rep == null)
rep = "";
if (value.IsNullOrEmpty())
return value;
var sb = new StringBuilder(value.Length);
var last = 0;
var len = find.Length;
var idx = value.IndexOf(find, DefaultComparison);
while (idx != -1)
{
sb.Append(value.Substring(last, idx - last));
sb.Append(rep);
idx += len;
last = idx;
idx = value.IndexOf(find, idx, comparsionType);
}
sb.Append(value.Substring(last));
return sb.ToString();
}
public static string ReplaceEx(this string value, string find, string rep)
=> value.Replace(find, rep, DefaultComparison);
#endregion
}
@@ -11,21 +11,7 @@ namespace Shadowsocks.Util.ProcessManagement
*/
public class Job : IDisposable
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr CreateJobObject(IntPtr a, string lpName);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoType infoType, IntPtr lpJobObjectInfo, UInt32 cbJobObjectInfoLength);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(IntPtr hObject);
private IntPtr handle = IntPtr.Zero;
private bool disposed;
public Job()
{
@@ -62,36 +48,6 @@ namespace Shadowsocks.Util.ProcessManagement
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (disposed) return;
disposed = true;
if (disposing) { }
Close();
}
private void Close()
{
if (handle != IntPtr.Zero)
{
CloseHandle(handle);
handle = IntPtr.Zero;
}
}
~Job()
{
Dispose(false);
}
public bool AddProcess(IntPtr processHandle)
{
var succ = AssignProcessToJobObject(handle, processHandle);
@@ -109,6 +65,56 @@ namespace Shadowsocks.Util.ProcessManagement
return AddProcess(Process.GetProcessById(processId).Handle);
}
#region IDisposable
private bool disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposed) return;
disposed = true;
if (disposing)
{
// no managed objects to free
}
if (handle != IntPtr.Zero)
{
CloseHandle(handle);
handle = IntPtr.Zero;
}
}
~Job()
{
Dispose(false);
}
#endregion
#region Interop
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr CreateJobObject(IntPtr a, string lpName);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoType infoType, IntPtr lpJobObjectInfo, UInt32 cbJobObjectInfoLength);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(IntPtr hObject);
#endregion
}
#region Helper classes
@@ -0,0 +1,42 @@
/****************************** Module Header ******************************\
Module Name: INTERNET_OPTION.cs
Project: CSWebBrowserWithProxy
Copyright (c) Microsoft Corporation.
This enum contains 4 WinINet constants used in method InternetQueryOption and
InternetSetOption functions.
Visit http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx to get the
whole constants list.
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
namespace Shadowsocks.Util.SystemProxy
{
public enum INTERNET_OPTION
{
// Sets or retrieves an INTERNET_PER_CONN_OPTION_LIST structure that specifies
// a list of options for a particular connection.
INTERNET_OPTION_PER_CONNECTION_OPTION = 75,
// Notify the system that the registry settings have been changed so that
// it verifies the settings on the next call to InternetConnect.
INTERNET_OPTION_SETTINGS_CHANGED = 39,
// Causes the proxy data to be reread from the registry for a handle.
INTERNET_OPTION_REFRESH = 37,
// Alerts the current WinInet instance that proxy settings have changed
// and that they must update with the new settings.
// To alert all available WinInet instances, set the Buffer parameter of
// InternetSetOption to NULL and BufferLength to 0 when passing this option.
INTERNET_OPTION_PROXY_SETTINGS_CHANGED = 95
}
}
@@ -0,0 +1,115 @@
/****************************** Module Header ******************************\
Module Name: INTERNET_PER_CONN_OPTION.cs
Project: CSWebBrowserWithProxy
Copyright (c) Microsoft Corporation.
This file defines the struct INTERNET_PER_CONN_OPTION and constants used by it.
The struct INTERNET_PER_CONN_OPTION contains the value of an option that to be
set to internet settings.
Visit http://msdn.microsoft.com/en-us/library/aa385145(VS.85).aspx to get the
detailed description.
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
/// <summary>
/// Constants used in INTERNET_PER_CONN_OPTION_OptionUnion struct.
/// </summary>
public enum INTERNET_PER_CONN_OptionEnum
{
INTERNET_PER_CONN_FLAGS = 1,
INTERNET_PER_CONN_PROXY_SERVER = 2,
INTERNET_PER_CONN_PROXY_BYPASS = 3,
INTERNET_PER_CONN_AUTOCONFIG_URL = 4,
INTERNET_PER_CONN_AUTODISCOVERY_FLAGS = 5,
INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL = 6,
INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS = 7,
INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME = 8,
INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL = 9,
INTERNET_PER_CONN_FLAGS_UI = 10
}
/// <summary>
/// Constants used in INTERNET_PER_CONN_OPTON struct.
/// </summary>
[Flags]
public enum INTERNET_OPTION_PER_CONN_FLAGS
{
PROXY_TYPE_DIRECT = 0x00000001, // direct to net
PROXY_TYPE_PROXY = 0x00000002, // via named proxy
PROXY_TYPE_AUTO_PROXY_URL = 0x00000004, // autoproxy URL
PROXY_TYPE_AUTO_DETECT = 0x00000008 // use autoproxy detection
}
/// <summary>
/// Constants used in INTERNET_PER_CONN_OPTON struct.
/// Windows 7 and later:
/// Clients that support Internet Explorer 8 should query the connection type using INTERNET_PER_CONN_FLAGS_UI.
/// If this query fails, then the system is running a previous version of Internet Explorer and the client should
/// query again with INTERNET_PER_CONN_FLAGS.
/// Restore the connection type using INTERNET_PER_CONN_FLAGS regardless of the version of Internet Explorer.
/// XXX: If fails, notify user to upgrade Internet Explorer
/// </summary>
[Flags]
public enum INTERNET_OPTION_PER_CONN_FLAGS_UI
{
PROXY_TYPE_DIRECT = 0x00000001, // direct to net
PROXY_TYPE_PROXY = 0x00000002, // via named proxy
PROXY_TYPE_AUTO_PROXY_URL = 0x00000004, // autoproxy URL
PROXY_TYPE_AUTO_DETECT = 0x00000008 // use autoproxy detection
}
/// <summary>
/// Used in INTERNET_PER_CONN_OPTION.
/// When create a instance of OptionUnion, only one filed will be used.
/// The StructLayout and FieldOffset attributes could help to decrease the struct size.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct INTERNET_PER_CONN_OPTION_OptionUnion : IDisposable
{
// A value in INTERNET_OPTION_PER_CONN_FLAGS.
[FieldOffset(0)]
public int dwValue;
[FieldOffset(0)]
public System.IntPtr pszValue;
[FieldOffset(0)]
public System.Runtime.InteropServices.ComTypes.FILETIME ftValue;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (disposing)
{
if (pszValue != IntPtr.Zero)
{
Marshal.FreeHGlobal(pszValue);
pszValue = IntPtr.Zero;
}
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct INTERNET_PER_CONN_OPTION
{
// A value in INTERNET_PER_CONN_OptionEnum.
public int dwOption;
public INTERNET_PER_CONN_OPTION_OptionUnion Value;
}
}
@@ -0,0 +1,63 @@
/****************************** Module Header ******************************\
Module Name: INTERNET_PER_CONN_OPTION_LIST.cs
Project: CSWebBrowserWithProxy
Copyright (c) Microsoft Corporation.
The struct INTERNET_PER_CONN_OPTION contains a list of options that to be
set to internet connection.
Visit http://msdn.microsoft.com/en-us/library/aa385146(VS.85).aspx to get the
detailed description.
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct INTERNET_PER_CONN_OPTION_LIST : IDisposable
{
public int Size;
// The connection to be set. NULL means LAN.
public System.IntPtr Connection;
public int OptionCount;
public int OptionError;
// List of INTERNET_PER_CONN_OPTIONs.
public System.IntPtr pOptions;
public void Dispose()
{
Dispose( true );
GC.SuppressFinalize( this );
}
private void Dispose( bool disposing )
{
if ( disposing )
{
if ( Connection != IntPtr.Zero )
{
Marshal.FreeHGlobal( Connection );
Connection = IntPtr.Zero;
}
if ( pOptions != IntPtr.Zero )
{
Marshal.FreeHGlobal( pOptions );
pOptions = IntPtr.Zero;
}
}
}
}
}
@@ -0,0 +1,36 @@
/****************************** Module Header ******************************\
Module Name: NativeMethods.cs
Project: CSWebBrowserWithProxy
Copyright (c) Microsoft Corporation.
This class is a simple .NET wrapper of wininet.dll. It contains 4 extern
methods in wininet.dll. They are InternetOpen, InternetCloseHandle,
InternetSetOption and InternetQueryOption.
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
internal static class NativeMethods
{
/// <summary>
/// Sets an Internet option.
/// </summary>
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool InternetSetOption(
IntPtr hInternet,
INTERNET_OPTION dwOption,
IntPtr lpBuffer,
int lpdwBufferLength);
}
}
+147
View File
@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Shadowsocks.Util.SystemProxy
{
public static class RAS
{
private enum RasFieldSizeConstants
{
#region original header
//#if (WINVER >= 0x400)
//#define RAS_MaxEntryName 256
//#define RAS_MaxDeviceName 128
//#define RAS_MaxCallbackNumber RAS_MaxPhoneNumber
//#else
//#define RAS_MaxEntryName 20
//#define RAS_MaxDeviceName 32
//#define RAS_MaxCallbackNumber 48
//#endif
#endregion
RAS_MaxEntryName = 256,
RAS_MaxPath = 260
}
private const int ERROR_SUCCESS = 0;
private const int RASBASE = 600;
private const int ERROR_BUFFER_TOO_SMALL = RASBASE + 3;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct RasEntryName
{
#region original header
//#define RASENTRYNAMEW struct tagRASENTRYNAMEW
//RASENTRYNAMEW
//{
// DWORD dwSize;
// WCHAR szEntryName[RAS_MaxEntryName + 1];
//
//#if (WINVER >= 0x500)
// //
// // If this flag is REN_AllUsers then its a
// // system phonebook.
// //
// DWORD dwFlags;
// WCHAR szPhonebookPath[MAX_PATH + 1];
//#endif
//};
//
//#define RASENTRYNAMEA struct tagRASENTRYNAMEA
//RASENTRYNAMEA
//{
// DWORD dwSize;
// CHAR szEntryName[RAS_MaxEntryName + 1];
//
//#if (WINVER >= 0x500)
// DWORD dwFlags;
// CHAR szPhonebookPath[MAX_PATH + 1];
//#endif
//};
#endregion
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=(int)RasFieldSizeConstants.RAS_MaxEntryName + 1)]
public string szEntryName;
public int dwFlags;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_MaxPath + 1)]
public string szPhonebookPath;
}
[DllImport("rasapi32.dll", CharSet = CharSet.Auto)]
private static extern uint RasEnumEntries(
string reserved, // reserved, must be NULL
string lpszPhonebook, // pointer to full path and file name of phone-book file
[In, Out] RasEntryName[] lprasentryname, // buffer to receive phone-book entries
ref int lpcb, // size in bytes of buffer
out int lpcEntries // number of entries written to buffer
);
/// <summary>
/// Get all entries from RAS
/// </summary>
/// <param name="allConns"></param>
/// <returns>
/// 0: success with entries
/// 1: success but no entries found
/// 2: failed
/// </returns>
public static uint GetAllConns(ref string[] allConns)
{
int lpNames = 0;
int entryNameSize = 0;
int lpSize = 0;
uint retval = ERROR_SUCCESS;
RasEntryName[] names = null;
entryNameSize = Marshal.SizeOf(typeof(RasEntryName));
// Windows Vista or later: To determine the required buffer size, call RasEnumEntries
// with lprasentryname set to NULL. The variable pointed to by lpcb should be set to zero.
// The function will return the required buffer size in lpcb and an error code of ERROR_BUFFER_TOO_SMALL.
retval = RasEnumEntries(null, null, null, ref lpSize, out lpNames);
if (retval == ERROR_BUFFER_TOO_SMALL)
{
names = new RasEntryName[lpNames];
for (int i = 0; i < names.Length; i++)
{
names[i].dwSize = entryNameSize;
}
retval = RasEnumEntries(null, null, names, ref lpSize, out lpNames);
}
if (retval == ERROR_SUCCESS)
{
if (lpNames == 0)
{
// no entries found.
return 1;
}
allConns = new string[names.Length];
for (int i = 0; i < names.Length; i++)
{
allConns[i] = names[i].szEntryName;
}
return 0;
}
else
{
return 2;
}
}
}
}
@@ -0,0 +1,191 @@
/****************************** Module Header ******************************\
Module Name: WinINet.cs
Project: CSWebBrowserWithProxy
Copyright (c) Microsoft Corporation.
This class is used to set the proxy. or restore to the system proxy for the
current application
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Shadowsocks.Controller;
namespace Shadowsocks.Util.SystemProxy
{
public static class WinINet
{
/// <summary>
/// Set IE settings.
/// </summary>
private static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL, string connName)
{
List<INTERNET_PER_CONN_OPTION> _optionlist = new List<INTERNET_PER_CONN_OPTION>();
if (enable)
{
if (global)
{
// global proxy
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_FLAGS_UI,
Value = { dwValue = (int)(INTERNET_OPTION_PER_CONN_FLAGS_UI.PROXY_TYPE_PROXY
| INTERNET_OPTION_PER_CONN_FLAGS_UI.PROXY_TYPE_DIRECT) }
});
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_PROXY_SERVER,
Value = { pszValue = Marshal.StringToHGlobalAuto(proxyServer) }
});
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_PROXY_BYPASS,
Value = { pszValue = Marshal.StringToHGlobalAuto("<local>") }
});
}
else
{
// pac
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_FLAGS_UI,
Value = { dwValue = (int)INTERNET_OPTION_PER_CONN_FLAGS_UI.PROXY_TYPE_AUTO_PROXY_URL }
});
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_AUTOCONFIG_URL,
Value = { pszValue = Marshal.StringToHGlobalAuto(pacURL) }
});
}
}
else
{
// direct
_optionlist.Add(new INTERNET_PER_CONN_OPTION
{
dwOption = (int)INTERNET_PER_CONN_OptionEnum.INTERNET_PER_CONN_FLAGS_UI,
Value = { dwValue = (int)(INTERNET_OPTION_PER_CONN_FLAGS_UI.PROXY_TYPE_AUTO_DETECT
| INTERNET_OPTION_PER_CONN_FLAGS_UI.PROXY_TYPE_DIRECT) }
});
}
// Get total length of INTERNET_PER_CONN_OPTIONs
var len = _optionlist.Sum(each => Marshal.SizeOf(each));
// Allocate a block of memory of the options.
IntPtr buffer = Marshal.AllocCoTaskMem(len);
IntPtr current = buffer;
// Marshal data from a managed object to an unmanaged block of memory.
foreach (INTERNET_PER_CONN_OPTION eachOption in _optionlist)
{
Marshal.StructureToPtr(eachOption, current, false);
current = (IntPtr)((int)current + Marshal.SizeOf(eachOption));
}
// Initialize a INTERNET_PER_CONN_OPTION_LIST instance.
INTERNET_PER_CONN_OPTION_LIST optionList = new INTERNET_PER_CONN_OPTION_LIST();
// Point to the allocated memory.
optionList.pOptions = buffer;
// Return the unmanaged size of an object in bytes.
optionList.Size = Marshal.SizeOf(optionList);
optionList.Connection = connName.IsNullOrEmpty()
? IntPtr.Zero // NULL means LAN
: Marshal.StringToHGlobalAuto(connName); // TODO: not working if contains Chinese
optionList.OptionCount = _optionlist.Count;
optionList.OptionError = 0;
int optionListSize = Marshal.SizeOf(optionList);
// Allocate memory for the INTERNET_PER_CONN_OPTION_LIST instance.
IntPtr intptrStruct = Marshal.AllocCoTaskMem(optionListSize);
// Marshal data from a managed object to an unmanaged block of memory.
Marshal.StructureToPtr(optionList, intptrStruct, true);
// Set internet settings.
bool bReturn = NativeMethods.InternetSetOption(
IntPtr.Zero,
INTERNET_OPTION.INTERNET_OPTION_PER_CONNECTION_OPTION,
intptrStruct, optionListSize);
// Free the allocated memory.
Marshal.FreeCoTaskMem(buffer);
Marshal.FreeCoTaskMem(intptrStruct);
// Throw an exception if this operation failed.
if (!bReturn)
{
throw new Exception("InternetSetOption: " + Marshal.GetLastWin32Error());
}
// Notify the system that the registry settings have been changed and cause
// the proxy data to be reread from the registry for a handle.
// bReturn = NativeMethods.InternetSetOption(
// IntPtr.Zero,
// INTERNET_OPTION.INTERNET_OPTION_SETTINGS_CHANGED,
// IntPtr.Zero, 0);
// if ( ! bReturn )
// {
// Logging.Error("InternetSetOption:INTERNET_OPTION_SETTINGS_CHANGED");
// }
bReturn = NativeMethods.InternetSetOption(
IntPtr.Zero,
INTERNET_OPTION.INTERNET_OPTION_PROXY_SETTINGS_CHANGED,
IntPtr.Zero, 0);
if (!bReturn)
{
Logging.Error("InternetSetOption:INTERNET_OPTION_PROXY_SETTINGS_CHANGED");
}
bReturn = NativeMethods.InternetSetOption(
IntPtr.Zero,
INTERNET_OPTION.INTERNET_OPTION_REFRESH,
IntPtr.Zero, 0);
if (!bReturn)
{
Logging.Error("InternetSetOption:INTERNET_OPTION_REFRESH");
}
}
public static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL)
{
string[] allConnections = null;
var ret = RAS.GetAllConns(ref allConnections);
if (ret == 2)
throw new Exception("Cannot get all connections");
if (ret == 1)
{
// no entries, only set LAN
SetIEProxy(enable, global, proxyServer, pacURL, null);
}
else if (ret == 0)
{
// found entries, set LAN and each connection
SetIEProxy(enable, global, proxyServer, pacURL, null);
foreach (string connName in allConnections)
{
SetIEProxy(enable, global, proxyServer, pacURL, connName);
}
}
}
}
}
+26 -5
View File
@@ -5,6 +5,7 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows.Forms;
using Microsoft.Win32;
using Shadowsocks.Controller;
@@ -210,14 +211,34 @@ namespace Shadowsocks.Util
return new BandwidthScaleInfo(f, unit, scale);
}
public static RegistryKey OpenUserRegKey( string name, bool writable ) {
public static RegistryKey OpenRegKey( string name, bool writable, RegistryHive hive = RegistryHive.CurrentUser )
{
// we are building x86 binary for both x86 and x64, which will
// cause problem when opening registry key
// detect operating system instead of CPU
RegistryKey userKey = RegistryKey.OpenRemoteBaseKey( RegistryHive.CurrentUser, "",
Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32 )
.OpenSubKey( name, writable );
return userKey;
if (name.IsNullOrEmpty()) throw new ArgumentException(nameof(name));
try
{
RegistryKey userKey = RegistryKey.OpenBaseKey(hive,
Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32)
.OpenSubKey(name, writable);
return userKey;
}
catch (UnauthorizedAccessException uae)
{
Logging.LogUsefulException(uae);
return null;
}
catch (SecurityException se)
{
Logging.LogUsefulException(se);
return null;
}
catch (ArgumentException ae)
{
MessageBox.Show("OpenRegKey: " + ae.ToString());
return null;
}
}
public static bool IsWinVistaOrHigher() {
+51 -24
View File
@@ -57,6 +57,8 @@
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.DuplicateButton = new System.Windows.Forms.Button();
this.TimeoutLabel = new System.Windows.Forms.Label();
this.TimeoutTextBox = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1.SuspendLayout();
this.ServerGroupBox.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
@@ -83,12 +85,14 @@
this.tableLayoutPanel1.Controls.Add(this.PasswordTextBox, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.EncryptionLabel, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.EncryptionSelect, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.OneTimeAuth, 1, 6);
this.tableLayoutPanel1.Controls.Add(this.OneTimeAuth, 1, 7);
this.tableLayoutPanel1.Controls.Add(this.TimeoutLabel, 0, 6);
this.tableLayoutPanel1.Controls.Add(this.TimeoutTextBox, 1, 6);
this.tableLayoutPanel1.Location = new System.Drawing.Point(8, 21);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 7;
this.tableLayoutPanel1.RowCount = 8;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
@@ -96,13 +100,14 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(249, 162);
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(255, 189);
this.tableLayoutPanel1.TabIndex = 0;
//
// RemarksTextBox
//
this.RemarksTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.RemarksTextBox.Location = new System.Drawing.Point(83, 113);
this.RemarksTextBox.Location = new System.Drawing.Point(89, 113);
this.RemarksTextBox.MaxLength = 32;
this.RemarksTextBox.Name = "RemarksTextBox";
this.RemarksTextBox.Size = new System.Drawing.Size(160, 21);
@@ -113,7 +118,7 @@
//
this.RemarksLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.RemarksLabel.AutoSize = true;
this.RemarksLabel.Location = new System.Drawing.Point(30, 117);
this.RemarksLabel.Location = new System.Drawing.Point(36, 117);
this.RemarksLabel.Name = "RemarksLabel";
this.RemarksLabel.Size = new System.Drawing.Size(47, 12);
this.RemarksLabel.TabIndex = 9;
@@ -123,7 +128,7 @@
//
this.IPLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.IPLabel.AutoSize = true;
this.IPLabel.Location = new System.Drawing.Point(18, 10);
this.IPLabel.Location = new System.Drawing.Point(24, 10);
this.IPLabel.Name = "IPLabel";
this.IPLabel.Size = new System.Drawing.Size(59, 12);
this.IPLabel.TabIndex = 0;
@@ -133,7 +138,7 @@
//
this.ServerPortLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.ServerPortLabel.AutoSize = true;
this.ServerPortLabel.Location = new System.Drawing.Point(6, 37);
this.ServerPortLabel.Location = new System.Drawing.Point(12, 37);
this.ServerPortLabel.Name = "ServerPortLabel";
this.ServerPortLabel.Size = new System.Drawing.Size(71, 12);
this.ServerPortLabel.TabIndex = 1;
@@ -143,7 +148,7 @@
//
this.PasswordLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.PasswordLabel.AutoSize = true;
this.PasswordLabel.Location = new System.Drawing.Point(24, 64);
this.PasswordLabel.Location = new System.Drawing.Point(30, 64);
this.PasswordLabel.Name = "PasswordLabel";
this.PasswordLabel.Size = new System.Drawing.Size(53, 12);
this.PasswordLabel.TabIndex = 2;
@@ -152,7 +157,7 @@
// IPTextBox
//
this.IPTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.IPTextBox.Location = new System.Drawing.Point(83, 6);
this.IPTextBox.Location = new System.Drawing.Point(89, 6);
this.IPTextBox.MaxLength = 512;
this.IPTextBox.Name = "IPTextBox";
this.IPTextBox.Size = new System.Drawing.Size(160, 21);
@@ -162,7 +167,7 @@
// ServerPortTextBox
//
this.ServerPortTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ServerPortTextBox.Location = new System.Drawing.Point(83, 33);
this.ServerPortTextBox.Location = new System.Drawing.Point(89, 33);
this.ServerPortTextBox.MaxLength = 10;
this.ServerPortTextBox.Name = "ServerPortTextBox";
this.ServerPortTextBox.Size = new System.Drawing.Size(160, 21);
@@ -172,7 +177,7 @@
// PasswordTextBox
//
this.PasswordTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.PasswordTextBox.Location = new System.Drawing.Point(83, 60);
this.PasswordTextBox.Location = new System.Drawing.Point(89, 60);
this.PasswordTextBox.MaxLength = 256;
this.PasswordTextBox.Name = "PasswordTextBox";
this.PasswordTextBox.Size = new System.Drawing.Size(160, 21);
@@ -184,7 +189,7 @@
//
this.EncryptionLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.EncryptionLabel.AutoSize = true;
this.EncryptionLabel.Location = new System.Drawing.Point(12, 91);
this.EncryptionLabel.Location = new System.Drawing.Point(18, 91);
this.EncryptionLabel.Name = "EncryptionLabel";
this.EncryptionLabel.Size = new System.Drawing.Size(65, 12);
this.EncryptionLabel.TabIndex = 8;
@@ -213,7 +218,7 @@
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb"});
this.EncryptionSelect.Location = new System.Drawing.Point(83, 87);
this.EncryptionSelect.Location = new System.Drawing.Point(89, 87);
this.EncryptionSelect.Name = "EncryptionSelect";
this.EncryptionSelect.Size = new System.Drawing.Size(160, 20);
this.EncryptionSelect.TabIndex = 3;
@@ -221,7 +226,7 @@
// OneTimeAuth
//
this.OneTimeAuth.AutoSize = true;
this.OneTimeAuth.Location = new System.Drawing.Point(83, 140);
this.OneTimeAuth.Location = new System.Drawing.Point(89, 167);
this.OneTimeAuth.Name = "OneTimeAuth";
this.OneTimeAuth.Size = new System.Drawing.Size(156, 16);
this.OneTimeAuth.TabIndex = 5;
@@ -296,7 +301,7 @@
this.ServerGroupBox.Location = new System.Drawing.Point(178, 0);
this.ServerGroupBox.Margin = new System.Windows.Forms.Padding(12, 0, 0, 0);
this.ServerGroupBox.Name = "ServerGroupBox";
this.ServerGroupBox.Size = new System.Drawing.Size(260, 200);
this.ServerGroupBox.Size = new System.Drawing.Size(266, 227);
this.ServerGroupBox.TabIndex = 0;
this.ServerGroupBox.TabStop = false;
this.ServerGroupBox.Text = "Server";
@@ -333,7 +338,7 @@
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.Size = new System.Drawing.Size(438, 296);
this.tableLayoutPanel2.Size = new System.Drawing.Size(444, 323);
this.tableLayoutPanel2.TabIndex = 7;
//
// tableLayoutPanel6
@@ -346,7 +351,7 @@
this.tableLayoutPanel6.Controls.Add(this.MoveDownButton, 1, 0);
this.tableLayoutPanel6.Controls.Add(this.MoveUpButton, 0, 0);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Top;
this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 264);
this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 291);
this.tableLayoutPanel6.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 1;
@@ -389,16 +394,16 @@
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel5.Controls.Add(this.ProxyPortTextBox, 1, 0);
this.tableLayoutPanel5.Controls.Add(this.ProxyPortLabel, 0, 0);
this.tableLayoutPanel5.Location = new System.Drawing.Point(242, 200);
this.tableLayoutPanel5.Location = new System.Drawing.Point(248, 227);
this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel5.RowCount = 1;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(196, 64);
this.tableLayoutPanel5.TabIndex = 9;
//
@@ -433,7 +438,7 @@
this.tableLayoutPanel3.Controls.Add(this.MyCancelButton, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.OKButton, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Right;
this.tableLayoutPanel3.Location = new System.Drawing.Point(279, 267);
this.tableLayoutPanel3.Location = new System.Drawing.Point(285, 294);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
@@ -452,7 +457,7 @@
this.tableLayoutPanel4.Controls.Add(this.DeleteButton, 1, 0);
this.tableLayoutPanel4.Controls.Add(this.AddButton, 0, 0);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Top;
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 200);
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 227);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 2;
@@ -473,6 +478,26 @@
this.DuplicateButton.UseVisualStyleBackColor = true;
this.DuplicateButton.Click += new System.EventHandler(this.DuplicateButton_Click);
//
// TimeoutLabel
//
this.TimeoutLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.TimeoutLabel.AutoSize = true;
this.TimeoutLabel.Location = new System.Drawing.Point(6, 144);
this.TimeoutLabel.Name = "TimeoutLabel";
this.TimeoutLabel.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.TimeoutLabel.Size = new System.Drawing.Size(77, 12);
this.TimeoutLabel.TabIndex = 10;
this.TimeoutLabel.Text = "Timeout(Sec)";
//
// TimeoutTextBox
//
this.TimeoutTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.TimeoutTextBox.Location = new System.Drawing.Point(89, 140);
this.TimeoutTextBox.MaxLength = 5;
this.TimeoutTextBox.Name = "TimeoutTextBox";
this.TimeoutTextBox.Size = new System.Drawing.Size(160, 21);
this.TimeoutTextBox.TabIndex = 11;
//
// ConfigForm
//
this.AcceptButton = this.OKButton;
@@ -542,6 +567,8 @@
private System.Windows.Forms.Button MoveUpButton;
private System.Windows.Forms.CheckBox OneTimeAuth;
private System.Windows.Forms.Button DuplicateButton;
private System.Windows.Forms.Label TimeoutLabel;
private System.Windows.Forms.TextBox TimeoutTextBox;
}
}
+28 -13
View File
@@ -49,6 +49,7 @@ namespace Shadowsocks.View
EncryptionLabel.Text = I18N.GetString("Encryption");
ProxyPortLabel.Text = I18N.GetString("Proxy Port");
RemarksLabel.Text = I18N.GetString("Remarks");
TimeoutLabel.Text = I18N.GetString("Timeout(Sec)");
OneTimeAuth.Text = I18N.GetString("Onetime Authentication");
ServerGroupBox.Text = I18N.GetString("Server");
OKButton.Text = I18N.GetString("OK");
@@ -78,15 +79,32 @@ namespace Shadowsocks.View
{
return true;
}
Server server = new Server
Server server = new Server();
server.server = IPTextBox.Text.Trim();
try
{
server = IPTextBox.Text.Trim(),
server_port = int.Parse(ServerPortTextBox.Text),
password = PasswordTextBox.Text,
method = EncryptionSelect.Text,
remarks = RemarksTextBox.Text,
auth = OneTimeAuth.Checked
};
server.server_port = int.Parse(ServerPortTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show(I18N.GetString("Illegal port number format"));
ServerPortTextBox.Clear();
return false;
}
server.password = PasswordTextBox.Text;
server.method = EncryptionSelect.Text;
server.remarks = RemarksTextBox.Text;
try
{
server.timeout = int.Parse(TimeoutTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show(I18N.GetString("Illegal timeout format"));
TimeoutTextBox.Clear();
return false;
}
server.auth = OneTimeAuth.Checked;
int localPort = int.Parse(ProxyPortTextBox.Text);
Configuration.CheckServer(server);
Configuration.CheckLocalPort(localPort);
@@ -95,10 +113,6 @@ namespace Shadowsocks.View
return true;
}
catch (FormatException)
{
MessageBox.Show(I18N.GetString("Illegal port number format"));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
@@ -118,6 +132,7 @@ namespace Shadowsocks.View
ProxyPortTextBox.Text = _modifiedConfiguration.localPort.ToString();
EncryptionSelect.Text = server.method ?? "aes-256-cfb";
RemarksTextBox.Text = server.remarks;
TimeoutTextBox.Text = server.timeout.ToString();
OneTimeAuth.Checked = server.auth;
}
}
@@ -281,7 +296,7 @@ namespace Shadowsocks.View
{
int index = ServersListBox.SelectedIndex;
Server server = _modifiedConfiguration.configs[index];
object item = ServersListBox.SelectedItem;
object item = ServersListBox.Items[index];
_modifiedConfiguration.configs.Remove(server);
_modifiedConfiguration.configs.Insert(index + step, server);
+250 -222
View File
@@ -28,226 +28,252 @@
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.MyCancelButton = new System.Windows.Forms.Button();
this.OKButton = new System.Windows.Forms.Button();
this.UseProxyCheckBox = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.ProxyAddrLabel = new System.Windows.Forms.Label();
this.ProxyServerTextBox = new System.Windows.Forms.TextBox();
this.ProxyPortLable = new System.Windows.Forms.Label();
this.ProxyPortTextBox = new System.Windows.Forms.TextBox();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.ProxyTypeLabel = new System.Windows.Forms.Label();
this.ProxyTypeComboBox = new System.Windows.Forms.ComboBox();
this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.AutoSize = true;
this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.UseProxyCheckBox, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 1);
this.tableLayoutPanel1.Location = new System.Drawing.Point(15, 15);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(395, 123);
this.tableLayoutPanel1.TabIndex = 0;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.AutoSize = true;
this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel3.ColumnCount = 2;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel3.Controls.Add(this.MyCancelButton, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.OKButton, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Right;
this.tableLayoutPanel3.Location = new System.Drawing.Point(236, 94);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.Size = new System.Drawing.Size(159, 26);
this.tableLayoutPanel3.TabIndex = 9;
//
// MyCancelButton
//
this.MyCancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.MyCancelButton.Dock = System.Windows.Forms.DockStyle.Right;
this.MyCancelButton.Location = new System.Drawing.Point(84, 3);
this.MyCancelButton.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.MyCancelButton.Name = "MyCancelButton";
this.MyCancelButton.Size = new System.Drawing.Size(75, 23);
this.MyCancelButton.TabIndex = 13;
this.MyCancelButton.Text = "Cancel";
this.MyCancelButton.UseVisualStyleBackColor = true;
this.MyCancelButton.Click += new System.EventHandler(this.CancelButton_Click);
//
// OKButton
//
this.OKButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.OKButton.Dock = System.Windows.Forms.DockStyle.Right;
this.OKButton.Location = new System.Drawing.Point(3, 3);
this.OKButton.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
this.OKButton.Name = "OKButton";
this.OKButton.Size = new System.Drawing.Size(75, 23);
this.OKButton.TabIndex = 12;
this.OKButton.Text = "OK";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
//
// UseProxyCheckBox
//
this.UseProxyCheckBox.AutoSize = true;
this.UseProxyCheckBox.Location = new System.Drawing.Point(3, 3);
this.UseProxyCheckBox.Name = "UseProxyCheckBox";
this.UseProxyCheckBox.Size = new System.Drawing.Size(78, 16);
this.UseProxyCheckBox.TabIndex = 0;
this.UseProxyCheckBox.Text = "Use Proxy";
this.UseProxyCheckBox.UseVisualStyleBackColor = true;
this.UseProxyCheckBox.CheckedChanged += new System.EventHandler(this.UseProxyCheckBox_CheckedChanged);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.AutoSize = true;
this.tableLayoutPanel2.ColumnCount = 4;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.Controls.Add(this.ProxyAddrLabel, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyServerTextBox, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyPortLable, 2, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyPortTextBox, 3, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 61);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(389, 27);
this.tableLayoutPanel2.TabIndex = 1;
//
// ProxyAddrLabel
//
this.ProxyAddrLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.ProxyAddrLabel.AutoSize = true;
this.ProxyAddrLabel.Location = new System.Drawing.Point(3, 7);
this.ProxyAddrLabel.Name = "ProxyAddrLabel";
this.ProxyAddrLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyAddrLabel.TabIndex = 0;
this.ProxyAddrLabel.Text = "Proxy Addr";
//
// ProxyServerTextBox
//
this.ProxyServerTextBox.Location = new System.Drawing.Point(74, 3);
this.ProxyServerTextBox.MaxLength = 512;
this.ProxyServerTextBox.Name = "ProxyServerTextBox";
this.ProxyServerTextBox.Size = new System.Drawing.Size(135, 21);
this.ProxyServerTextBox.TabIndex = 1;
this.ProxyServerTextBox.WordWrap = false;
//
// ProxyPortLable
//
this.ProxyPortLable.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.ProxyPortLable.AutoSize = true;
this.ProxyPortLable.Location = new System.Drawing.Point(215, 7);
this.ProxyPortLable.Name = "ProxyPortLable";
this.ProxyPortLable.Size = new System.Drawing.Size(65, 12);
this.ProxyPortLable.TabIndex = 2;
this.ProxyPortLable.Text = "Proxy Port";
//
// ProxyPortTextBox
//
this.ProxyPortTextBox.Location = new System.Drawing.Point(286, 3);
this.ProxyPortTextBox.MaxLength = 10;
this.ProxyPortTextBox.Name = "ProxyPortTextBox";
this.ProxyPortTextBox.Size = new System.Drawing.Size(100, 21);
this.ProxyPortTextBox.TabIndex = 3;
this.ProxyPortTextBox.WordWrap = false;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.AutoSize = true;
this.tableLayoutPanel4.ColumnCount = 2;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.Controls.Add(this.ProxyTypeLabel, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.ProxyTypeComboBox, 1, 0);
this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 25);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 1;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel4.Size = new System.Drawing.Size(198, 30);
this.tableLayoutPanel4.TabIndex = 10;
//
// ProxyTypeLabel
//
this.ProxyTypeLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.ProxyTypeLabel.AutoSize = true;
this.ProxyTypeLabel.Location = new System.Drawing.Point(3, 9);
this.ProxyTypeLabel.Name = "ProxyTypeLabel";
this.ProxyTypeLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyTypeLabel.TabIndex = 1;
this.ProxyTypeLabel.Text = "Proxy Type";
//
// ProxyTypeComboBox
//
this.ProxyTypeComboBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.ProxyTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ProxyTypeComboBox.FormattingEnabled = true;
this.ProxyTypeComboBox.Items.AddRange(new object[] {
"SOCKS5",
"HTTP"});
this.ProxyTypeComboBox.Location = new System.Drawing.Point(74, 5);
this.ProxyTypeComboBox.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.ProxyTypeComboBox.Name = "ProxyTypeComboBox";
this.ProxyTypeComboBox.Size = new System.Drawing.Size(121, 20);
this.ProxyTypeComboBox.TabIndex = 2;
//
// ProxyForm
//
this.AcceptButton = this.OKButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.CancelButton = this.MyCancelButton;
this.ClientSize = new System.Drawing.Size(441, 165);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ProxyForm";
this.Padding = new System.Windows.Forms.Padding(12, 12, 12, 9);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit Proxy";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProxyForm_FormClosed);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.MyCancelButton = new System.Windows.Forms.Button();
this.OKButton = new System.Windows.Forms.Button();
this.UseProxyCheckBox = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.ProxyAddrLabel = new System.Windows.Forms.Label();
this.ProxyServerTextBox = new System.Windows.Forms.TextBox();
this.ProxyPortLabel = new System.Windows.Forms.Label();
this.ProxyPortTextBox = new System.Windows.Forms.TextBox();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.ProxyTypeLabel = new System.Windows.Forms.Label();
this.ProxyTypeComboBox = new System.Windows.Forms.ComboBox();
this.ProxyTimeoutTextBox = new System.Windows.Forms.TextBox();
this.ProxyTimeoutLabel = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.AutoSize = true;
this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.UseProxyCheckBox, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 1);
this.tableLayoutPanel1.Location = new System.Drawing.Point(15, 15);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(395, 123);
this.tableLayoutPanel1.TabIndex = 0;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.AutoSize = true;
this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel3.ColumnCount = 2;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel3.Controls.Add(this.MyCancelButton, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.OKButton, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Right;
this.tableLayoutPanel3.Location = new System.Drawing.Point(236, 94);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.Size = new System.Drawing.Size(159, 26);
this.tableLayoutPanel3.TabIndex = 9;
//
// MyCancelButton
//
this.MyCancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.MyCancelButton.Dock = System.Windows.Forms.DockStyle.Right;
this.MyCancelButton.Location = new System.Drawing.Point(84, 3);
this.MyCancelButton.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.MyCancelButton.Name = "MyCancelButton";
this.MyCancelButton.Size = new System.Drawing.Size(75, 23);
this.MyCancelButton.TabIndex = 13;
this.MyCancelButton.Text = "Cancel";
this.MyCancelButton.UseVisualStyleBackColor = true;
this.MyCancelButton.Click += new System.EventHandler(this.CancelButton_Click);
//
// OKButton
//
this.OKButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.OKButton.Dock = System.Windows.Forms.DockStyle.Right;
this.OKButton.Location = new System.Drawing.Point(3, 3);
this.OKButton.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
this.OKButton.Name = "OKButton";
this.OKButton.Size = new System.Drawing.Size(75, 23);
this.OKButton.TabIndex = 12;
this.OKButton.Text = "OK";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
//
// UseProxyCheckBox
//
this.UseProxyCheckBox.AutoSize = true;
this.UseProxyCheckBox.Location = new System.Drawing.Point(3, 3);
this.UseProxyCheckBox.Name = "UseProxyCheckBox";
this.UseProxyCheckBox.Size = new System.Drawing.Size(78, 16);
this.UseProxyCheckBox.TabIndex = 0;
this.UseProxyCheckBox.Text = "Use Proxy";
this.UseProxyCheckBox.UseVisualStyleBackColor = true;
this.UseProxyCheckBox.CheckedChanged += new System.EventHandler(this.UseProxyCheckBox_CheckedChanged);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.AutoSize = true;
this.tableLayoutPanel2.ColumnCount = 4;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.Controls.Add(this.ProxyAddrLabel, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyServerTextBox, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyPortLabel, 2, 0);
this.tableLayoutPanel2.Controls.Add(this.ProxyPortTextBox, 3, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 61);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(389, 27);
this.tableLayoutPanel2.TabIndex = 1;
//
// ProxyAddrLabel
//
this.ProxyAddrLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyAddrLabel.AutoSize = true;
this.ProxyAddrLabel.Location = new System.Drawing.Point(3, 7);
this.ProxyAddrLabel.Name = "ProxyAddrLabel";
this.ProxyAddrLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyAddrLabel.TabIndex = 0;
this.ProxyAddrLabel.Text = "Proxy Addr";
//
// ProxyServerTextBox
//
this.ProxyServerTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyServerTextBox.Location = new System.Drawing.Point(74, 3);
this.ProxyServerTextBox.MaxLength = 512;
this.ProxyServerTextBox.Name = "ProxyServerTextBox";
this.ProxyServerTextBox.Size = new System.Drawing.Size(135, 21);
this.ProxyServerTextBox.TabIndex = 1;
this.ProxyServerTextBox.WordWrap = false;
//
// ProxyPortLabel
//
this.ProxyPortLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyPortLabel.AutoSize = true;
this.ProxyPortLabel.Location = new System.Drawing.Point(215, 7);
this.ProxyPortLabel.Name = "ProxyPortLabel";
this.ProxyPortLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyPortLabel.TabIndex = 2;
this.ProxyPortLabel.Text = "Proxy Port";
//
// ProxyPortTextBox
//
this.ProxyPortTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyPortTextBox.Location = new System.Drawing.Point(286, 3);
this.ProxyPortTextBox.MaxLength = 10;
this.ProxyPortTextBox.Name = "ProxyPortTextBox";
this.ProxyPortTextBox.Size = new System.Drawing.Size(100, 21);
this.ProxyPortTextBox.TabIndex = 3;
this.ProxyPortTextBox.WordWrap = false;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.AutoSize = true;
this.tableLayoutPanel4.ColumnCount = 4;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel4.Controls.Add(this.ProxyTypeLabel, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.ProxyTypeComboBox, 1, 0);
this.tableLayoutPanel4.Controls.Add(this.ProxyTimeoutTextBox, 3, 0);
this.tableLayoutPanel4.Controls.Add(this.ProxyTimeoutLabel, 2, 0);
this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 25);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 1;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel4.Size = new System.Drawing.Size(387, 30);
this.tableLayoutPanel4.TabIndex = 10;
//
// ProxyTypeLabel
//
this.ProxyTypeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyTypeLabel.AutoSize = true;
this.ProxyTypeLabel.Location = new System.Drawing.Point(3, 9);
this.ProxyTypeLabel.Name = "ProxyTypeLabel";
this.ProxyTypeLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyTypeLabel.TabIndex = 1;
this.ProxyTypeLabel.Text = "Proxy Type";
//
// ProxyTypeComboBox
//
this.ProxyTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ProxyTypeComboBox.FormattingEnabled = true;
this.ProxyTypeComboBox.Items.AddRange(new object[] {
"SOCKS5",
"HTTP"});
this.ProxyTypeComboBox.Location = new System.Drawing.Point(74, 5);
this.ProxyTypeComboBox.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.ProxyTypeComboBox.Name = "ProxyTypeComboBox";
this.ProxyTypeComboBox.Size = new System.Drawing.Size(121, 20);
this.ProxyTypeComboBox.TabIndex = 2;
//
// ProxyTimeoutTextBox
//
this.ProxyTimeoutTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyTimeoutTextBox.Location = new System.Drawing.Point(284, 4);
this.ProxyTimeoutTextBox.Name = "ProxyTimeoutTextBox";
this.ProxyTimeoutTextBox.Size = new System.Drawing.Size(100, 21);
this.ProxyTimeoutTextBox.TabIndex = 3;
//
// ProxyTimeoutLabel
//
this.ProxyTimeoutLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.ProxyTimeoutLabel.AutoSize = true;
this.ProxyTimeoutLabel.Location = new System.Drawing.Point(201, 9);
this.ProxyTimeoutLabel.Name = "ProxyTimeoutLabel";
this.ProxyTimeoutLabel.Size = new System.Drawing.Size(77, 12);
this.ProxyTimeoutLabel.TabIndex = 4;
this.ProxyTimeoutLabel.Text = "Timeout(Sec)";
//
// ProxyForm
//
this.AcceptButton = this.OKButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.CancelButton = this.MyCancelButton;
this.ClientSize = new System.Drawing.Size(441, 165);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ProxyForm";
this.Padding = new System.Windows.Forms.Padding(12, 12, 12, 9);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit Proxy";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProxyForm_FormClosed);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
@@ -257,13 +283,15 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.Label ProxyAddrLabel;
private System.Windows.Forms.TextBox ProxyServerTextBox;
private System.Windows.Forms.Label ProxyPortLable;
private System.Windows.Forms.Label ProxyPortLabel;
private System.Windows.Forms.TextBox ProxyPortTextBox;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.Button MyCancelButton;
private System.Windows.Forms.Button OKButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.Label ProxyTypeLabel;
private System.Windows.Forms.ComboBox ProxyTypeComboBox;
private System.Windows.Forms.ComboBox ProxyTypeComboBox;
private System.Windows.Forms.TextBox ProxyTimeoutTextBox;
private System.Windows.Forms.Label ProxyTimeoutLabel;
}
}
+37 -13
View File
@@ -34,7 +34,8 @@ namespace Shadowsocks.View
UseProxyCheckBox.Text = I18N.GetString("Use Proxy");
ProxyTypeLabel.Text = I18N.GetString("Proxy Type");
ProxyAddrLabel.Text = I18N.GetString("Proxy Addr");
ProxyPortLable.Text = I18N.GetString("Proxy Port");
ProxyPortLabel.Text = I18N.GetString("Proxy Port");
ProxyTimeoutLabel.Text = I18N.GetString("Timeout(Sec)");
OKButton.Text = I18N.GetString("OK");
MyCancelButton.Text = I18N.GetString("Cancel");
this.Text = I18N.GetString("Edit Proxy");
@@ -51,33 +52,54 @@ namespace Shadowsocks.View
UseProxyCheckBox.Checked = _modifiedConfiguration.useProxy;
ProxyServerTextBox.Text = _modifiedConfiguration.proxyServer;
ProxyPortTextBox.Text = _modifiedConfiguration.proxyPort.ToString();
ProxyTimeoutTextBox.Text = _modifiedConfiguration.proxyTimeout.ToString();
ProxyTypeComboBox.SelectedIndex = _modifiedConfiguration.proxyType;
}
private void OKButton_Click(object sender, EventArgs e)
{
var type = ProxyTypeComboBox.SelectedIndex;
var proxy = ProxyServerTextBox.Text;
var port = 0;
var timeout = 3;
if (UseProxyCheckBox.Checked)
{
try
{
var type = ProxyTypeComboBox.SelectedIndex;
var proxy = ProxyServerTextBox.Text;
var port = int.Parse(ProxyPortTextBox.Text);
Configuration.CheckServer(proxy);
Configuration.CheckPort(port);
controller.EnableProxy(type, proxy, port);
port = int.Parse(ProxyPortTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show(I18N.GetString("Illegal port number format"));
ProxyPortTextBox.Clear();
return;
}
try
{
timeout = int.Parse(ProxyTimeoutTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show(I18N.GetString("Illegal timeout format"));
ProxyTimeoutTextBox.Clear();
return;
}
try
{
Configuration.CheckServer(proxy);
Configuration.CheckPort(port);
Configuration.CheckTimeout(timeout, ProxyConfig.MaxProxyTimeoutSec);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
controller.EnableProxy(type, proxy, port);
}
else
{
@@ -85,11 +107,10 @@ namespace Shadowsocks.View
}
_modifiedConfiguration.useProxy = UseProxyCheckBox.Checked;
_modifiedConfiguration.proxyType = ProxyTypeComboBox.SelectedIndex;
_modifiedConfiguration.proxyServer = ProxyServerTextBox.Text;
var tmpProxyPort = 0;
int.TryParse(ProxyPortTextBox.Text, out tmpProxyPort);
_modifiedConfiguration.proxyPort = tmpProxyPort;
_modifiedConfiguration.proxyType = type;
_modifiedConfiguration.proxyServer = proxy;
_modifiedConfiguration.proxyPort = port;
_modifiedConfiguration.proxyTimeout = timeout;
controller.SaveProxyConfig(_modifiedConfiguration);
this.Close();
@@ -116,14 +137,17 @@ namespace Shadowsocks.View
{
ProxyServerTextBox.Enabled = true;
ProxyPortTextBox.Enabled = true;
ProxyTimeoutTextBox.Enabled = true;
ProxyTypeComboBox.Enabled = true;
}
else
{
ProxyServerTextBox.Clear();
ProxyPortTextBox.Clear();
ProxyTimeoutTextBox.Clear();
ProxyServerTextBox.Enabled = false;
ProxyPortTextBox.Enabled = false;
ProxyTimeoutTextBox.Enabled = false;
ProxyTypeComboBox.Enabled = false;
}
}
+119 -119
View File
@@ -1,120 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+6 -6
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
+6 -6
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caseless.Fody" version="1.4.2" targetFramework="net40-client" developmentDependency="true" />
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net40-client" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net40-client" developmentDependency="true" />
<package id="GlobalHotKey" version="1.1.0" targetFramework="net40-client" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40-client" />
<package id="StringEx.CS" version="0.3.1" targetFramework="net40-client" developmentDependency="true" />
<package id="Caseless.Fody" version="1.4.2" targetFramework="net462" developmentDependency="true" />
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net462" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net462" developmentDependency="true" />
<package id="GlobalHotKey" version="1.1.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" />
<package id="StringEx.CS" version="0.3.1" targetFramework="net462" developmentDependency="true" />
</packages>
+17 -15
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Shadowsocks</RootNamespace>
<AssemblyName>Shadowsocks</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>
</StartupObject>
@@ -21,7 +21,8 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -72,11 +73,9 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>3rd\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>3rd\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -84,11 +83,8 @@
<Reference Include="System.Net" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xaml" />
<Reference Include="System.XML" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="3rd\zxing\BarcodeFormat.cs" />
@@ -190,6 +186,12 @@
<Compile Include="Util\Sockets\LineReader.cs" />
<Compile Include="Util\Sockets\SocketUtil.cs" />
<Compile Include="Util\Sockets\WrappedSocket.cs" />
<Compile Include="Util\SystemProxy\INTERNET_OPTION.cs" />
<Compile Include="Util\SystemProxy\INTERNET_PER_CONN_OPTION.cs" />
<Compile Include="Util\SystemProxy\INTERNET_PER_CONN_OPTION_LIST.cs" />
<Compile Include="Util\SystemProxy\NativeMethods.cs" />
<Compile Include="Util\SystemProxy\RAS.cs" />
<Compile Include="Util\SystemProxy\WinINet.cs" />
<Compile Include="Util\Util.cs" />
<Compile Include="View\ConfigForm.cs">
<SubType>Form</SubType>
@@ -331,13 +333,6 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('3rd\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '3rd\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
</Target>
<Import Project="3rd\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('3rd\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
<UsingTask TaskName="CosturaCleanup" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory">
<ParameterGroup>
<Config Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem" />
@@ -374,6 +369,13 @@ foreach (var item in filesToCleanup)
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
<Import Project="3rd\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('3rd\Fody.1.29.4\build\dotnet\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('3rd\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '3rd\Fody.1.29.4\build\dotnet\Fody.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+2 -5
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>test</RootNamespace>
<AssemblyName>test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@@ -40,9 +40,6 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="WindowsBase" />
</ItemGroup>
<Choose>