Skip to content

Commit

Permalink
Get rid of WrappedSocket. It's not needed in .NET 4.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
notsure2 committed Dec 10, 2023
1 parent 0339b45 commit 8a9d91d
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 273 deletions.
4 changes: 2 additions & 2 deletions shadowsocks-csharp/Controller/Service/PortForwarder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private class Handler
private byte[] _firstPacket;
private int _firstPacketLength;
private Socket _local;
private WrappedSocket _remote;
private Socket _remote;
private bool _closed = false;
private bool _localShutdown = false;
private bool _remoteShutdown = false;
Expand All @@ -56,7 +56,7 @@ public void Start(byte[] firstPacket, int length, Socket socket, int targetPort)
EndPoint remoteEP = SocketUtil.GetEndPoint(_local.AddressFamily == AddressFamily.InterNetworkV6 ? "[::1]" : "127.0.0.1", targetPort);

// Connect to the remote endpoint.
_remote = new WrappedSocket();
_remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
_remote.BeginConnect(remoteEP, ConnectCallback, null);
}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Proxy/DirectConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override string ToString()
}
}

private WrappedSocket _remote = new WrappedSocket();
private Socket _remote = new Socket(SocketType.Stream, ProtocolType.Tcp);

public EndPoint LocalEndPoint => _remote.LocalEndPoint;

Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Proxy/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private class HttpState
public EndPoint DestEndPoint { get; private set; }


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


public void BeginConnectProxy(EndPoint remoteEP, AsyncCallback callback, object state)
Expand Down
3 changes: 1 addition & 2 deletions shadowsocks-csharp/Proxy/Socks5Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading;
using Shadowsocks.Controller;
using Shadowsocks.Model;
using Shadowsocks.Util.Sockets;

namespace Shadowsocks.Proxy
{
Expand Down Expand Up @@ -42,7 +41,7 @@ private class Socks5State
public Exception ex { get; set; }
}

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

private const int Socks5PktMaxSize = 4 + 16 + 2;
private readonly byte[] _receiveBuffer = new byte[Socks5PktMaxSize];
Expand Down
5 changes: 3 additions & 2 deletions shadowsocks-csharp/Util/Sockets/LineReader.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Net.Sockets;
using System.Text;

namespace Shadowsocks.Util.Sockets
{
public class LineReader
{
private readonly WrappedSocket _socket;
private readonly Socket _socket;
private readonly Func<string, object, bool> _onLineRead;
private readonly Action<Exception, object> _onException;
private readonly Action<byte[], int, int, object> _onFinish;
Expand All @@ -20,7 +21,7 @@ public class LineReader

private int _bufferIndex;

public LineReader(WrappedSocket socket, Func<string, object, bool> onLineRead, Action<Exception, object> onException,
public LineReader(Socket socket, Func<string, object, bool> onLineRead, Action<Exception, object> onException,
Action<byte[], int, int, object> onFinish, Encoding encoding, string delimiter, int maxLineBytes, object state)
{
if (socket == null)
Expand Down
264 changes: 0 additions & 264 deletions shadowsocks-csharp/Util/Sockets/WrappedSocket.cs

This file was deleted.

1 change: 0 additions & 1 deletion shadowsocks-csharp/shadowsocks-csharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
<Compile Include="Util\ProcessManagement\ThreadUtil.cs" />
<Compile Include="Util\Sockets\LineReader.cs" />
<Compile Include="Util\Sockets\SocketUtil.cs" />
<Compile Include="Util\Sockets\WrappedSocket.cs" />
<Compile Include="Util\SystemProxy\ProxyException.cs" />
<Compile Include="Util\SystemProxy\Sysproxy.cs" />
<Compile Include="Util\Util.cs" />
Expand Down

0 comments on commit 8a9d91d

Please sign in to comment.