From afc5137355e612fa28867a738c0d097c6d790b89 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Tue, 11 Nov 2014 02:28:12 +0800 Subject: [PATCH] some fix --- shadowsocks-csharp/Controller/Local.cs | 15 ++++++++------- shadowsocks-csharp/Program.cs | 2 ++ shadowsocks-csharp/shadowsocks-csharp.csproj | 4 +++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/shadowsocks-csharp/Controller/Local.cs b/shadowsocks-csharp/Controller/Local.cs index ed769215..8bdbd15f 100755 --- a/shadowsocks-csharp/Controller/Local.cs +++ b/shadowsocks-csharp/Controller/Local.cs @@ -70,7 +70,7 @@ namespace Shadowsocks.Controller { Socket listener = (Socket)ar.AsyncState; Socket conn = listener.EndAccept(ar); - conn.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true); + conn.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); listener.BeginAccept( new AsyncCallback(AcceptCallback), @@ -103,15 +103,14 @@ namespace Shadowsocks.Controller public const int RecvSize = 16384; public const int BufferSize = RecvSize + 32; // remote receive buffer - public byte[] remoteRecvBuffer = new byte[RecvSize]; + private byte[] remoteRecvBuffer = new byte[RecvSize]; // remote send buffer - public byte[] remoteSendBuffer = new byte[BufferSize]; + private byte[] remoteSendBuffer = new byte[BufferSize]; // connection receive buffer - public byte[] connetionRecvBuffer = new byte[RecvSize]; + private byte[] connetionRecvBuffer = new byte[RecvSize]; // connection send buffer - public byte[] connetionSendBuffer = new byte[BufferSize]; + private byte[] connetionSendBuffer = new byte[BufferSize]; // Received data string. - public StringBuilder sb = new StringBuilder(); private bool connectionShutdown = false; private bool remoteShutdown = false; @@ -134,7 +133,7 @@ namespace Shadowsocks.Controller remote = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - remote.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true); + remote.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); // Connect to the remote endpoint. remote.BeginConnect(remoteEP, @@ -238,6 +237,7 @@ namespace Shadowsocks.Controller { // reject socks 4 response = new byte[]{ 0, 91 }; + Console.WriteLine("socks 5 protocol error"); } connection.BeginSend(response, 0, response.Length, 0, new AsyncCallback(HandshakeSendCallback), null); } @@ -289,6 +289,7 @@ namespace Shadowsocks.Controller } else { + Console.WriteLine("failed to recv data in handshakeReceive2Callback"); this.Close(); } } diff --git a/shadowsocks-csharp/Program.cs b/shadowsocks-csharp/Program.cs index 35356d78..2115c77a 100755 --- a/shadowsocks-csharp/Program.cs +++ b/shadowsocks-csharp/Program.cs @@ -47,7 +47,9 @@ namespace Shadowsocks } LoadLibrary(dllPath); +#if !DEBUG Logging.OpenLogFile(); +#endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ShadowsocksController controller = new ShadowsocksController(); diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index 1ad09bf6..2fa3cf78 100755 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -119,7 +119,9 @@ QRCodeForm.cs - + + Designer +