mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
Use pack consistently.
Formatting.
This commit is contained in:
@@ -180,7 +180,7 @@ namespace Renci.SshNet.Abstractions
|
||||
receiveCompleted.Dispose();
|
||||
}
|
||||
#else
|
||||
#error Receiving data from a Socket is not implemented.
|
||||
#error Receiving data from a Socket is not implemented.
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Renci.SshNet.Abstractions
|
||||
if (readToken.Exception != null)
|
||||
throw readToken.Exception;
|
||||
#else
|
||||
#error Receiving data from a Socket is not implemented.
|
||||
#error Receiving data from a Socket is not implemented.
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -407,11 +407,10 @@ namespace Renci.SshNet.Abstractions
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytesSent = socket.Send(data, offset + totalBytesSent, totalBytesToSend - totalBytesSent,
|
||||
SocketFlags.None);
|
||||
var bytesSent = socket.Send(data, offset + totalBytesSent, totalBytesToSend - totalBytesSent, SocketFlags.None);
|
||||
if (bytesSent == 0)
|
||||
throw new SshConnectionException("An established connection was aborted by the server.",
|
||||
DisconnectReason.ConnectionLost);
|
||||
DisconnectReason.ConnectionLost);
|
||||
|
||||
totalBytesSent += bytesSent;
|
||||
}
|
||||
@@ -430,10 +429,10 @@ namespace Renci.SshNet.Abstractions
|
||||
var sendCompleted = new ManualResetEvent(false);
|
||||
var sendReceiveToken = new BlockingSendReceiveToken(socket, data, offset, size, sendCompleted);
|
||||
var socketAsyncSendArgs = new SocketAsyncEventArgs
|
||||
{
|
||||
RemoteEndPoint = socket.RemoteEndPoint,
|
||||
UserToken = sendReceiveToken
|
||||
};
|
||||
{
|
||||
RemoteEndPoint = socket.RemoteEndPoint,
|
||||
UserToken = sendReceiveToken
|
||||
};
|
||||
socketAsyncSendArgs.SetBuffer(data, offset, size);
|
||||
socketAsyncSendArgs.Completed += SendCompleted;
|
||||
|
||||
@@ -450,7 +449,7 @@ namespace Renci.SshNet.Abstractions
|
||||
|
||||
if (sendReceiveToken.TotalBytesTransferred == 0)
|
||||
throw new SshConnectionException("An established connection was aborted by the server.",
|
||||
DisconnectReason.ConnectionLost);
|
||||
DisconnectReason.ConnectionLost);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -460,7 +459,7 @@ namespace Renci.SshNet.Abstractions
|
||||
sendCompleted.Dispose();
|
||||
}
|
||||
#else
|
||||
#error Sending data to a Socket is not implemented.
|
||||
#error Sending data to a Socket is not implemented.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Renci.SshNet
|
||||
return false;
|
||||
}
|
||||
|
||||
var port = (uint)(portBuffer[0] * 256 + portBuffer[1]);
|
||||
var port = Pack.BigEndianToUInt16(portBuffer);
|
||||
|
||||
var ipBuffer = new byte[4];
|
||||
if (SocketAbstraction.Read(socket, ipBuffer, 0, ipBuffer.Length, timeout) == 0)
|
||||
@@ -387,12 +387,12 @@ namespace Renci.SshNet
|
||||
{
|
||||
// no user authentication is one of the authentication methods supported
|
||||
// by the SOCKS client
|
||||
SocketAbstraction.Send(socket, new byte[] { 0x05, 0x00 }, 0, 2);
|
||||
SocketAbstraction.Send(socket, new byte[] {0x05, 0x00}, 0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the SOCKS client requires authentication, which we currently do not support
|
||||
SocketAbstraction.Send(socket, new byte[] { 0x05, 0xFF }, 0, 2);
|
||||
SocketAbstraction.Send(socket, new byte[] {0x05, 0xFF}, 0, 2);
|
||||
|
||||
// we continue business as usual but expect the client to close the connection
|
||||
// so one of the subsequent reads should return -1 signaling that the client
|
||||
@@ -515,19 +515,21 @@ namespace Renci.SshNet
|
||||
|
||||
private static byte[] CreateSocks5Reply(bool channelOpen)
|
||||
{
|
||||
var socksReply = new byte[
|
||||
// SOCKS version
|
||||
1 +
|
||||
// Reply field
|
||||
1 +
|
||||
// Reserved; fixed: 0x00
|
||||
1 +
|
||||
// Address type; fixed: 0x01
|
||||
1 +
|
||||
// IPv4 server bound address; fixed: {0x00, 0x00, 0x00, 0x00}
|
||||
4 +
|
||||
// server bound port; fixed: {0x00, 0x00}
|
||||
2];
|
||||
var socksReply = new byte
|
||||
[
|
||||
// SOCKS version
|
||||
1 +
|
||||
// Reply field
|
||||
1 +
|
||||
// Reserved; fixed: 0x00
|
||||
1 +
|
||||
// Address type; fixed: 0x01
|
||||
1 +
|
||||
// IPv4 server bound address; fixed: {0x00, 0x00, 0x00, 0x00}
|
||||
4 +
|
||||
// server bound port; fixed: {0x00, 0x00}
|
||||
2
|
||||
];
|
||||
|
||||
socksReply[0] = 0x05;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user