Skip to content

Commit

Permalink
3.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
breakwa11 committed Oct 9, 2016
1 parent ff20d0a commit 1e4b97d
Show file tree
Hide file tree
Showing 26 changed files with 1,078 additions and 388 deletions.
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Controller/HttpPortForwarder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Handler
private bool _closed = false;
private Configuration _config;
HttpPraser httpProxyState;
public const int RecvSize = 16384;
public const int RecvSize = 4096;
// remote receive buffer
private byte[] remoteRecvBuffer = new byte[RecvSize];
// connection receive buffer
Expand Down
3 changes: 2 additions & 1 deletion shadowsocks-csharp/Controller/HttpProxyRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public void Start(Configuration configuration)
polipoConfig = polipoConfig.Replace("__BYPASS_ACTION__", "actionsfile " + _subPath + "/bypass.action");
FileManager.ByteArrayToFile(runningPath + "/privoxy.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig));

string bypassConfig = "{+forward-override{forward .}}\n0.[0-9]*.[0-9]*.[0-9]*/\n10.[0-9]*.[0-9]*.[0-9]*/\n127.[0-9]*.[0-9]*.[0-9]*/\n192.168.[0-9]*.[0-9]*/\n172.1[6-9].[0-9]*.[0-9]*/\n172.2[0-9].[0-9]*.[0-9]*/\n172.3[0-1].[0-9]*.[0-9]*/\n169.254.[0-9]*.[0-9]*/\n::1/\nfc00::/\nfe80::/\nlocalhost/\n";
//string bypassConfig = "{+forward-override{forward .}}\n0.[0-9]*.[0-9]*.[0-9]*/\n10.[0-9]*.[0-9]*.[0-9]*/\n127.[0-9]*.[0-9]*.[0-9]*/\n192.168.[0-9]*.[0-9]*/\n172.1[6-9].[0-9]*.[0-9]*/\n172.2[0-9].[0-9]*.[0-9]*/\n172.3[0-1].[0-9]*.[0-9]*/\n169.254.[0-9]*.[0-9]*/\n::1/\nfc00::/\nfe80::/\nlocalhost/\n";
string bypassConfig = "{+forward-override{forward .}}\n";
if (bypass)
{
string bypass_path = Path.Combine(System.Windows.Forms.Application.StartupPath, PACServer.BYPASS_FILE);
Expand Down
3 changes: 0 additions & 3 deletions shadowsocks-csharp/Controller/Listener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public interface Service
}

Configuration _config;
//bool _buildinHttpProxy;
bool _shareOverLAN;
bool _bypassWhiteList;
string _authUser;
Expand Down Expand Up @@ -67,7 +66,6 @@ public bool isConfigChange(Configuration config)
try
{
if (this._shareOverLAN != config.shareOverLan
//|| _buildinHttpProxy != config.buildinHttpProxy
|| _authUser != config.authUser
|| _authPass != config.authPass
|| _bypassWhiteList != config.bypassWhiteList
Expand All @@ -86,7 +84,6 @@ public void Start(Configuration config, int port)
{
this._config = config;
this._shareOverLAN = config.shareOverLan;
//this._buildinHttpProxy = config.buildinHttpProxy;
this._authUser = config.authUser;
this._authPass = config.authPass;
this._bypassWhiteList = config.bypassWhiteList;
Expand Down
17 changes: 12 additions & 5 deletions shadowsocks-csharp/Controller/Local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,13 @@ public void Start(byte[] firstPacket, int length)
{
State = ConnectState.HANDSHAKE;
remoteHeaderSendBuffer = firstPacket;

detector.OnSend(remoteHeaderSendBuffer, length);
byte[] data = new byte[length];
Array.Copy(remoteHeaderSendBuffer, data, data.Length);
connectionSendBufferList.Add(data);
remoteHeaderSendBuffer = data;

Connect();
}
}
Expand Down Expand Up @@ -1165,14 +1172,14 @@ private void StartPipe()

speedTester.BeginUpload();

//if (remoteHeaderSendBuffer[0] != 1 && remoteHeaderSendBuffer[0] != 3 && remoteHeaderSendBuffer[0] != 4)
//{
// throw new Exception("Wrong header");
//}
// remote ready
if (connectionUDP == null) // TCP
{
detector.OnSend(remoteHeaderSendBuffer, remoteHeaderSendBuffer.Length);
byte[] data = new byte[remoteHeaderSendBuffer.Length];
Array.Copy(remoteHeaderSendBuffer, data, data.Length);
connectionSendBufferList.Add(data);
if (cfg.reconnectTimes > 0)
if (cfg.reconnectTimes > 0 || cfg.targetPort != 0)
{
RemoteSend(remoteHeaderSendBuffer, remoteHeaderSendBuffer.Length);
remoteHeaderSendBuffer = null;
Expand Down
20 changes: 18 additions & 2 deletions shadowsocks-csharp/Controller/ProxyAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private void CloseSocket(ref Socket sock)
private void Close()
{
CloseSocket(ref _connection);
CloseSocket(ref _connectionUDP);
}

bool AuthConnection(Socket connection, string authUser, string authPass)
Expand Down Expand Up @@ -262,7 +263,7 @@ private void HandshakeReceive2Callback()
recv_size = _remoteHeaderSendBuffer[1];
if (recv_size == 0)
throw new Exception("Wrong socks5 addr type");
HandshakeReceive3Callback(recv_size);
HandshakeReceive3Callback(recv_size + 2); // recv port
}
else
{
Expand Down Expand Up @@ -519,9 +520,24 @@ private void Connect()
newFirstPacket[addr.Length + 3] = (byte)(cfg.server_port % 256);
Array.Copy(_firstPacket, 0, newFirstPacket, addr.Length + 4, _firstPacketLength);
_remoteHeaderSendBuffer = newFirstPacket;

handler.Start(_remoteHeaderSendBuffer, _remoteHeaderSendBuffer.Length);
return;
}
}
else
{
if (_connectionUDP == null && new Socks5Forwarder(_config).Handle(_remoteHeaderSendBuffer, _remoteHeaderSendBuffer.Length, _connection))
{
return;
}
else
{
handler.Start(_remoteHeaderSendBuffer, _remoteHeaderSendBuffer.Length);
return;
}
}
handler.Start(_remoteHeaderSendBuffer, _remoteHeaderSendBuffer.Length);
Close();
}
}
}
16 changes: 8 additions & 8 deletions shadowsocks-csharp/Controller/ProxySocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public bool isProtocolSendback
{
get
{
Dictionary<string, int> protocols = new Dictionary<string, int>();
protocols["auth_aes128_sha1"] = 1;
if (protocols.ContainsKey(_protocol.Name()))
{
return true;
}
return false;
//return _protocol.isAlwaysSendback();
//Dictionary<string, int> protocols = new Dictionary<string, int>();
//protocols["auth_aes128_sha1"] = 1;
//if (protocols.ContainsKey(_protocol.Name()))
//{
// return true;
//}
//return false;
return _protocol.isAlwaysSendback();
}
}

