Browse Source

fix udp downlink.

pull/2925/head
Student Main 4 years ago
parent
commit
d04adc10b6
No known key found for this signature in database GPG Key ID: AA78519C208C8742
2 changed files with 4 additions and 3 deletions
  1. +1
    -1
      shadowsocks-csharp/Controller/Service/UDPListener.cs
  2. +3
    -2
      shadowsocks-csharp/Controller/Service/UDPRelay.cs

+ 1
- 1
shadowsocks-csharp/Controller/Service/UDPListener.cs View File

@@ -101,7 +101,7 @@ namespace Shadowsocks.Controller
var len = result.ReceivedBytes; var len = result.ReceivedBytes;
foreach (IDatagramService service in _services) foreach (IDatagramService service in _services)
{ {
if (service.Handle(buffer, len, _udpSocket, remote))
if (service.Handle(buffer, len, _udpSocket, result.RemoteEndPoint))
{ {
break; break;
} }


+ 3
- 2
shadowsocks-csharp/Controller/Service/UDPRelay.cs View File

@@ -46,6 +46,7 @@ namespace Shadowsocks.Controller
} }
// UDPListener.UDPState udpState = (UDPListener.UDPState)state; // UDPListener.UDPState udpState = (UDPListener.UDPState)state;
IPEndPoint remoteEndPoint = (IPEndPoint)state; IPEndPoint remoteEndPoint = (IPEndPoint)state;
// IPEndPoint remoteEndPoint = (IPEndPoint)socket.RemoteEndPoint;
UDPHandler handler = _cache.get(remoteEndPoint); UDPHandler handler = _cache.get(remoteEndPoint);
if (handler == null) if (handler == null)
{ {
@@ -109,7 +110,7 @@ namespace Shadowsocks.Controller
byte[] dataOut = new byte[slicedData.Length + 1000]; byte[] dataOut = new byte[slicedData.Length + 1000];
var dataToSend = slicedData[3..]; var dataToSend = slicedData[3..];
int outlen = encryptor.EncryptUDP(slicedData[3..], dataOut); int outlen = encryptor.EncryptUDP(slicedData[3..], dataOut);
logger.Debug(_localEndPoint, _remoteEndPoint, outlen, "UDP Relay");
logger.Debug(_localEndPoint, _remoteEndPoint, outlen, "UDP Relay up");
_remote?.SendTo(dataOut, outlen, SocketFlags.None, _remoteEndPoint); _remote?.SendTo(dataOut, outlen, SocketFlags.None, _remoteEndPoint);
} }
@@ -137,7 +138,7 @@ namespace Shadowsocks.Controller
byte[] sendBuf = new byte[outlen + 3]; byte[] sendBuf = new byte[outlen + 3];
Array.Copy(dataOut, 0, sendBuf, 3, outlen); Array.Copy(dataOut, 0, sendBuf, 3, outlen);
logger.Debug(_localEndPoint, _remoteEndPoint, outlen, "UDP Relay");
logger.Debug(_remoteEndPoint, _localEndPoint, outlen, "UDP Relay down");
_local?.SendTo(sendBuf, outlen + 3, 0, _localEndPoint); _local?.SendTo(sendBuf, outlen + 3, 0, _localEndPoint);
Receive(); Receive();


Loading…
Cancel
Save