diff --git a/shadowsocks-csharp.sln b/shadowsocks-csharp.sln index 46bde1a8..03faec06 100755 --- a/shadowsocks-csharp.sln +++ b/shadowsocks-csharp.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shadowsocks-csharp", "shadowsocks-csharp\shadowsocks-csharp.csproj", "{8C02D2F7-7CDB-4D55-9F25-CD03EF4AA062}" EndProject Global diff --git a/shadowsocks-csharp/Controller/Local.cs b/shadowsocks-csharp/Controller/Local.cs index baf535c3..bf2f95ad 100755 --- a/shadowsocks-csharp/Controller/Local.cs +++ b/shadowsocks-csharp/Controller/Local.cs @@ -10,9 +10,9 @@ namespace Shadowsocks.Controller { class Local - { + { private Server _server; - private bool _shareOverLAN; + private bool _shareOverLAN; //private Encryptor encryptor; Socket _listener; public Local(Configuration config) @@ -26,7 +26,7 @@ namespace Shadowsocks.Controller { try { - // Create a TCP/IP socket. + // Create a TCP/IP socket. _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); IPEndPoint localEndPoint = null; @@ -36,7 +36,7 @@ namespace Shadowsocks.Controller } else { - localEndPoint = new IPEndPoint(IPAddress.Loopback, _server.local_port); + localEndPoint = new IPEndPoint(IPAddress.Loopback, _server.local_port); } // Bind the socket to the local endpoint and listen for incoming connections. @@ -221,7 +221,7 @@ namespace Shadowsocks.Controller // reject socks 4 response = new byte[]{ 0, 91 }; } - connection.BeginSend(response, 0, response.Length, 0, new AsyncCallback(handshakeSendCallback), null); + connection.BeginSend(response, 0, response.Length, 0, new AsyncCallback(HandshakeSendCallback), null); } else { @@ -235,7 +235,7 @@ namespace Shadowsocks.Controller } } - private void handshakeSendCallback(IAsyncResult ar) + private void HandshakeSendCallback(IAsyncResult ar) { try { @@ -267,7 +267,7 @@ namespace Shadowsocks.Controller if (bytesRead > 0) { byte[] response = { 5, 0, 0, 1, 0, 0, 0, 0, 0, 0 }; - connection.BeginSend(response, 0, response.Length, 0, new AsyncCallback(startPipe), null); + connection.BeginSend(response, 0, response.Length, 0, new AsyncCallback(StartPipe), null); } else { @@ -282,15 +282,15 @@ namespace Shadowsocks.Controller } - private void startPipe(IAsyncResult ar) + private void StartPipe(IAsyncResult ar) { try { connection.EndReceive(ar); remote.BeginReceive(remoteRecvBuffer, 0, RecvSize, 0, - new AsyncCallback(pipeRemoteReceiveCallback), null); + new AsyncCallback(PipeRemoteReceiveCallback), null); connection.BeginReceive(connetionRecvBuffer, 0, RecvSize, 0, - new AsyncCallback(pipeConnectionReceiveCallback), null); + new AsyncCallback(PipeConnectionReceiveCallback), null); } catch (Exception e) { @@ -299,7 +299,7 @@ namespace Shadowsocks.Controller } } - private void pipeRemoteReceiveCallback(IAsyncResult ar) + private void PipeRemoteReceiveCallback(IAsyncResult ar) { try @@ -310,7 +310,7 @@ namespace Shadowsocks.Controller { int bytesToSend; encryptor.Decrypt(remoteRecvBuffer, bytesRead, remoteSendBuffer, out bytesToSend); - connection.BeginSend(remoteSendBuffer, 0, bytesToSend, 0, new AsyncCallback(pipeConnectionSendCallback), null); + connection.BeginSend(remoteSendBuffer, 0, bytesToSend, 0, new AsyncCallback(PipeConnectionSendCallback), null); } else { @@ -325,7 +325,7 @@ namespace Shadowsocks.Controller } } - private void pipeConnectionReceiveCallback(IAsyncResult ar) + private void PipeConnectionReceiveCallback(IAsyncResult ar) { try @@ -336,7 +336,7 @@ namespace Shadowsocks.Controller { int bytesToSend; encryptor.Encrypt(connetionRecvBuffer, bytesRead, connetionSendBuffer, out bytesToSend); - remote.BeginSend(connetionSendBuffer, 0, bytesToSend, 0, new AsyncCallback(pipeRemoteSendCallback), null); + remote.BeginSend(connetionSendBuffer, 0, bytesToSend, 0, new AsyncCallback(PipeRemoteSendCallback), null); } else { @@ -350,13 +350,13 @@ namespace Shadowsocks.Controller } } - private void pipeRemoteSendCallback(IAsyncResult ar) + private void PipeRemoteSendCallback(IAsyncResult ar) { try { remote.EndSend(ar); connection.BeginReceive(this.connetionRecvBuffer, 0, RecvSize, 0, - new AsyncCallback(pipeConnectionReceiveCallback), null); + new AsyncCallback(PipeConnectionReceiveCallback), null); } catch (Exception e) { @@ -365,13 +365,13 @@ namespace Shadowsocks.Controller } } - private void pipeConnectionSendCallback(IAsyncResult ar) + private void PipeConnectionSendCallback(IAsyncResult ar) { try { connection.EndSend(ar); remote.BeginReceive(this.remoteRecvBuffer, 0, RecvSize, 0, - new AsyncCallback(pipeRemoteReceiveCallback), null); + new AsyncCallback(PipeRemoteReceiveCallback), null); } catch (Exception e) { diff --git a/shadowsocks-csharp/Controller/PACServer.cs b/shadowsocks-csharp/Controller/PACServer.cs index 422089dc..9ad74abf 100755 --- a/shadowsocks-csharp/Controller/PACServer.cs +++ b/shadowsocks-csharp/Controller/PACServer.cs @@ -15,6 +15,7 @@ namespace Shadowsocks.Controller { private static int PORT = 8090; private static string PAC_FILE = "pac.txt"; + public bool openOnLan; Socket _listener; FileSystemWatcher watcher; diff --git a/shadowsocks-csharp/Controller/PolipoRunner.cs b/shadowsocks-csharp/Controller/PolipoRunner.cs index de1c3c3a..a82333f5 100755 --- a/shadowsocks-csharp/Controller/PolipoRunner.cs +++ b/shadowsocks-csharp/Controller/PolipoRunner.cs @@ -12,6 +12,7 @@ namespace Shadowsocks.Controller class PolipoRunner { private Process _process; + public bool openOnLan; public void Start(Configuration configuration) { @@ -31,10 +32,10 @@ namespace Shadowsocks.Controller Console.WriteLine(e.ToString()); } } - string temppath = Path.GetTempPath(); + string temppath = Path.GetTempPath(); string polipoConfig = Resources.polipo_config; polipoConfig = polipoConfig.Replace("__SOCKS_PORT__", server.local_port.ToString()); - polipoConfig = polipoConfig.Replace("__POLIPO_BIND_IP__", configuration.shareOverLan ? "0.0.0.0" : "127.0.0.1"); + polipoConfig = polipoConfig.Replace("__POLIPO_BIND_IP__", configuration.shareOverLan ? "0.0.0.0" : "127.0.0.1"); FileManager.ByteArrayToFile(temppath + "/polipo.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig)); FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe); diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index e6e80d05..4c1d34a8 100755 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -34,6 +34,7 @@ namespace Shadowsocks.Controller public ShadowsocksController() { _config = Configuration.Load(); + openOnLan = _config.openOnLan; polipoRunner = new PolipoRunner(); polipoRunner.Start(_config); local = new Local(_config); diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index 65b0a3b6..e89983b0 100755 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -17,6 +17,7 @@ namespace Shadowsocks.Model public bool enabled; public bool shareOverLan; public bool isDefault; + public bool openOnLan; private static string CONFIG_FILE = "gui-config.json"; diff --git a/shadowsocks-csharp/View/ConfigForm.Designer.cs b/shadowsocks-csharp/View/ConfigForm.Designer.cs index cf874286..c1187c04 100755 --- a/shadowsocks-csharp/View/ConfigForm.Designer.cs +++ b/shadowsocks-csharp/View/ConfigForm.Designer.cs @@ -434,6 +434,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "ConfigForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Edit Servers";