Compare commits

..
11 Commits
Author SHA1 Message Date
noisyfox 24db6438bd Update CHANGES and bump version 2016-11-07 16:52:28 +11:00
noisyfox c908caa584 Use OpenRegKey 2016-11-06 01:25:22 +11:00
noisyfox a16e80743c Open .net download page automatically 2016-11-06 00:59:03 +11:00
noisyfox aa9fd8ec06 Check .NET Framework version on startup 2016-11-05 23:23:04 +11:00
noisyfox 02124ff3ad Update README.md 2016-11-05 22:07:17 +11:00
Noisyfox eec899b9a3 Merge pull request #847 from celeron533/master
Update README.md
2016-11-04 22:08:18 +11:00
Noisyfox 1979131e12 Merge pull request #857 from wongsyrone/master
Minor update
2016-11-04 21:51:38 +11:00
celeron533 c09af5fe0f Update README.md 2016-10-31 12:30:41 +08:00
Syrone Wong 816e2b351d Update mbed TLS to 2.4.0
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-29 22:47:58 +08:00
Syrone Wong 217e818339 Cleanup
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-26 16:50:28 +08:00
Syrone Wong f06f6f2fbb Refine power mode handling
- enlarge timeout to 10 seconds
- detach event handler before exiting
- output log if success

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-24 08:27:49 +08:00
10 changed files with 89 additions and 45 deletions
+5
View File
@@ -1,3 +1,8 @@
3.3.5 2016-11-7
- Improve system power mode handling
- Update mbed TLS to 2.4.0
- Check .NET Framework version on startup
3.3.4 2016-10-21
- Fix IE dial-up and VPN connection proxy settings
not changed since release 3.3.3.
+5 -3
View File
@@ -96,16 +96,18 @@ system temp folder, create a `shadowsocks_portable_mode.txt` into shadowsocks fo
#### Develop
Visual Studio 2015 is required.
[Visual Studio 2015] & [.NET Framework 4.6.2 Developer Pack] are required.
#### License
GPLv3
[Appveyor]: https://ci.appveyor.com/project/wongsyrone/shadowsocks-windows-0cn3i
[Build Status]: https://ci.appveyor.com/api/projects/status/47784ryn365vw56w/branch/master?svg=true
[Appveyor]: https://ci.appveyor.com/project/Noisyfox/shadowsocks-windows
[Build Status]: https://ci.appveyor.com/api/projects/status/04idbevayrghcrh7/branch/master?svg=true
[latest release]: https://github.com/shadowsocks/shadowsocks-csharp/releases
[GFWList]: https://github.com/gfwlist/gfwlist
[Servers]: https://github.com/shadowsocks/shadowsocks/wiki/Ports-and-Clients#linux--server-side
[中文说明]: https://github.com/shadowsocks/shadowsocks-windows/wiki/Shadowsocks-Windows-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
[Visual Studio 2015]: https://www.visualstudio.com/downloads/
[.NET Framework 4.6.2 Developer Pack]: https://www.microsoft.com/download/details.aspx?id=53321
@@ -23,7 +23,7 @@ namespace Shadowsocks.Controller
public string LatestVersionLocalName;
public event EventHandler CheckUpdateCompleted;
public const string Version = "3.3.4";
public const string Version = "3.3.5";
private class CheckUpdateTimer : System.Timers.Timer
{
+1
View File
@@ -130,6 +130,7 @@ System Proxy On: =系统代理已启用:
Running: Port {0}=正在运行:端口 {0}
Unexpected error, shadowsocks will exit. Please report to=非预期错误,Shadowsocks将退出。请提交此错误到
Unsupported operating system, use Windows Vista at least.=不支持的操作系统版本,最低需求为Windows Vista。
Unsupported .NET Framework, please update to 4.6.2 or later.=当前 .NET Framework 版本过低,请升级至4.6.2或更新版本。
Proxy request failed=代理请求失败
Proxy handshake failed=代理握手失败
Register hotkey failed=注册热键失败
Binary file not shown.
+1
View File
@@ -130,6 +130,7 @@ System Proxy On: =系統代理已啟用:
Running: Port {0}=正在運行:連接埠號碼 {0}
Unexpected error, shadowsocks will exit. Please report to=非預期錯誤,Shadowsocks將退出。請提交此錯誤到
Unsupported operating system, use Windows Vista at least.=不支持的作業系統版本,最低需求為Windows Vista。
Unsupported .NET Framework, please update to 4.6.2 or later.=當前 .NET Framework 版本過低,最低需求為4.6.2。
Proxy request failed=代理請求失敗
Proxy handshake failed=代理握手失敗
Register hotkey failed=註冊捷徑鍵失敗
+23 -3
View File
@@ -31,6 +31,17 @@ namespace Shadowsocks
return;
}
// Check .NET Framework version
if (!Utils.IsSupportedRuntimeVersion())
{
MessageBox.Show(I18N.GetString("Unsupported .NET Framework, please update to 4.6.2 or later."),
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Process.Start(
"http://dotnetsocial.cloudapp.net/GetDotnet?tfm=.NETFramework,Version=v4.6.2");
return;
}
Utils.ReleaseMemory(true);
using (Mutex mutex = new Mutex(false, $"Global\\Shadowsocks_{Application.StartupPath.GetHashCode()}"))
{
@@ -107,7 +118,7 @@ namespace Shadowsocks
Logging.Info("os wake up");
if (_controller != null)
{
System.Timers.Timer timer = new System.Timers.Timer(5 * 1000);
System.Timers.Timer timer = new System.Timers.Timer(10 * 1000);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = false;
timer.Enabled = true;
@@ -115,7 +126,11 @@ namespace Shadowsocks
}
break;
case PowerModes.Suspend:
_controller?.Stop();
if (_controller != null)
{
_controller.Stop();
Logging.Info("controller stopped");
}
Logging.Info("os suspend");
break;
}
@@ -125,7 +140,11 @@ namespace Shadowsocks
{
try
{
_controller?.Start();
if (_controller != null)
{
_controller.Start();
Logging.Info("controller started");
}
}
catch (Exception ex)
{
@@ -149,6 +168,7 @@ namespace Shadowsocks
private static void Application_ApplicationExit(object sender, EventArgs e)
{
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
HotKeys.Destroy();
if (_controller != null)
{
+14 -13
View File
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
public static class RAS
internal static class RemoteAccessService
{
private enum RasFieldSizeConstants
{
@@ -69,22 +64,28 @@ namespace Shadowsocks.Util.SystemProxy
#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)]
[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
// reserved, must be NULL
string reserved,
// pointer to full path and file name of phone-book file
string lpszPhonebook,
// buffer to receive phone-book entries
[In, Out] RasEntryName[] lprasentryname,
// size in bytes of buffer
ref int lpcb,
// number of entries written to buffer
out int lpcEntries
);
/// <summary>
+1 -10
View File
@@ -136,15 +136,6 @@ namespace Shadowsocks.Util.SystemProxy
// 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,
@@ -167,7 +158,7 @@ namespace Shadowsocks.Util.SystemProxy
public static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL)
{
string[] allConnections = null;
var ret = RAS.GetAllConns(ref allConnections);
var ret = RemoteAccessService.GetAllConns(ref allConnections);
if (ret == 2)
throw new Exception("Cannot get all connections");
+38 -15
View File
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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;
@@ -211,7 +208,7 @@ namespace Shadowsocks.Util
return new BandwidthScaleInfo(f, unit, scale);
}
public static RegistryKey OpenRegKey( string name, bool writable, RegistryHive hive = RegistryHive.CurrentUser )
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
@@ -224,24 +221,20 @@ namespace Shadowsocks.Util
.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;
}
catch (Exception e)
{
Logging.LogUsefulException(e);
return null;
}
}
public static bool IsWinVistaOrHigher() {
public static bool IsWinVistaOrHigher()
{
return Environment.OSVersion.Version.Major > 5;
}
@@ -249,5 +242,35 @@ namespace Shadowsocks.Util
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetProcessWorkingSetSize(IntPtr process,
UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);
// See: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
public static bool IsSupportedRuntimeVersion()
{
/*
* +-----------------------------------------------------------------+----------------------------+
* | Version | Value of the Release DWORD |
* +-----------------------------------------------------------------+----------------------------+
* | .NET Framework 4.6.2 installed on Windows 10 Anniversary Update | 394802 |
* | .NET Framework 4.6.2 installed on all other Windows OS versions | 394806 |
* +-----------------------------------------------------------------+----------------------------+
*/
const int minSupportedRelease = 394802;
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
using (var ndpKey = OpenRegKey(subkey, false, RegistryHive.LocalMachine))
{
if (ndpKey?.GetValue("Release") != null)
{
var releaseKey = (int)ndpKey.GetValue("Release");
if (releaseKey >= minSupportedRelease)
{
return true;
}
}
}
return false;
}
}
}