Expand Down
21 changes: 11 additions & 10 deletions shadowsocks-csharp/Controller/ShadowsocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class PathEventArgs : EventArgs

public event EventHandler ConfigChanged;
public event EventHandler ToggleModeChanged;
public event EventHandler ToggleRuleModeChanged;
//public event EventHandler ShareOverLANStatusChanged;
public event EventHandler ShowConfigFormEvent;

Expand Down Expand Up @@ -267,23 +268,23 @@ public void ToggleMode(int mode)
}
}

public void ToggleRuleMode(int mode)
{
_config.proxyRuleMode = mode;
SaveConfig(_config);
if (ToggleRuleModeChanged != null)
{
ToggleRuleModeChanged(this, new EventArgs());
}
}

public void ToggleBypass(bool bypass)
{
_config.bypassWhiteList = bypass;
UpdateSystemProxy();
SaveConfig(_config);
}

//public void ToggleShareOverLAN(bool enabled)
//{
// _config.shareOverLan = enabled;
// SaveConfig(_config);
// if (ShareOverLANStatusChanged != null)
// {
// ShareOverLANStatusChanged(this, new EventArgs());
// }
//}

public void ToggleSelectRandom(bool enabled)
{
_config.random = enabled;
Expand Down
Loading

0 comments on commit 1e4b97d

Please sign in to comment.