Skip to content

Commit 8a9d91d

Browse files
committed
Get rid of WrappedSocket. It's not needed in .NET 4.5+
1 parent 0339b45 commit 8a9d91d

File tree

7 files changed

+8
-273
lines changed

7 files changed

+8
-273
lines changed

shadowsocks-csharp/Controller/Service/PortForwarder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private class Handler
3232
private byte[] _firstPacket;
3333
private int _firstPacketLength;
3434
private Socket _local;
35-
private WrappedSocket _remote;
35+
private Socket _remote;
3636
private bool _closed = false;
3737
private bool _localShutdown = false;
3838
private bool _remoteShutdown = false;
@@ -56,7 +56,7 @@ public void Start(byte[] firstPacket, int length, Socket socket, int targetPort)
5656
EndPoint remoteEP = SocketUtil.GetEndPoint(_local.AddressFamily == AddressFamily.InterNetworkV6 ? "[::1]" : "127.0.0.1", targetPort);
5757

5858
// Connect to the remote endpoint.
59-
_remote = new WrappedSocket();
59+
_remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
6060
_remote.BeginConnect(remoteEP, ConnectCallback, null);
6161
}
6262
catch (Exception e)

shadowsocks-csharp/Proxy/DirectConnect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override string ToString()
3434
}
3535
}
3636

37-
private WrappedSocket _remote = new WrappedSocket();
37+
private Socket _remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
3838

3939
public EndPoint LocalEndPoint => _remote.LocalEndPoint;
4040

shadowsocks-csharp/Proxy/HttpProxy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private class HttpState
4949
public EndPoint DestEndPoint { get; private set; }
5050

5151

52-
private readonly WrappedSocket _remote = new WrappedSocket();
52+
private readonly Socket _remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
5353

5454

5555
public void BeginConnectProxy(EndPoint remoteEP, AsyncCallback callback, object state)

shadowsocks-csharp/Proxy/Socks5Proxy.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading;
66
using Shadowsocks.Controller;
77
using Shadowsocks.Model;
8-
using Shadowsocks.Util.Sockets;
98

109
namespace Shadowsocks.Proxy
1110
{
@@ -42,7 +41,7 @@ private class Socks5State
4241
public Exception ex { get; set; }
4342
}
4443

45-
private readonly WrappedSocket _remote = new WrappedSocket();
44+
private readonly Socket _remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
4645

4746
private const int Socks5PktMaxSize = 4 + 16 + 2;
4847
private readonly byte[] _receiveBuffer = new byte[Socks5PktMaxSize];

shadowsocks-csharp/Util/Sockets/LineReader.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using System;
2+
using System.Net.Sockets;
23
using System.Text;
34

45
namespace Shadowsocks.Util.Sockets
56
{
67
public class LineReader
78
{
8-
private readonly WrappedSocket _socket;
9+
private readonly Socket _socket;
910
private readonly Func<string, object, bool> _onLineRead;
1011
private readonly Action<Exception, object> _onException;
1112
private readonly Action<byte[], int, int, object> _onFinish;
@@ -20,7 +21,7 @@ public class LineReader
2021

2122
private int _bufferIndex;
2223

23-
public LineReader(WrappedSocket socket, Func<string, object, bool> onLineRead, Action<Exception, object> onException,
24+
public LineReader(Socket socket, Func<string, object, bool> onLineRead, Action<Exception, object> onException,
2425
Action<byte[], int, int, object> onFinish, Encoding encoding, string delimiter, int maxLineBytes, object state)
2526
{
2627
if (socket == null)

shadowsocks-csharp/Util/Sockets/WrappedSocket.cs

-264
This file was deleted.

shadowsocks-csharp/shadowsocks-csharp.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@
349349
<Compile Include="Util\ProcessManagement\ThreadUtil.cs" />
350350
<Compile Include="Util\Sockets\LineReader.cs" />
351351
<Compile Include="Util\Sockets\SocketUtil.cs" />
352-
<Compile Include="Util\Sockets\WrappedSocket.cs" />
353352
<Compile Include="Util\SystemProxy\ProxyException.cs" />
354353
<Compile Include="Util\SystemProxy\Sysproxy.cs" />
355354
<Compile Include="Util\Util.cs" />

0 commit comments

Comments
 (0)