spare enough space for UDP packet

This commit is contained in:
Syrone Wong
2017-04-08 18:59:39 +08:00
parent 54335d4889
commit 877644609b
3 changed files with 4 additions and 4 deletions
@@ -53,7 +53,7 @@ namespace Shadowsocks.Controller
private Socket _remote;
private Server _server;
private byte[] _buffer = new byte[1500];
private byte[] _buffer = new byte[65536];
private IPEndPoint _localEndPoint;
private IPEndPoint _remoteEndPoint;
@@ -81,7 +81,7 @@ namespace Shadowsocks.Controller
IEncryptor encryptor = EncryptorFactory.GetEncryptor(_server.method, _server.password);
byte[] dataIn = new byte[length - 3];
Array.Copy(data, 3, dataIn, 0, length - 3);
byte[] dataOut = new byte[length - 3 + 16];
byte[] dataOut = new byte[65536]; // enough space for AEAD ciphers
int outlen;
encryptor.EncryptUDP(dataIn, length - 3, dataOut, out outlen);
Logging.Debug(_localEndPoint, _remoteEndPoint, outlen, "UDP Relay");
@@ -18,7 +18,7 @@ namespace Shadowsocks.Encryption.AEAD
private static readonly byte[] InfoBytes = Encoding.ASCII.GetBytes(Info);
// for UDP only
protected static byte[] _udpTmpBuf = new byte[MAX_INPUT_SIZE];
protected static byte[] _udpTmpBuf = new byte[65536];
// every connection should create its own buffer
private CircularBuffer<byte> _encCircularBuffer = new CircularBuffer<byte>(MAX_INPUT_SIZE * 2, false);
@@ -11,7 +11,7 @@ namespace Shadowsocks.Encryption.Stream
: EncryptorBase
{
// for UDP only
protected static byte[] _udpTmpBuf = new byte[MAX_INPUT_SIZE];
protected static byte[] _udpTmpBuf = new byte[65536];
// every connection should create its own buffer
private CircularBuffer<byte> _encCircularBuffer = new CircularBuffer<byte>(TCPHandler.BufferSize * 2, false);