Browse Source

add open on lan option

Add an option to choose whether to open on lan or not.
pull/45/head
wzxjohn 10 years ago
parent
commit
26fdd9c612
3 changed files with 20 additions and 19 deletions
  1. +1
    -1
      shadowsocks-csharp.sln
  2. +18
    -18
      shadowsocks-csharp/Controller/Local.cs
  3. +1
    -0
      shadowsocks-csharp/View/ConfigForm.Designer.cs

+ 1
- 1
shadowsocks-csharp.sln View File

@@ -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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{45913187-0685-4903-B250-DCEF0479CD86}"


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

@@ -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)
{


+ 1
- 0
shadowsocks-csharp/View/ConfigForm.Designer.cs View File

@@ -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";


Loading…
Cancel
Save