Browse Source

Merge pull request #8 from clowwindy/master

Merge with upstream
pull/146/head
Sharuru 10 years ago
parent
commit
7be4ba2681
6 changed files with 60 additions and 16 deletions
  1. +4
    -0
      CHANGES
  2. +13
    -13
      shadowsocks-csharp/Controller/Local.cs
  3. +27
    -0
      shadowsocks-csharp/Controller/Logging.cs
  4. +6
    -1
      shadowsocks-csharp/Controller/PACServer.cs
  5. +9
    -1
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  6. +1
    -1
      shadowsocks-csharp/Properties/AssemblyInfo.cs

+ 4
- 0
CHANGES View File

@@ -1,3 +1,7 @@
2.0.11 2014-11-23
- Fix a crash
- Only switch the system proxy off if we have switched it on

2.0.10 2014-11-18 2.0.10 2014-11-18
- Minor fixes - Minor fixes
- Optimize code - Optimize code


+ 13
- 13
shadowsocks-csharp/Controller/Local.cs View File

@@ -144,7 +144,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -176,7 +176,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
} }
} }
if (remote != null) if (remote != null)
@@ -188,7 +188,7 @@ namespace Shadowsocks.Controller
} }
catch (SocketException e) catch (SocketException e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
} }
} }
lock (encryptionLock) lock (encryptionLock)
@@ -218,7 +218,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -236,7 +236,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -269,7 +269,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -296,7 +296,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -324,7 +324,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -346,7 +346,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -384,7 +384,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -421,7 +421,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -440,7 +440,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }
@@ -459,7 +459,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close(); this.Close();
} }
} }


+ 27
- 0
shadowsocks-csharp/Controller/Logging.cs View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net.Sockets;
using System.Text; using System.Text;
namespace Shadowsocks.Controller namespace Shadowsocks.Controller
@@ -30,5 +31,31 @@ namespace Shadowsocks.Controller
return false; return false;
} }
} }
public static void LogUsefulException(Exception e)
{
// just log useful exceptions, not all of them
if (e is SocketException)
{
SocketException se = (SocketException)e;
if (se.SocketErrorCode == SocketError.ConnectionAborted)
{
// closed by browser when sending
// normally happens when download is canceled or a tab is closed before page is loaded
}
else if (se.SocketErrorCode == SocketError.ConnectionReset)
{
// received rst
}
else
{
Console.WriteLine(e);
}
}
else
{
Console.WriteLine(e);
}
}
} }
} }

+ 6
- 1
shadowsocks-csharp/Controller/PACServer.cs View File

@@ -174,7 +174,12 @@ Connection: Close
private void SendCallback(IAsyncResult ar) private void SendCallback(IAsyncResult ar)
{ {
Socket conn = (Socket)ar.AsyncState; Socket conn = (Socket)ar.AsyncState;
conn.Shutdown(SocketShutdown.Send);
try
{
conn.Shutdown(SocketShutdown.Send);
}
catch
{ }
} }
private void WatchPacFile() private void WatchPacFile()


+ 9
- 1
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -22,6 +22,8 @@ namespace Shadowsocks.Controller
private PolipoRunner polipoRunner; private PolipoRunner polipoRunner;
private bool stopped = false; private bool stopped = false;
private bool _systemProxyIsDirty = false;
public class PathEventArgs : EventArgs public class PathEventArgs : EventArgs
{ {
public string Path; public string Path;
@@ -174,10 +176,16 @@ namespace Shadowsocks.Controller
if (_config.enabled) if (_config.enabled)
{ {
SystemProxy.Enable(); SystemProxy.Enable();
_systemProxyIsDirty = true;
} }
else else
{ {
SystemProxy.Disable();
// only switch it off if we have switched it on
if (_systemProxyIsDirty)
{
SystemProxy.Disable();
_systemProxyIsDirty = false;
}
} }
} }


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

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

Loading…
Cancel
Save