mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 13:39:09 +00:00
Always use "tuning" code.
Avoid some NRE in Dispose.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;FEATURE_RNG_CSP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -26,7 +26,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE</DefineConstants>
|
||||
<DefineConstants>TRACE;FEATURE_RNG_CSP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Renci.SshNet.xml</DocumentationFile>
|
||||
@@ -935,7 +935,7 @@
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
|
||||
<UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -41,7 +41,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_DIAGNOSTICS_TRACESOURCE</DefineConstants>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -910,7 +910,7 @@
|
||||
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
|
||||
<SilverlightProjectProperties />
|
||||
</FlavorProperties>
|
||||
<UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
|
||||
<UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -28,7 +28,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -1271,7 +1271,7 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="c45379b9-17b1-4e89-bc2e-6d41726413e8" />
|
||||
<UserProperties ProjectLinkReference="c45379b9-17b1-4e89-bc2e-6d41726413e8" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
+12
@@ -17,6 +17,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IForwardedPort> _forwardedPortMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelForwardedTcpip _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
@@ -31,6 +32,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
private IList<Socket> _connectedRegister;
|
||||
private IList<Socket> _disconnectedRegister;
|
||||
private Thread _channelThread;
|
||||
private TimeSpan _connectionInfoTimeout;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
@@ -52,6 +54,12 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
if (_channelThread.IsAlive)
|
||||
_channelThread.Abort();
|
||||
_channelThread = null;
|
||||
}
|
||||
if (_channel != null)
|
||||
{
|
||||
_channel.Dispose();
|
||||
_channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +76,18 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
_channelException = null;
|
||||
_connectedRegister = new List<Socket>();
|
||||
_disconnectedRegister = new List<Socket>();
|
||||
_connectionInfoTimeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
_remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.Timeout).Returns(_connectionInfoTimeout);
|
||||
_sessionMock.InSequence(sequence).Setup(
|
||||
p => p.SendMessage(
|
||||
It.Is<ChannelOpenConfirmationMessage>(
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
var target = new ChannelDataMessage();
|
||||
|
||||
Assert.IsNull(target.Data);
|
||||
#if TUNING
|
||||
Assert.AreEqual(0, target.Offset);
|
||||
Assert.AreEqual(0, target.Size);
|
||||
#endif
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -37,10 +35,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
var target = new ChannelDataMessage(localChannelNumber, data);
|
||||
|
||||
Assert.AreSame(data, target.Data);
|
||||
#if TUNING
|
||||
Assert.AreEqual(0, target.Offset);
|
||||
Assert.AreEqual(data.Length, target.Size);
|
||||
#endif
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -61,7 +57,6 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
}
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
[TestMethod]
|
||||
public void Constructor_LocalChannelNumberAndDataAndOffsetAndSize()
|
||||
{
|
||||
@@ -81,7 +76,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
public void Constructor_LocalChannelNumberAndDataAndOffsetAndSize_ShouldThrowArgumentNullExceptionWhenDataIsNull()
|
||||
{
|
||||
var localChannelNumber = (uint) new Random().Next(0, int.MaxValue);
|
||||
byte[] data = null;
|
||||
const byte[] data = null;
|
||||
const int offset = 0;
|
||||
const int size = 0;
|
||||
|
||||
@@ -96,7 +91,6 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
Assert.AreEqual("data", ex.ParamName);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes()
|
||||
@@ -106,17 +100,10 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
var localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
var data = new byte[random.Next(10, 20)];
|
||||
random.NextBytes(data);
|
||||
#if TUNING
|
||||
var offset = random.Next(2, 4);
|
||||
var size = random.Next(5, 9);
|
||||
|
||||
var target = new ChannelDataMessage(localChannelNumber, data, offset, size);
|
||||
#else
|
||||
var offset = 0;
|
||||
var size = data.Length;
|
||||
|
||||
var target = new ChannelDataMessage(localChannelNumber, data);
|
||||
#endif
|
||||
|
||||
var bytes = target.GetBytes();
|
||||
|
||||
@@ -145,28 +132,21 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
{
|
||||
var random = new Random();
|
||||
|
||||
var localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
var localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
var data = new byte[random.Next(10, 20)];
|
||||
random.NextBytes(data);
|
||||
#if TUNING
|
||||
|
||||
var offset = random.Next(2, 4);
|
||||
var size = random.Next(5, 9);
|
||||
var channelDataMessage = new ChannelDataMessage(localChannelNumber, data, offset, size);
|
||||
#else
|
||||
var offset = 0;
|
||||
var size = data.Length;
|
||||
var channelDataMessage = new ChannelDataMessage(localChannelNumber, data);
|
||||
#endif
|
||||
var bytes = channelDataMessage.GetBytes();
|
||||
var target = new ChannelDataMessage();
|
||||
|
||||
target.Load(bytes);
|
||||
|
||||
Assert.IsTrue(target.Data.SequenceEqual(data.Take(offset, size)));
|
||||
#if TUNING
|
||||
Assert.AreEqual(0, target.Offset);
|
||||
Assert.AreEqual(size, target.Size);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -26,9 +26,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
{
|
||||
var target = new ChannelOpenMessage();
|
||||
|
||||
#if TUNING
|
||||
Assert.IsNull(target.ChannelType);
|
||||
#endif
|
||||
Assert.IsNull(target.Info);
|
||||
Assert.AreEqual(default(uint), target.InitialWindowSize);
|
||||
Assert.AreEqual(default(uint), target.LocalChannelNumber);
|
||||
@@ -45,11 +43,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
|
||||
var target = new ChannelOpenMessage(localChannelNumber, initialWindowSize, maximumPacketSize, info);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
|
||||
#else
|
||||
Assert.AreEqual(info.ChannelType, target.ChannelType);
|
||||
#endif
|
||||
Assert.AreSame(info, target.Info);
|
||||
Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
|
||||
Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
|
||||
@@ -105,15 +99,9 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
var actualChannelTypeLength = sshDataStream.ReadUInt32();
|
||||
Assert.AreEqual((uint) target.ChannelType.Length, actualChannelTypeLength);
|
||||
|
||||
#if TUNING
|
||||
var actualChannelType = new byte[actualChannelTypeLength];
|
||||
sshDataStream.Read(actualChannelType, 0, (int) actualChannelTypeLength);
|
||||
Assert.IsTrue(target.ChannelType.SequenceEqual(actualChannelType));
|
||||
#else
|
||||
var actualChannelType = new byte[actualChannelTypeLength];
|
||||
sshDataStream.Read(actualChannelType, 0, (int) actualChannelTypeLength);
|
||||
Assert.AreEqual(target.ChannelType, SshData.Ascii.GetString(actualChannelType));
|
||||
#endif
|
||||
|
||||
Assert.AreEqual(localChannelNumber, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual(initialWindowSize, sshDataStream.ReadUInt32());
|
||||
@@ -138,11 +126,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
|
||||
target.Load(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
|
||||
#else
|
||||
Assert.AreEqual(info.ChannelType, target.ChannelType);
|
||||
#endif
|
||||
Assert.IsNotNull(target.Info);
|
||||
Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
|
||||
Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
|
||||
@@ -169,11 +153,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
|
||||
target.Load(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
|
||||
#else
|
||||
Assert.AreEqual(info.ChannelType, target.ChannelType);
|
||||
#endif
|
||||
Assert.IsNotNull(target.Info);
|
||||
Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
|
||||
Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
|
||||
@@ -200,11 +180,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
|
||||
target.Load(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
|
||||
#else
|
||||
Assert.AreEqual(info.ChannelType, target.ChannelType);
|
||||
#endif
|
||||
Assert.IsNotNull(target.Info);
|
||||
Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
|
||||
Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
|
||||
@@ -228,11 +204,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
|
||||
target.Load(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
|
||||
#else
|
||||
Assert.AreEqual(info.ChannelType, target.ChannelType);
|
||||
#endif
|
||||
Assert.IsNotNull(target.Info);
|
||||
Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
|
||||
Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
|
||||
|
||||
@@ -89,21 +89,12 @@ namespace Renci.SshNet.Tests.Classes
|
||||
for (var i = 0; i < random.Next(1, 3); i++)
|
||||
_pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(-1);
|
||||
_pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0);
|
||||
#if TUNING
|
||||
_channelSessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.SendData(It.Is<byte[]>(b => b.SequenceEqual(_fileContent.Take(_bufferSize))), 0, _bufferSize));
|
||||
_channelSessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.SendData(It.Is<byte[]>(b => b.Take(0, _fileContent.Length - _bufferSize).SequenceEqual(_fileContent.Take(_bufferSize, _fileContent.Length - _bufferSize))), 0, _fileContent.Length - _bufferSize));
|
||||
#else
|
||||
_channelSessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.SendData(It.Is<byte[]>(b => b.SequenceEqual(_fileContent.Take(_bufferSize)))));
|
||||
_channelSessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.SendData(It.Is<byte[]>(b => b.SequenceEqual(_fileContent.Skip(_bufferSize)))));
|
||||
#endif
|
||||
_channelSessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.SendData(It.Is<byte[]>(b => b.SequenceEqual(new byte[] { 0 }))));
|
||||
|
||||
+3
-7
@@ -90,9 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Name length
|
||||
@@ -104,10 +102,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
@@ -115,7 +111,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
|
||||
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
|
||||
|
||||
Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualHandle = new byte[_handle.Length];
|
||||
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
|
||||
|
||||
+5
-9
@@ -75,9 +75,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Name length
|
||||
@@ -91,24 +89,22 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualNameBytes = new byte[_nameBytes.Length];
|
||||
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
|
||||
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
|
||||
|
||||
Assert.AreEqual((uint)_oldPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualOldPath = new byte[_oldPathBytes.Length];
|
||||
sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
|
||||
Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
|
||||
|
||||
Assert.AreEqual((uint)_newPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualNewPath = new byte[_newPathBytes.Length];
|
||||
sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
|
||||
|
||||
+4
-8
@@ -79,9 +79,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Name length
|
||||
@@ -95,24 +93,22 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualNameBytes = new byte[_nameBytes.Length];
|
||||
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
|
||||
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
|
||||
|
||||
Assert.AreEqual((uint)_oldPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualOldPath = new byte[_oldPathBytes.Length];
|
||||
sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
|
||||
Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
|
||||
|
||||
Assert.AreEqual((uint)_newPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualNewPath = new byte[_newPathBytes.Length];
|
||||
sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
|
||||
|
||||
@@ -96,9 +96,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Name length
|
||||
@@ -110,18 +108,16 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualNameBytes = new byte[_nameBytes.Length];
|
||||
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
|
||||
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
|
||||
|
||||
Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
var actualPath = new byte[_pathBytes.Length];
|
||||
sshDataStream.Read(actualPath, 0, actualPath.Length);
|
||||
|
||||
@@ -71,9 +71,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -86,13 +84,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Block, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Block, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
|
||||
var actualHandle = new byte[_handle.Length];
|
||||
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
|
||||
Assert.IsTrue(_handle.SequenceEqual(actualHandle));
|
||||
|
||||
@@ -62,9 +62,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -74,13 +72,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Close, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Close, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
|
||||
var actualHandle = new byte[_handle.Length];
|
||||
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
|
||||
Assert.IsTrue(_handle.SequenceEqual(actualHandle));
|
||||
|
||||
@@ -66,9 +66,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -79,13 +77,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.FSetStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.FSetStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
|
||||
var actualHandle = new byte[_handle.Length];
|
||||
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
|
||||
Assert.IsTrue(_handle.SequenceEqual(actualHandle));
|
||||
|
||||
@@ -84,9 +84,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -96,13 +94,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.FStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.FStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
|
||||
var actualHandle = new byte[_handle.Length];
|
||||
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
|
||||
Assert.IsTrue(_handle.SequenceEqual(actualHandle));
|
||||
|
||||
@@ -90,9 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Pah length
|
||||
@@ -102,10 +100,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.LStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.LStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
@@ -75,9 +75,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // NewLinkPath length
|
||||
@@ -90,10 +88,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Link, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Link, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint) _newLinkPathBytes.Length, sshDataStream.ReadUInt32());
|
||||
@@ -106,7 +102,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
|
||||
Assert.IsTrue(_existingPathBytes.SequenceEqual(actualExistingPath));
|
||||
|
||||
Assert.AreEqual((byte) 1, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(1, sshDataStream.ReadByte());
|
||||
|
||||
Assert.IsTrue(sshDataStream.IsEndOfData);
|
||||
}
|
||||
|
||||
@@ -72,9 +72,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -85,9 +83,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.MkDir, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -90,9 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -102,13 +100,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.OpenDir, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.OpenDir, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
var actualPath = new byte[_pathBytes.Length];
|
||||
sshDataStream.Read(actualPath, 0, actualPath.Length);
|
||||
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
|
||||
|
||||
@@ -110,9 +110,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Filename length
|
||||
@@ -124,13 +122,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.Open, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Open, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_filenameBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _filenameBytes.Length, sshDataStream.ReadUInt32());
|
||||
var actualPath = new byte[_filenameBytes.Length];
|
||||
sshDataStream.Read(actualPath, 0, actualPath.Length);
|
||||
Assert.IsTrue(_filenameBytes.SequenceEqual(actualPath));
|
||||
|
||||
@@ -85,9 +85,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -97,9 +95,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.ReadDir, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -102,9 +102,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -114,9 +112,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.ReadLink, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -104,9 +104,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -118,9 +116,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Read, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -118,9 +118,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -130,10 +128,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte)SftpMessageTypes.RealPath, sshDataStream.ReadByte());
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((byte) SftpMessageTypes.RealPath, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
|
||||
@@ -68,9 +68,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Filename length
|
||||
@@ -80,9 +78,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Remove, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -73,9 +73,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // OldPath length
|
||||
@@ -87,9 +85,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Rename, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -71,9 +71,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -83,9 +81,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.RmDir, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -77,9 +77,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -90,13 +88,11 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.SetStat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
|
||||
var actualPath = new byte[_pathBytes.Length];
|
||||
sshDataStream.Read(actualPath, 0, actualPath.Length);
|
||||
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
|
||||
|
||||
@@ -88,9 +88,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Path length
|
||||
@@ -100,9 +98,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Stat, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -91,9 +91,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // NewLinkPath length
|
||||
@@ -105,9 +103,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.SymLink, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -66,9 +66,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -80,9 +78,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Unblock, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -31,27 +31,17 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
_offset = (ulong) random.Next(0, int.MaxValue);
|
||||
_data = new byte[random.Next(5, 10)];
|
||||
random.NextBytes(_data);
|
||||
#if TUNING
|
||||
_length = random.Next(1, 4);
|
||||
#else
|
||||
_length = _data.Length;
|
||||
#endif
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Constructor()
|
||||
{
|
||||
#if TUNING
|
||||
var request = new SftpWriteRequest(_protocolVersion, _requestId, _handle, _offset, _data, _length, null);
|
||||
#else
|
||||
var request = new SftpWriteRequest(_protocolVersion, _requestId, _handle, _offset, _data, null);
|
||||
#endif
|
||||
|
||||
Assert.AreSame(_data, request.Data);
|
||||
Assert.AreSame(_handle, request.Handle);
|
||||
#if TUNING
|
||||
Assert.AreEqual(_length, request.Length);
|
||||
#endif
|
||||
Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
|
||||
Assert.AreEqual(_requestId, request.RequestId);
|
||||
Assert.AreEqual(SftpMessageTypes.Write, request.SftpMessageType);
|
||||
@@ -70,9 +60,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
_handle,
|
||||
_offset,
|
||||
_data,
|
||||
#if TUNING
|
||||
_length,
|
||||
#endif
|
||||
statusAction);
|
||||
|
||||
request.Complete(statusResponse);
|
||||
@@ -84,18 +72,12 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
[TestMethod]
|
||||
public void GetBytes()
|
||||
{
|
||||
#if TUNING
|
||||
var request = new SftpWriteRequest(_protocolVersion, _requestId, _handle, _offset, _data, _length, null);
|
||||
#else
|
||||
var request = new SftpWriteRequest(_protocolVersion, _requestId, _handle, _offset, _data, null);
|
||||
#endif
|
||||
|
||||
var bytes = request.GetBytes();
|
||||
|
||||
var expectedBytesLength = 0;
|
||||
#if TUNING
|
||||
expectedBytesLength += 4; // Length
|
||||
#endif
|
||||
expectedBytesLength += 1; // Type
|
||||
expectedBytesLength += 4; // RequestId
|
||||
expectedBytesLength += 4; // Handle length
|
||||
@@ -108,9 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
|
||||
var sshDataStream = new SshDataStream(bytes);
|
||||
|
||||
#if TUNING
|
||||
Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
|
||||
#endif
|
||||
Assert.AreEqual((byte) SftpMessageTypes.Write, sshDataStream.ReadByte());
|
||||
Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
|
||||
|
||||
|
||||
@@ -52,12 +52,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
var target = new StatVfsReplyInfo();
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4 + 88);
|
||||
sshDataStream.Write((uint) (sshDataStream.Capacity - 4));
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4 + 88);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte) SftpMessageTypes.ExtendedReply);
|
||||
sshDataStream.Write(_responseId);
|
||||
sshDataStream.Write(_bsize);
|
||||
|
||||
@@ -40,13 +40,9 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
var attributes = CreateSftpFileAttributes();
|
||||
var attributesBytes = attributes.GetBytes();
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4 + attributesBytes.Length);
|
||||
sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4 + attributesBytes.Length);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte)SftpMessageTypes.Attrs);
|
||||
sshDataStream.WriteByte((byte) SftpMessageTypes.Attrs);
|
||||
sshDataStream.Write(_responseId);
|
||||
sshDataStream.Write(attributesBytes, 0, attributesBytes.Length);
|
||||
|
||||
|
||||
@@ -41,12 +41,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
var target = new SftpDataResponse(_protocolVersion);
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4 + _data.Length);
|
||||
sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4 + _data.Length);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte)SftpMessageTypes.Attrs);
|
||||
sshDataStream.Write(_responseId);
|
||||
sshDataStream.Write((uint) _data.Length);
|
||||
|
||||
@@ -36,12 +36,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
var target = new SftpExtendedReplyResponse(_protocolVersion);
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4);
|
||||
sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte) SftpMessageTypes.ExtendedReply);
|
||||
sshDataStream.Write(_responseId);
|
||||
|
||||
@@ -66,12 +62,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
var sid = (ulong) _random.Next(0, int.MaxValue);
|
||||
var namemax = (ulong) _random.Next(0, int.MaxValue);
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4 + 88);
|
||||
sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4 + 88);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte) SftpMessageTypes.Attrs);
|
||||
sshDataStream.Write(_responseId);
|
||||
sshDataStream.Write(bsize);
|
||||
|
||||
@@ -41,12 +41,8 @@ namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
var target = new SftpHandleResponse(_protocolVersion);
|
||||
|
||||
#if TUNING
|
||||
var sshDataStream = new SshDataStream(4 + 1 + 4 + _handle.Length);
|
||||
sshDataStream.Position = 4; // skip 4 bytes for SSH packet length
|
||||
#else
|
||||
var sshDataStream = new SshDataStream(1 + 4 + _handle.Length);
|
||||
#endif
|
||||
sshDataStream.WriteByte((byte) SftpMessageTypes.Handle);
|
||||
sshDataStream.Write(_responseId);
|
||||
sshDataStream.Write((uint) _handle.Length);
|
||||
|
||||
+1
-3
@@ -16,7 +16,6 @@ namespace Renci.SshNet.Tests.Classes
|
||||
private string _commandText;
|
||||
private Encoding _encoding;
|
||||
private SshCommand _sshCommand;
|
||||
private IAsyncResult _asyncResult;
|
||||
private InvalidOperationException _actualException;
|
||||
|
||||
protected override void OnInit()
|
||||
@@ -35,12 +34,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
_channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
|
||||
_commandText = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_encoding = Encoding.UTF8;
|
||||
_asyncResult = null;
|
||||
|
||||
var seq = new MockSequence();
|
||||
_sessionMock.InSequence(seq).Setup(p => p.CreateChannelSession()).Returns(_channelSessionMock.Object);
|
||||
_channelSessionMock.InSequence(seq).Setup(p => p.Open());
|
||||
_channelSessionMock.InSequence(seq).Setup(p => p.SendExecRequest(_commandText));
|
||||
_channelSessionMock.InSequence(seq).Setup(p => p.SendExecRequest(_commandText)).Returns(true);
|
||||
|
||||
_sshCommand = new SshCommand(_sessionMock.Object, _commandText, _encoding);
|
||||
_sshCommand.BeginExecute();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -26,7 +26,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -23,24 +23,26 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\Renci.SshNet.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Renci.SshNet.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
@@ -50,7 +52,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -62,7 +64,7 @@
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_SOCKET_EAP;FEATURE_DATAGRAMSOCKET;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
@@ -72,7 +74,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -84,7 +86,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
@@ -94,7 +96,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_RNG_CREATE;FEATURE_SOCKET_EAP;FEATURE_SOCKET_POLL;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_HASH_MD5;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>TRACE;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWS_PHONE;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_DEVICEINFORMATION_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWS_PHONE;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_DEVICEINFORMATION_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -35,7 +35,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS_PHONE;TUNING;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_DEVICEINFORMATION_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<DefineConstants>TRACE;WINDOWS_PHONE;FEATURE_RNG_CSP;FEATURE_SOCKET_EAP;FEATURE_STREAM_APM;FEATURE_DEVICEINFORMATION_APM;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -928,7 +928,7 @@
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
|
||||
<UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Renci.SshNet
|
||||
private bool _isDisposed;
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged ResourceMessages.
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -324,22 +324,22 @@ namespace Renci.SshNet
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Disconnect();
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
if (_ownsConnectionInfo && _connectionInfo != null)
|
||||
{
|
||||
var connectionInfoDisposable = _connectionInfo as IDisposable;
|
||||
if (connectionInfoDisposable != null)
|
||||
connectionInfoDisposable.Dispose();
|
||||
_connectionInfo = null;
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
Disconnect();
|
||||
|
||||
if (_ownsConnectionInfo && _connectionInfo != null)
|
||||
{
|
||||
var connectionInfoDisposable = _connectionInfo as IDisposable;
|
||||
if (connectionInfoDisposable != null)
|
||||
connectionInfoDisposable.Dispose();
|
||||
_connectionInfo = null;
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
@@ -362,9 +362,6 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
~BaseClient()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -292,14 +292,9 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="data">The payload to send.</param>
|
||||
public void SendData(byte[] data)
|
||||
{
|
||||
#if TUNING
|
||||
SendData(data, 0, data.Length);
|
||||
#else
|
||||
SendMessage(new ChannelDataMessage(RemoteChannelNumber, data));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Sends a SSH_MSG_CHANNEL_DATA message with the specified payload.
|
||||
/// </summary>
|
||||
@@ -340,7 +335,6 @@ namespace Renci.SshNet.Channels
|
||||
offset += sizeOfCurrentMessage;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Closes the channel.
|
||||
@@ -495,55 +489,6 @@ namespace Renci.SshNet.Channels
|
||||
_session.SendMessage(message);
|
||||
}
|
||||
|
||||
#if !TUNING
|
||||
/// <summary>
|
||||
/// Sends channel data message to the servers.
|
||||
/// </summary>
|
||||
/// <param name="message">Channel data message.</param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// When the data of the message exceeds the maximum packet size or the remote window
|
||||
/// size does not allow the full message to be sent, then this method will send the
|
||||
/// data in multiple chunks and will only wait for the remote window size to be adjusted
|
||||
/// when its zero.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This is done to support SSH servers will a small window size that do not agressively
|
||||
/// increase their window size. We need to take into account that there may be SSH
|
||||
/// servers that only increase their window size when it has reached zero.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
protected void SendMessage(ChannelDataMessage message)
|
||||
{
|
||||
// send channel messages only while channel is open
|
||||
if (!IsOpen)
|
||||
return;
|
||||
|
||||
var totalDataLength = message.Data.Length;
|
||||
var totalDataSent = 0;
|
||||
|
||||
var totalBytesToSend = totalDataLength;
|
||||
while (totalBytesToSend > 0)
|
||||
{
|
||||
var dataThatCanBeSentInMessage = GetDataLengthThatCanBeSentInMessage(totalBytesToSend);
|
||||
if (dataThatCanBeSentInMessage == totalDataLength)
|
||||
{
|
||||
// we can send the message in one chunk
|
||||
_session.SendMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we need to send the message in multiple chunks
|
||||
var dataToSend = new byte[dataThatCanBeSentInMessage];
|
||||
Array.Copy(message.Data, totalDataSent, dataToSend, 0, dataThatCanBeSentInMessage);
|
||||
_session.SendMessage(new ChannelDataMessage(message.LocalChannelNumber, dataToSend));
|
||||
}
|
||||
totalDataSent += dataThatCanBeSentInMessage;
|
||||
totalBytesToSend -= dataThatCanBeSentInMessage;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Sends a SSH_MSG_CHANNEL_EOF message to the remote server.
|
||||
/// </summary>
|
||||
|
||||
@@ -94,11 +94,7 @@ namespace Renci.SshNet.Channels
|
||||
var read = SocketAbstraction.ReadPartial(_socket, buffer, 0, buffer.Length, ConnectionInfo.Timeout);
|
||||
if (read > 0)
|
||||
{
|
||||
#if TUNING
|
||||
SendData(buffer, 0, read);
|
||||
#else
|
||||
SendMessage(new ChannelDataMessage(RemoteChannelNumber, buffer.Take(read).ToArray()));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -183,9 +179,10 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="wait"><c>true</c> to wait for the SSH_MSG_CHANNEL_CLOSE message to be received from the server; otherwise, <c>false</c>.</param>
|
||||
protected override void Close(bool wait)
|
||||
{
|
||||
if (_forwardedPort != null)
|
||||
var forwardedPort = _forwardedPort;
|
||||
if (forwardedPort != null)
|
||||
{
|
||||
_forwardedPort.Closing -= ForwardedPort_Closing;
|
||||
forwardedPort.Closing -= ForwardedPort_Closing;
|
||||
_forwardedPort = null;
|
||||
}
|
||||
|
||||
@@ -313,15 +310,17 @@ namespace Renci.SshNet.Channels
|
||||
}
|
||||
}
|
||||
|
||||
if (_channelOpen != null)
|
||||
var channelOpen = _channelOpen;
|
||||
if (channelOpen != null)
|
||||
{
|
||||
_channelOpen.Dispose();
|
||||
channelOpen.Dispose();
|
||||
_channelOpen = null;
|
||||
}
|
||||
|
||||
if (_channelData != null)
|
||||
var channelData = _channelData;
|
||||
if (channelData != null)
|
||||
{
|
||||
_channelData.Dispose();
|
||||
channelData.Dispose();
|
||||
_channelData = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,17 +80,13 @@ namespace Renci.SshNet.Channels
|
||||
|
||||
// Start reading data from the port and send to channel
|
||||
while (_socket != null && _socket.Connected)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
var read = SocketAbstraction.ReadPartial(_socket, buffer, 0, buffer.Length, ConnectionInfo.Timeout);
|
||||
if (read > 0)
|
||||
{
|
||||
#if TUNING
|
||||
SendData(buffer, 0, read);
|
||||
#else
|
||||
SendMessage(new ChannelDataMessage(RemoteChannelNumber, buffer.Take(read).ToArray()));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -100,9 +96,7 @@ namespace Renci.SshNet.Channels
|
||||
}
|
||||
catch (SocketException exp)
|
||||
{
|
||||
if (exp.SocketErrorCode == SocketError.WouldBlock ||
|
||||
exp.SocketErrorCode == SocketError.IOPending ||
|
||||
exp.SocketErrorCode == SocketError.NoBufferSpaceAvailable)
|
||||
if (SocketAbstraction.IsErrorResumable(exp.SocketErrorCode))
|
||||
{
|
||||
// socket buffer is probably empty, wait and try again
|
||||
ThreadAbstraction.Sleep(30);
|
||||
@@ -151,10 +145,11 @@ namespace Renci.SshNet.Channels
|
||||
|
||||
lock (_socketShutdownAndCloseLock)
|
||||
{
|
||||
if (_socket == null || !_socket.Connected)
|
||||
var socket = _socket;
|
||||
if (socket == null || !socket.Connected)
|
||||
return;
|
||||
|
||||
_socket.Shutdown(how);
|
||||
socket.Shutdown(how);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +163,14 @@ namespace Renci.SshNet.Channels
|
||||
|
||||
lock (_socketShutdownAndCloseLock)
|
||||
{
|
||||
if (_socket == null)
|
||||
return;
|
||||
|
||||
// closing a socket actually disposes the socket, so we can safely dereference
|
||||
// the field to avoid entering the lock again later
|
||||
_socket.Dispose();
|
||||
_socket = null;
|
||||
var socket = _socket;
|
||||
if (socket != null)
|
||||
{
|
||||
// closing a socket actually disposes the socket, so we can safely dereference
|
||||
// the field to avoid entering the lock again later
|
||||
socket.Dispose();
|
||||
_socket = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +181,10 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="wait"><c>true</c> to wait for the SSH_MSG_CHANNEL_CLOSE message to be received from the server; otherwise, <c>false</c>.</param>
|
||||
protected override void Close(bool wait)
|
||||
{
|
||||
if (_forwardedPort != null)
|
||||
var forwardedPort = _forwardedPort;
|
||||
if (forwardedPort != null)
|
||||
{
|
||||
_forwardedPort.Closing -= ForwardedPort_Closing;
|
||||
forwardedPort.Closing -= ForwardedPort_Closing;
|
||||
_forwardedPort = null;
|
||||
}
|
||||
|
||||
@@ -212,27 +209,10 @@ namespace Renci.SshNet.Channels
|
||||
{
|
||||
base.OnData(data);
|
||||
|
||||
if (_socket != null && _socket.Connected)
|
||||
SocketAbstraction.Send(_socket, data, 0, data.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// make sure we've unsubscribed from all session events and closed the channel
|
||||
// before we starting disposing
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
var socket = _socket;
|
||||
if (socket != null && socket.Connected)
|
||||
{
|
||||
if (_socket != null)
|
||||
{
|
||||
_socket.Dispose();
|
||||
_socket = null;
|
||||
}
|
||||
SocketAbstraction.Send(socket, data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Renci.SshNet.Channels
|
||||
public event EventHandler<ChannelOpenConfirmedEventArgs> OpenConfirmed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when <see cref="ChannelOpenFailureMessage"/> message received
|
||||
/// Occurs when <see cref="ChannelOpenFailureMessage"/> message is received.
|
||||
/// </summary>
|
||||
public event EventHandler<ChannelOpenFailedEventArgs> OpenFailed;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Renci.SshNet.Channels
|
||||
{
|
||||
InitializeRemoteInfo(remoteChannelNumber, initialWindowSize, maximumPacketSize);
|
||||
|
||||
// Channel is consider to be open when confirmation message was received
|
||||
// Channel is consider to be open when confirmation message was received
|
||||
IsOpen = true;
|
||||
|
||||
var openConfirmed = OpenConfirmed;
|
||||
@@ -83,7 +83,6 @@ namespace Renci.SshNet.Channels
|
||||
{
|
||||
OnChannelException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="data">The payload to send.</param>
|
||||
void SendData(byte[] data);
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Sends a SSH_MSG_CHANNEL_DATA message with the specified payload.
|
||||
/// </summary>
|
||||
@@ -99,7 +98,6 @@ namespace Renci.SshNet.Channels
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
void SendData(byte[] data, int offset, int size);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Sends a SSH_MSG_CHANNEL_EOF message to the remote server.
|
||||
|
||||
@@ -1964,11 +1964,7 @@ namespace Renci.SshNet.Common
|
||||
var bytesArray = new byte[bitLength / 8 + (((bitLength % 8) > 0) ? 1 : 0)];
|
||||
HashAlgorithmFactory.GenerateRandom(bytesArray);
|
||||
bytesArray[bytesArray.Length - 1] = (byte)(bytesArray[bytesArray.Length - 1] & 0x7F); // Ensure not a negative value
|
||||
#if TUNING
|
||||
return new BigInteger(bytesArray);
|
||||
#else
|
||||
return new BigInteger(bytesArray.ToArray());
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -108,11 +108,7 @@ namespace Renci.SshNet.Common
|
||||
|
||||
var data = ReadBytes(length);
|
||||
|
||||
#if TUNING
|
||||
return new BigInteger(data.Reverse());
|
||||
#else
|
||||
return new BigInteger(data.Reverse().ToArray());
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -175,13 +171,9 @@ namespace Renci.SshNet.Common
|
||||
/// <param name="data">BigInteger data to write.</param>
|
||||
public void Write(BigInteger data)
|
||||
{
|
||||
#if TUNING
|
||||
var bytes = data.ToByteArray().Reverse().ToList();
|
||||
#else
|
||||
var bytes = data.ToByteArray().Reverse().ToList();
|
||||
#endif
|
||||
var bytes = data.ToByteArray().Reverse();
|
||||
_data.Add(Integer);
|
||||
var length = GetLength(bytes.Count);
|
||||
var length = GetLength(bytes.Length);
|
||||
WriteBytes(length);
|
||||
WriteBytes(bytes);
|
||||
}
|
||||
|
||||
@@ -85,14 +85,12 @@ namespace Renci.SshNet.Common
|
||||
}
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
internal static BigInteger ToBigInteger(this byte[] data)
|
||||
{
|
||||
var reversed = new byte[data.Length];
|
||||
Buffer.BlockCopy(data, 0, reversed, 0, data.Length);
|
||||
return new BigInteger(reversed.Reverse());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reverses the sequence of the elements in the entire one-dimensional <see cref="Array"/>.
|
||||
@@ -219,7 +217,7 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 2.</returns>
|
||||
internal static byte[] GetBytes(this UInt16 value)
|
||||
internal static byte[] GetBytes(this ushort value)
|
||||
{
|
||||
return new[] {(byte) (value >> 8), (byte) (value & 0xFF)};
|
||||
}
|
||||
@@ -229,15 +227,11 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 4.</returns>
|
||||
internal static byte[] GetBytes(this UInt32 value)
|
||||
internal static byte[] GetBytes(this uint value)
|
||||
{
|
||||
#if TUNING
|
||||
var buffer = new byte[4];
|
||||
value.Write(buffer, 0);
|
||||
return buffer;
|
||||
#else
|
||||
return new[] {(byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) (value & 0xFF)};
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,7 +253,7 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 8.</returns>
|
||||
internal static byte[] GetBytes(this UInt64 value)
|
||||
internal static byte[] GetBytes(this ulong value)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
@@ -273,7 +267,7 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="value">The number to convert.</param>
|
||||
/// <returns>An array of bytes with length 8.</returns>
|
||||
internal static byte[] GetBytes(this Int64 value)
|
||||
internal static byte[] GetBytes(this long value)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if !TUNING
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
|
||||
namespace Renci.SshNet.Common
|
||||
@@ -17,44 +14,29 @@ namespace Renci.SshNet.Common
|
||||
internal static readonly Encoding Ascii = new ASCIIEncoding();
|
||||
internal static readonly Encoding Utf8 = Encoding.UTF8;
|
||||
|
||||
#if TUNING
|
||||
private SshDataStream _stream;
|
||||
|
||||
protected SshDataStream DataStream
|
||||
{
|
||||
get { return _stream; }
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Data byte array that hold message unencrypted data
|
||||
/// </summary>
|
||||
private List<byte> _data;
|
||||
|
||||
private int _readerIndex;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether all data from the buffer has been read.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is end of data; otherwise, <c>false</c>.
|
||||
/// <c>true</c> if this instance is end of data; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
protected bool IsEndOfData
|
||||
{
|
||||
get
|
||||
{
|
||||
#if TUNING
|
||||
return _stream.Position >= _stream.Length;
|
||||
#else
|
||||
return _readerIndex >= _data.Count();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] _loadedData;
|
||||
#if TUNING
|
||||
private int _offset;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index that represents zero in current data type.
|
||||
@@ -70,7 +52,6 @@ namespace Renci.SshNet.Common
|
||||
}
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -81,34 +62,20 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets data bytes array
|
||||
/// </summary>
|
||||
/// <returns>Byte array representation of data structure.</returns>
|
||||
public
|
||||
#if !TUNING
|
||||
virtual
|
||||
#endif
|
||||
byte[] GetBytes()
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
#if TUNING
|
||||
var messageLength = BufferCapacity;
|
||||
var capacity = messageLength != -1 ? messageLength : DefaultCapacity;
|
||||
var dataStream = new SshDataStream(capacity);
|
||||
WriteBytes(dataStream);
|
||||
return dataStream.ToArray();
|
||||
#else
|
||||
_data = new List<byte>();
|
||||
|
||||
SaveData();
|
||||
|
||||
return _data.ToArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Writes the current message to the specified <see cref="SshDataStream"/>.
|
||||
/// </summary>
|
||||
@@ -118,16 +85,11 @@ namespace Renci.SshNet.Common
|
||||
_stream = stream;
|
||||
SaveData();
|
||||
}
|
||||
#endif
|
||||
|
||||
internal T OfType<T>() where T : SshData, new()
|
||||
{
|
||||
var result = new T();
|
||||
#if TUNING
|
||||
result.LoadBytes(_loadedData, _offset);
|
||||
#else
|
||||
result.LoadBytes(_loadedData);
|
||||
#endif
|
||||
result.LoadData();
|
||||
return result;
|
||||
}
|
||||
@@ -139,18 +101,9 @@ namespace Renci.SshNet.Common
|
||||
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
|
||||
public void Load(byte[] value)
|
||||
{
|
||||
#if TUNING
|
||||
Load(value, 0);
|
||||
#else
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
LoadBytes(value);
|
||||
LoadData();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Loads data from the specified buffer.
|
||||
/// </summary>
|
||||
@@ -162,7 +115,6 @@ namespace Renci.SshNet.Common
|
||||
LoadBytes(value, offset);
|
||||
LoadData();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
@@ -181,21 +133,9 @@ namespace Renci.SshNet.Common
|
||||
/// <exception cref="ArgumentNullException"><paramref name="bytes"/> is null.</exception>
|
||||
protected void LoadBytes(byte[] bytes)
|
||||
{
|
||||
#if TUNING
|
||||
LoadBytes(bytes, 0);
|
||||
#else
|
||||
// Note about why I check for null here, and in Load(byte[]) in this class.
|
||||
// This method is called by several other classes, such as SshNet.Messages.Message, SshNet.Sftp.SftpMessage.
|
||||
if (bytes == null)
|
||||
throw new ArgumentNullException("bytes");
|
||||
|
||||
ResetReader();
|
||||
_loadedData = bytes;
|
||||
_data = new List<byte>(bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Loads data bytes into internal buffer.
|
||||
/// </summary>
|
||||
@@ -213,49 +153,25 @@ namespace Renci.SshNet.Common
|
||||
_stream = new SshDataStream(bytes);
|
||||
ResetReader();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Resets internal data reader index.
|
||||
/// </summary>
|
||||
protected void ResetReader()
|
||||
{
|
||||
#if TUNING
|
||||
_stream.Position = ZeroReaderIndex + _offset;
|
||||
#else
|
||||
_readerIndex = ZeroReaderIndex; // Set to 1 to skip first byte which specifies message type
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TUNING
|
||||
/// <summary>
|
||||
/// Reads next mpint data type from internal buffer.
|
||||
/// </summary>
|
||||
/// <returns>mpint read.</returns>
|
||||
protected BigInteger ReadBigInt()
|
||||
{
|
||||
var length = this.ReadUInt32();
|
||||
var data = this.ReadBytes((int)length);
|
||||
return new BigInteger(data.Reverse().ToArray());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads all data left in internal buffer at current position.
|
||||
/// </summary>
|
||||
/// <returns>An array of bytes containing the remaining data in the internal buffer.</returns>
|
||||
protected byte[] ReadBytes()
|
||||
{
|
||||
#if TUNING
|
||||
var bytesLength = (int) (_stream.Length - _stream.Position);
|
||||
var data = new byte[bytesLength];
|
||||
_stream.Read(data, 0, bytesLength);
|
||||
return data;
|
||||
#else
|
||||
var data = new byte[_data.Count - _readerIndex];
|
||||
_data.CopyTo(_readerIndex, data, 0, data.Length);
|
||||
return data;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -270,7 +186,6 @@ namespace Renci.SshNet.Common
|
||||
// For the nerds, the condition translates to: if (length > data.Count && length < int.MaxValue)
|
||||
// Which probably would cause all sorts of exception, most notably OutOfMemoryException.
|
||||
|
||||
#if TUNING
|
||||
var data = new byte[length];
|
||||
var bytesRead = _stream.Read(data, 0, length);
|
||||
|
||||
@@ -278,15 +193,6 @@ namespace Renci.SshNet.Common
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
|
||||
return data;
|
||||
#else
|
||||
if (length > _data.Count)
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
|
||||
var result = new byte[length];
|
||||
_data.CopyTo(_readerIndex, result, 0, length);
|
||||
_readerIndex += length;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -295,14 +201,10 @@ namespace Renci.SshNet.Common
|
||||
/// <returns>Byte read.</returns>
|
||||
protected byte ReadByte()
|
||||
{
|
||||
#if TUNING
|
||||
var byteRead = _stream.ReadByte();
|
||||
if (byteRead == -1)
|
||||
throw new InvalidOperationException("Attempt to read past the end of the SSH data stream.");
|
||||
return (byte) byteRead;
|
||||
#else
|
||||
return ReadBytes(1).FirstOrDefault();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -344,23 +246,6 @@ namespace Renci.SshNet.Common
|
||||
return ((ulong)data[0] << 56 | (ulong)data[1] << 48 | (ulong)data[2] << 40 | (ulong)data[3] << 32 | (ulong)data[4] << 24 | (ulong)data[5] << 16 | (ulong)data[6] << 8 | data[7]);
|
||||
}
|
||||
|
||||
#if !TUNING
|
||||
/// <summary>
|
||||
/// Reads next string data type from internal buffer.
|
||||
/// </summary>
|
||||
/// <returns>string read</returns>
|
||||
protected string ReadAsciiString()
|
||||
{
|
||||
var length = ReadUInt32();
|
||||
|
||||
if (length > int.MaxValue)
|
||||
{
|
||||
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue));
|
||||
}
|
||||
return Ascii.GetString(ReadBytes((int)length), 0, (int)length);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads next string data type from internal buffer using the specific encoding.
|
||||
/// </summary>
|
||||
@@ -369,20 +254,9 @@ namespace Renci.SshNet.Common
|
||||
/// </returns>
|
||||
protected string ReadString(Encoding encoding)
|
||||
{
|
||||
#if TUNING
|
||||
return _stream.ReadString(encoding);
|
||||
#else
|
||||
var length = ReadUInt32();
|
||||
|
||||
if (length > int.MaxValue)
|
||||
{
|
||||
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue));
|
||||
}
|
||||
return encoding.GetString(ReadBytes((int)length), 0, (int)length);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Reads next data type as byte array from internal buffer.
|
||||
/// </summary>
|
||||
@@ -393,28 +267,13 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
return _stream.ReadBinary();
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Reads next string data type from internal buffer.
|
||||
/// </summary>
|
||||
/// <returns>string read</returns>
|
||||
protected byte[] ReadBinaryString()
|
||||
{
|
||||
var length = ReadUInt32();
|
||||
|
||||
if (length > int.MaxValue)
|
||||
{
|
||||
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue));
|
||||
}
|
||||
|
||||
return ReadBytes((int)length);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads next name-list data type from internal buffer.
|
||||
/// </summary>
|
||||
/// <returns>String array or read data..</returns>
|
||||
/// <returns>
|
||||
/// String array or read data.
|
||||
/// </returns>
|
||||
protected string[] ReadNamesList()
|
||||
{
|
||||
var namesList = ReadString(Ascii);
|
||||
@@ -437,7 +296,6 @@ namespace Renci.SshNet.Common
|
||||
return result;
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Writes bytes array data into internal buffer.
|
||||
/// </summary>
|
||||
@@ -447,19 +305,7 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
_stream.Write(data);
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes bytes array data into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array data to write.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
|
||||
protected void Write(IEnumerable<byte> data)
|
||||
{
|
||||
_data.AddRange(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Writes a sequence of bytes to the current SSH data stream and advances the current position
|
||||
/// within this stream by the number of bytes written.
|
||||
@@ -474,71 +320,47 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
_stream.Write(buffer, offset, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes byte data into internal buffer.
|
||||
/// Writes <see cref="byte"/> data into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">Byte data to write.</param>
|
||||
/// <param name="data"><see cref="byte"/> data to write.</param>
|
||||
protected void Write(byte data)
|
||||
{
|
||||
#if TUNING
|
||||
_stream.WriteByte(data);
|
||||
#else
|
||||
_data.Add(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes boolean data into internal buffer.
|
||||
/// Writes <see cref="bool"/> into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">Boolean data to write.</param>
|
||||
/// <param name="data"><see cref="bool" /> data to write.</param>
|
||||
protected void Write(bool data)
|
||||
{
|
||||
Write(data ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes uint32 data into internal buffer.
|
||||
/// Writes <see cref="uint"/> data into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">uint32 data to write.</param>
|
||||
/// <param name="data"><see cref="uint"/> data to write.</param>
|
||||
protected void Write(uint data)
|
||||
{
|
||||
#if TUNING
|
||||
_stream.Write(data);
|
||||
#else
|
||||
Write(data.GetBytes());
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes uint64 data into internal buffer.
|
||||
/// Writes <see cref="ulong" /> data into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">uint64 data to write.</param>
|
||||
/// <param name="data"><see cref="ulong"/> data to write.</param>
|
||||
protected void Write(ulong data)
|
||||
{
|
||||
#if TUNING
|
||||
_stream.Write(data);
|
||||
#else
|
||||
Write(data.GetBytes());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TUNING
|
||||
/// <summary>
|
||||
/// Writes string data into internal buffer as ASCII.
|
||||
/// Writes <see cref="string"/> data into internal buffer using default encoding.
|
||||
/// </summary>
|
||||
/// <param name="data">string data to write.</param>
|
||||
protected void WriteAscii(string data)
|
||||
{
|
||||
Write(data, Ascii);
|
||||
}
|
||||
#endif // !TUNING
|
||||
|
||||
/// <summary>
|
||||
/// Writes string data into internal buffer using default encoding.
|
||||
/// </summary>
|
||||
/// <param name="data">string data to write.</param>
|
||||
/// <param name="data"><see cref="string"/> data to write.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
|
||||
protected void Write(string data)
|
||||
{
|
||||
@@ -546,30 +368,17 @@ namespace Renci.SshNet.Common
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes string data into internal buffer using the specified encoding.
|
||||
/// Writes <see cref="string"/> data into internal buffer using the specified encoding.
|
||||
/// </summary>
|
||||
/// <param name="data">string data to write.</param>
|
||||
/// <param name="data"><see cref="string"/> data to write.</param>
|
||||
/// <param name="encoding">The character encoding to use.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="encoding"/> is null.</exception>
|
||||
protected void Write(string data, Encoding encoding)
|
||||
{
|
||||
#if TUNING
|
||||
_stream.Write(data, encoding);
|
||||
#else
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
if (encoding == null)
|
||||
throw new ArgumentNullException("encoding");
|
||||
|
||||
var bytes = encoding.GetBytes(data);
|
||||
|
||||
Write((uint)bytes.Length);
|
||||
Write(bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Writes data into internal buffer.
|
||||
/// </summary>
|
||||
@@ -593,21 +402,6 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
_stream.WriteBinary(buffer, offset, count);
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes string data into internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">string data to write.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
|
||||
protected void WriteBinaryString(byte[] data)
|
||||
{
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
|
||||
Write((uint)data.Length);
|
||||
_data.AddRange(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes mpint data into internal buffer.
|
||||
@@ -615,13 +409,7 @@ namespace Renci.SshNet.Common
|
||||
/// <param name="data">mpint data to write.</param>
|
||||
protected void Write(BigInteger data)
|
||||
{
|
||||
#if TUNING
|
||||
_stream.Write(data);
|
||||
#else
|
||||
var bytes = data.ToByteArray().Reverse().ToList();
|
||||
Write((uint)bytes.Count);
|
||||
Write(bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -197,7 +197,9 @@ namespace Renci.SshNet.Common
|
||||
/// Reads next specified number of bytes data type from internal buffer.
|
||||
/// </summary>
|
||||
/// <param name="length">Number of bytes to read.</param>
|
||||
/// <returns>An array of bytes that was read from the internal buffer.</returns>
|
||||
/// <returns>
|
||||
/// An array of bytes that was read from the internal buffer.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length"/> is greater than the internal buffer size.</exception>
|
||||
private byte[] ReadBytes(int length)
|
||||
{
|
||||
|
||||
@@ -132,56 +132,49 @@ namespace Renci.SshNet.Compression
|
||||
private bool _isDisposed;
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged ResourceMessages.
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if (!_isDisposed)
|
||||
{
|
||||
// If disposing equals true, dispose all managed
|
||||
// and unmanaged ResourceMessages.
|
||||
if (disposing)
|
||||
{
|
||||
// Dispose managed ResourceMessages.
|
||||
if (_compressorStream != null)
|
||||
{
|
||||
_compressorStream.Dispose();
|
||||
_compressorStream = null;
|
||||
}
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
if (_decompressorStream != null)
|
||||
{
|
||||
_decompressorStream.Dispose();
|
||||
_decompressorStream = null;
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
var compressorStream = _compressorStream;
|
||||
if (compressorStream != null)
|
||||
{
|
||||
compressorStream.Dispose();
|
||||
_compressorStream = null;
|
||||
}
|
||||
|
||||
var decompressorStream = _decompressorStream;
|
||||
if (decompressorStream != null)
|
||||
{
|
||||
decompressorStream.Dispose();
|
||||
_decompressorStream = null;
|
||||
}
|
||||
|
||||
// Note disposing has been done.
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the
|
||||
/// <see cref="SshCommand"/> is reclaimed by garbage collection.
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the <see cref="Compressor"/> is reclaimed
|
||||
/// by garbage collection.
|
||||
/// </summary>
|
||||
~Compressor()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Renci.SshNet
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Renci.SshNet
|
||||
private bool _isDisposed;
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged ResourceMessages.
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -126,37 +126,35 @@ namespace Renci.SshNet
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
var listenerCompleted = _listenerCompleted;
|
||||
if (listenerCompleted != null)
|
||||
{
|
||||
if (_listenerCompleted != null)
|
||||
{
|
||||
_listenerCompleted.Dispose();
|
||||
_listenerCompleted = null;
|
||||
}
|
||||
listenerCompleted.Dispose();
|
||||
_listenerCompleted = null;
|
||||
}
|
||||
|
||||
InternalDispose(disposing);
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
InternalDispose(disposing);
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the
|
||||
/// <see cref="ForwardedPortLocal"/> is reclaimed by garbage collection.
|
||||
/// <see cref="ForwardedPortDynamic"/> is reclaimed by garbage collection.
|
||||
/// </summary>
|
||||
~ForwardedPortDynamic()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,26 +168,27 @@ namespace Renci.SshNet
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
var listenerTaskCompleted = _listenerTaskCompleted;
|
||||
if (listenerTaskCompleted != null)
|
||||
{
|
||||
if (_listenerTaskCompleted != null)
|
||||
{
|
||||
_listenerTaskCompleted.Dispose();
|
||||
_listenerTaskCompleted = null;
|
||||
}
|
||||
listenerTaskCompleted.Dispose();
|
||||
_listenerTaskCompleted = null;
|
||||
}
|
||||
|
||||
InternalDispose(disposing);
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
InternalDispose(disposing);
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,9 +197,6 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
~ForwardedPortLocal()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -298,28 +298,31 @@ namespace Renci.SshNet
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
var session = Session;
|
||||
if (session != null)
|
||||
{
|
||||
if (Session != null)
|
||||
{
|
||||
Session.RequestSuccessReceived -= Session_RequestSuccess;
|
||||
Session.RequestFailureReceived -= Session_RequestFailure;
|
||||
Session.ChannelOpenReceived -= Session_ChannelOpening;
|
||||
Session = null;
|
||||
}
|
||||
if (_globalRequestResponse != null)
|
||||
{
|
||||
_globalRequestResponse.Dispose();
|
||||
_globalRequestResponse = null;
|
||||
}
|
||||
session.RequestSuccessReceived -= Session_RequestSuccess;
|
||||
session.RequestFailureReceived -= Session_RequestFailure;
|
||||
session.ChannelOpenReceived -= Session_ChannelOpening;
|
||||
Session = null;
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
var globalRequestResponse = _globalRequestResponse;
|
||||
if (globalRequestResponse != null)
|
||||
{
|
||||
globalRequestResponse.Dispose();
|
||||
_globalRequestResponse = null;
|
||||
}
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,9 +331,6 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
~ForwardedPortRemote()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,9 +156,10 @@ namespace Renci.SshNet
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
if (_authenticationCompleted != null)
|
||||
var authenticationCompleted = _authenticationCompleted;
|
||||
if (authenticationCompleted != null)
|
||||
{
|
||||
_authenticationCompleted.Dispose();
|
||||
authenticationCompleted.Dispose();
|
||||
_authenticationCompleted = null;
|
||||
}
|
||||
|
||||
@@ -168,13 +169,10 @@ namespace Renci.SshNet
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the
|
||||
/// <see cref="PasswordConnectionInfo"/> is reclaimed by garbage collection.
|
||||
/// <see cref="KeyboardInteractiveAuthenticationMethod"/> is reclaimed by garbage collection.
|
||||
/// </summary>
|
||||
~KeyboardInteractiveAuthenticationMethod()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,13 +184,10 @@ namespace Renci.SshNet
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the
|
||||
/// <see cref="PasswordConnectionInfo"/> is reclaimed by garbage collection.
|
||||
/// <see cref="KeyboardInteractiveConnectionInfo"/> is reclaimed by garbage collection.
|
||||
/// </summary>
|
||||
~KeyboardInteractiveConnectionInfo()
|
||||
{
|
||||
// Do not re-create Dispose clean-up code here.
|
||||
// Calling Dispose(false) is optimal in terms of
|
||||
// readability and maintainability.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,36 +6,25 @@
|
||||
[Message("SSH_MSG_USERAUTH_BANNER", 53)]
|
||||
public class BannerMessage : Message
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _message;
|
||||
private byte[] _language;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets banner message.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Message
|
||||
{
|
||||
get { return Utf8.GetString(_message, 0, _message.Length); }
|
||||
}
|
||||
#else
|
||||
public string Message { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets banner language.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Language
|
||||
{
|
||||
get { return Utf8.GetString(_language, 0, _language.Length); }
|
||||
}
|
||||
#else
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -54,20 +43,14 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
_message = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
#else
|
||||
Message = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,13 +58,8 @@
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(_message);
|
||||
WriteBinaryString(_language);
|
||||
#else
|
||||
Write(Message);
|
||||
Write(Language);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Renci.SshNet.Messages.Authentication
|
||||
/// </summary>
|
||||
public IList<string> Responses { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -26,7 +25,6 @@ namespace Renci.SshNet.Messages.Authentication
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InformationResponseMessage"/> class.
|
||||
|
||||
@@ -6,32 +6,16 @@
|
||||
[Message("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ", 60)]
|
||||
internal class PasswordChangeRequiredMessage : Message
|
||||
{
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets password change request message as UTF-8 encoded byte array.
|
||||
/// </summary>
|
||||
public byte[] Message { get; private set; }
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets password change request message.
|
||||
/// </summary>
|
||||
public string Message { get; private set; }
|
||||
#endif
|
||||
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets message language as UTF-8 encoded byte array.
|
||||
/// </summary>
|
||||
public byte[] Language { get; private set; }
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets message language.
|
||||
/// </summary>
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -50,20 +34,14 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
Message = ReadBinary();
|
||||
Language = ReadBinary();
|
||||
#else
|
||||
Message = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,13 +49,8 @@
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(Message);
|
||||
WriteBinaryString(Language);
|
||||
#else
|
||||
Write(Message);
|
||||
Write(Language);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
[Message("SSH_MSG_USERAUTH_PK_OK", 60)]
|
||||
internal class PublicKeyMessage : Message
|
||||
{
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the name of the public key algorithm as ASCII encoded byte array.
|
||||
/// </summary>
|
||||
@@ -14,22 +13,12 @@
|
||||
/// The name of the public key algorithm.
|
||||
/// </value>
|
||||
public byte[] PublicKeyAlgorithmName { get; private set; }
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets the name of the public key algorithm.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name of the public key algorithm.
|
||||
/// </value>
|
||||
public string PublicKeyAlgorithmName { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the public key data.
|
||||
/// </summary>
|
||||
public byte[] PublicKeyData { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -48,20 +37,14 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
PublicKeyAlgorithmName = ReadBinary();
|
||||
PublicKeyData = ReadBinary();
|
||||
#else
|
||||
PublicKeyAlgorithmName = ReadAsciiString();
|
||||
PublicKeyData = ReadBinaryString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,13 +52,8 @@
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(PublicKeyAlgorithmName);
|
||||
WriteBinaryString(PublicKeyData);
|
||||
#else
|
||||
WriteAscii(PublicKeyAlgorithmName);
|
||||
WriteBinaryString(PublicKeyData);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Renci.SshNet.Messages.Authentication
|
||||
get { return _methodName; }
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -70,7 +69,6 @@ namespace Renci.SshNet.Messages.Authentication
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessage"/> class.
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
/// </value>
|
||||
public byte[] Signature { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -67,7 +66,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessageHost"/> class.
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
/// </summary>
|
||||
public byte[] SubMethods { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -34,7 +33,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessageKeyboardInteractive"/> class.
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
/// </summary>
|
||||
public byte[] NewPassword { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -40,7 +39,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessagePassword"/> class.
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
/// </value>
|
||||
public byte[] Signature { get; set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -53,7 +52,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessagePublicKey"/> class.
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
internal const byte MessageNumber = 94;
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets or sets message data.
|
||||
/// </summary>
|
||||
@@ -21,17 +20,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// The actual data to read or write depends on the <see cref="Offset"/> and <see cref="Size"/>.
|
||||
/// </remarks>
|
||||
public byte[] Data { get; private set; }
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets or sets message data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data.
|
||||
/// </value>
|
||||
public byte[] Data { get; protected set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the zero-based offset in <see cref="Data"/> at which the data begins.
|
||||
/// </summary>
|
||||
@@ -64,7 +53,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelDataMessage"/> class.
|
||||
@@ -85,13 +73,10 @@ namespace Renci.SshNet.Messages.Connection
|
||||
throw new ArgumentNullException("data");
|
||||
|
||||
Data = data;
|
||||
#if TUNING
|
||||
Offset = 0;
|
||||
Size = data.Length;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelDataMessage"/> class.
|
||||
/// </summary>
|
||||
@@ -109,7 +94,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
Offset = offset;
|
||||
Size = size;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Loads the data.
|
||||
@@ -117,13 +101,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
protected override void LoadData()
|
||||
{
|
||||
base.LoadData();
|
||||
#if TUNING
|
||||
Data = ReadBinary();
|
||||
Offset = 0;
|
||||
Size = Data.Length;
|
||||
#else
|
||||
Data = ReadBinaryString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -132,11 +112,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
protected override void SaveData()
|
||||
{
|
||||
base.SaveData();
|
||||
#if TUNING
|
||||
WriteBinary(Data, Offset, Size);
|
||||
#else
|
||||
WriteBinaryString(Data);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
/// </summary>
|
||||
public byte[] Data { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -34,14 +33,12 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelExtendedDataMessage"/> class.
|
||||
/// </summary>
|
||||
public ChannelExtendedDataMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,11 +61,7 @@
|
||||
{
|
||||
base.LoadData();
|
||||
DataTypeCode = ReadUInt32();
|
||||
#if TUNING
|
||||
Data = ReadBinary();
|
||||
#else
|
||||
Data = ReadBinaryString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </value>
|
||||
public uint LocalChannelNumber { get; protected set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -31,7 +30,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="ChannelMessage"/>.
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
internal const byte MessageNumber = 90;
|
||||
|
||||
#if TUNING
|
||||
private byte[] _infoBytes;
|
||||
|
||||
/// <summary>
|
||||
@@ -21,21 +20,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// The type of the channel.
|
||||
/// </value>
|
||||
public byte[] ChannelType { get; private set; }
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets the type of the channel.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The type of the channel.
|
||||
/// </value>
|
||||
public string ChannelType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Info.ChannelType;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the local channel number.
|
||||
@@ -66,7 +50,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
public ChannelOpenInfo Info { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -87,7 +70,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelOpenMessage"/> class.
|
||||
@@ -110,16 +92,12 @@ namespace Renci.SshNet.Messages.Connection
|
||||
if (info == null)
|
||||
throw new ArgumentNullException("info");
|
||||
|
||||
#if TUNING
|
||||
ChannelType = Ascii.GetBytes(info.ChannelType);
|
||||
#endif
|
||||
LocalChannelNumber = channelNumber;
|
||||
InitialWindowSize = initialWindowSize;
|
||||
MaximumPacketSize = maximumPacketSize;
|
||||
Info = info;
|
||||
#if TUNING
|
||||
_infoBytes = info.GetBytes();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,21 +105,13 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
ChannelType = ReadBinary();
|
||||
#else
|
||||
var channelName = ReadAsciiString();
|
||||
#endif
|
||||
LocalChannelNumber = ReadUInt32();
|
||||
InitialWindowSize = ReadUInt32();
|
||||
MaximumPacketSize = ReadUInt32();
|
||||
#if TUNING
|
||||
_infoBytes = ReadBytes();
|
||||
|
||||
var channelName = Ascii.GetString(ChannelType, 0, ChannelType.Length);
|
||||
#else
|
||||
var _infoBytes = ReadBytes();
|
||||
#endif
|
||||
|
||||
switch (channelName)
|
||||
{
|
||||
@@ -167,19 +137,11 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(ChannelType);
|
||||
#else
|
||||
WriteAscii(ChannelType);
|
||||
#endif
|
||||
Write(LocalChannelNumber);
|
||||
Write(InitialWindowSize);
|
||||
Write(MaximumPacketSize);
|
||||
#if TUNING
|
||||
Write(_infoBytes);
|
||||
#else
|
||||
Write(Info.GetBytes());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
internal class DirectTcpipChannelInfo : ChannelOpenInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _hostToConnect;
|
||||
private byte[] _originatorAddress;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Specifies channel open type
|
||||
@@ -31,15 +29,11 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the host to connect.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string HostToConnect
|
||||
{
|
||||
get { return Utf8.GetString(_hostToConnect, 0, _hostToConnect.Length); }
|
||||
private set { _hostToConnect = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string HostToConnect { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the port to connect.
|
||||
@@ -49,22 +43,17 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the originator address.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string OriginatorAddress
|
||||
{
|
||||
get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
|
||||
private set { _originatorAddress = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string OriginatorAddress { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the originator port.
|
||||
/// </summary>
|
||||
public uint OriginatorPort { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -85,7 +74,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectTcpipChannelInfo"/> class from the
|
||||
@@ -119,17 +107,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_hostToConnect = ReadBinary();
|
||||
#else
|
||||
HostToConnect = ReadString();
|
||||
#endif
|
||||
PortToConnect = ReadUInt32();
|
||||
#if TUNING
|
||||
_originatorAddress = ReadBinary();
|
||||
#else
|
||||
OriginatorAddress = ReadString();
|
||||
#endif
|
||||
OriginatorPort = ReadUInt32();
|
||||
}
|
||||
|
||||
@@ -140,17 +120,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_hostToConnect);
|
||||
#else
|
||||
Write(HostToConnect);
|
||||
#endif
|
||||
Write(PortToConnect);
|
||||
#if TUNING
|
||||
WriteBinaryString(_originatorAddress);
|
||||
#else
|
||||
Write(OriginatorAddress);
|
||||
#endif
|
||||
Write(OriginatorPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
internal class ForwardedTcpipChannelInfo : ChannelOpenInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _connectedAddress;
|
||||
private byte[] _originatorAddress;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ForwardedTcpipChannelInfo"/> class from the
|
||||
@@ -53,15 +51,11 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the connected address.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string ConnectedAddress
|
||||
{
|
||||
get { return Utf8.GetString(_connectedAddress, 0, _connectedAddress.Length); }
|
||||
private set { _connectedAddress = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string ConnectedAddress { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the connected port.
|
||||
@@ -71,22 +65,17 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the originator address.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string OriginatorAddress
|
||||
{
|
||||
get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
|
||||
private set { _originatorAddress = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string OriginatorAddress { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the originator port.
|
||||
/// </summary>
|
||||
public uint OriginatorPort { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -107,7 +96,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
@@ -116,17 +104,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_connectedAddress = ReadBinary();
|
||||
#else
|
||||
ConnectedAddress = ReadString();
|
||||
#endif
|
||||
ConnectedPort = ReadUInt32();
|
||||
#if TUNING
|
||||
_originatorAddress = ReadBinary();
|
||||
#else
|
||||
OriginatorAddress = ReadString();
|
||||
#endif
|
||||
OriginatorPort = ReadUInt32();
|
||||
}
|
||||
|
||||
@@ -137,17 +117,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_connectedAddress);
|
||||
#else
|
||||
Write(ConnectedAddress);
|
||||
#endif
|
||||
Write(ConnectedPort);
|
||||
#if TUNING
|
||||
WriteBinaryString(_originatorAddress);
|
||||
#else
|
||||
Write(OriginatorAddress);
|
||||
#endif
|
||||
Write(OriginatorPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
internal class X11ChannelOpenInfo : ChannelOpenInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _originatorAddress;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Specifies channel open type
|
||||
@@ -30,22 +28,17 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the originator address.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string OriginatorAddress
|
||||
{
|
||||
get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
|
||||
private set { _originatorAddress = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string OriginatorAddress { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the originator port.
|
||||
/// </summary>
|
||||
public uint OriginatorPort { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -63,7 +56,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="X11ChannelOpenInfo"/> class from the
|
||||
@@ -94,11 +86,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_originatorAddress = ReadBinary();
|
||||
#else
|
||||
OriginatorAddress = ReadString();
|
||||
#endif
|
||||
OriginatorPort = ReadUInt32();
|
||||
}
|
||||
|
||||
@@ -109,11 +97,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_originatorAddress);
|
||||
#else
|
||||
Write(OriginatorAddress);
|
||||
#endif
|
||||
Write(OriginatorPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
/// </value>
|
||||
public uint MaximumPacketSize { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
protected override int BufferCapacity
|
||||
{
|
||||
get
|
||||
@@ -39,7 +38,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelOpenConfirmationMessage"/> class.
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
internal const uint UnknownChannelType = 3;
|
||||
internal const uint ResourceShortage = 4;
|
||||
|
||||
#if TUNING
|
||||
private byte[] _description;
|
||||
private byte[] _language;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets failure reason code.
|
||||
@@ -24,30 +22,21 @@
|
||||
/// <summary>
|
||||
/// Gets description for failure.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Description
|
||||
{
|
||||
get { return Utf8.GetString(_description, 0, _description.Length); }
|
||||
private set { _description = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string Description { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets message language.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Language
|
||||
{
|
||||
get { return Utf8.GetString(_language, 0, _language.Length); }
|
||||
private set { _language = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -67,7 +56,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelOpenFailureMessage"/> class.
|
||||
@@ -110,13 +98,8 @@
|
||||
{
|
||||
base.LoadData();
|
||||
ReasonCode = ReadUInt32();
|
||||
#if TUNING
|
||||
_description = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
#else
|
||||
Description = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -126,13 +109,8 @@
|
||||
{
|
||||
base.SaveData();
|
||||
Write(ReasonCode);
|
||||
#if TUNING
|
||||
WriteBinaryString(_description);
|
||||
WriteBinaryString(_language);
|
||||
#else
|
||||
Write(Description ?? string.Empty);
|
||||
Write(Language ?? "en");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
public UInt32 BreakLength { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -44,7 +43,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
[Message("SSH_MSG_CHANNEL_REQUEST", 98)]
|
||||
public class ChannelRequestMessage : ChannelMessage
|
||||
{
|
||||
#if TUNING
|
||||
private string _requestName;
|
||||
private byte[] _requestNameBytes;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the request.
|
||||
@@ -17,7 +15,6 @@
|
||||
/// <value>
|
||||
/// The name of the request.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string RequestName
|
||||
{
|
||||
get { return _requestName; }
|
||||
@@ -27,16 +24,12 @@
|
||||
_requestNameBytes = Ascii.GetBytes(value);
|
||||
}
|
||||
}
|
||||
#else
|
||||
public string RequestName { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets channel request data.
|
||||
/// </summary>
|
||||
public byte[] RequestData { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -54,7 +47,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelRequestMessage"/> class.
|
||||
@@ -83,12 +75,8 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_requestNameBytes = ReadBinary();
|
||||
_requestName = Ascii.GetString(_requestNameBytes, 0, _requestNameBytes.Length);
|
||||
#else
|
||||
RequestName = ReadAsciiString();
|
||||
#endif
|
||||
RequestData = ReadBytes();
|
||||
}
|
||||
|
||||
@@ -99,11 +87,7 @@
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_requestNameBytes);
|
||||
#else
|
||||
WriteAscii(RequestName);
|
||||
#endif
|
||||
Write(RequestData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
/// </summary>
|
||||
internal class EnvironmentVariableRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _variableName;
|
||||
private byte[] _variableValue;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name
|
||||
@@ -32,14 +30,10 @@
|
||||
/// <value>
|
||||
/// The name of the variable.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string VariableName
|
||||
{
|
||||
get { return Utf8.GetString(_variableName, 0, _variableName.Length); }
|
||||
}
|
||||
#else
|
||||
public string VariableName { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the variable value.
|
||||
@@ -47,16 +41,11 @@
|
||||
/// <value>
|
||||
/// The variable value.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string VariableValue
|
||||
{
|
||||
get { return Utf8.GetString(_variableValue, 0, _variableValue.Length); }
|
||||
}
|
||||
#else
|
||||
public string VariableValue { get; set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -75,7 +64,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnvironmentVariableRequestInfo"/> class.
|
||||
@@ -93,13 +81,8 @@
|
||||
public EnvironmentVariableRequestInfo(string variableName, string variableValue)
|
||||
: this()
|
||||
{
|
||||
#if TUNING
|
||||
_variableName = Utf8.GetBytes(variableName);
|
||||
_variableValue = Utf8.GetBytes(variableValue);
|
||||
#else
|
||||
VariableName = variableName;
|
||||
VariableValue = variableValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,13 +92,8 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_variableName = ReadBinary();
|
||||
_variableValue = ReadBinary();
|
||||
#else
|
||||
VariableName = ReadString();
|
||||
VariableValue = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,13 +103,8 @@
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_variableName);
|
||||
WriteBinaryString(_variableValue);
|
||||
#else
|
||||
Write(VariableName);
|
||||
Write(VariableValue);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
internal class ExecRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _command;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name
|
||||
@@ -34,14 +32,10 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <value>
|
||||
/// The command.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string Command
|
||||
{
|
||||
get { return Encoding.GetString(_command, 0, _command.Length); }
|
||||
}
|
||||
#else
|
||||
public string Command { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the encoding.
|
||||
@@ -51,7 +45,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </value>
|
||||
public Encoding Encoding { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -68,7 +61,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
|
||||
@@ -92,11 +84,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
if (encoding == null)
|
||||
throw new ArgumentNullException("encoding");
|
||||
|
||||
#if TUNING
|
||||
_command = encoding.GetBytes(command);
|
||||
#else
|
||||
Command = command;
|
||||
#endif
|
||||
Encoding = encoding;
|
||||
}
|
||||
|
||||
@@ -107,12 +95,8 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_command = ReadBinary();
|
||||
Encoding = Utf8;
|
||||
#else
|
||||
Command = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,11 +106,7 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_command);
|
||||
#else
|
||||
Write(Command, Encoding);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,9 @@
|
||||
/// </summary>
|
||||
internal class ExitSignalRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _signalName;
|
||||
private byte[] _errorMessage;
|
||||
private byte[] _language;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name
|
||||
@@ -33,15 +31,11 @@
|
||||
/// <value>
|
||||
/// The name of the signal.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string SignalName
|
||||
{
|
||||
get { return Ascii.GetString(_signalName, 0, _signalName.Length); }
|
||||
private set { _signalName = Ascii.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string SignalName { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether core is dumped.
|
||||
@@ -54,30 +48,21 @@
|
||||
/// <summary>
|
||||
/// Gets the error message.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return Utf8.GetString(_errorMessage, 0, _errorMessage.Length); }
|
||||
private set { _errorMessage = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string ErrorMessage { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets message language.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Language
|
||||
{
|
||||
get { return Utf8.GetString(_language, 0, _language.Length); }
|
||||
private set { _language = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
protected override int BufferCapacity
|
||||
{
|
||||
get
|
||||
@@ -93,7 +78,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExitSignalRequestInfo"/> class.
|
||||
@@ -126,19 +110,10 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_signalName = ReadBinary();
|
||||
#else
|
||||
SignalName = ReadAsciiString();
|
||||
#endif
|
||||
CoreDumped = ReadBoolean();
|
||||
#if TUNING
|
||||
_errorMessage = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
#else
|
||||
ErrorMessage = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,20 +123,10 @@
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_signalName);
|
||||
#else
|
||||
WriteAscii(SignalName);
|
||||
#endif
|
||||
Write(CoreDumped);
|
||||
#if TUNING
|
||||
Write(_errorMessage);
|
||||
Write(_language);
|
||||
#else
|
||||
Write(ErrorMessage);
|
||||
Write(Language);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
/// </summary>
|
||||
public uint ExitStatus { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
protected override int BufferCapacity
|
||||
{
|
||||
get
|
||||
@@ -36,7 +35,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExitStatusRequestInfo"/> class.
|
||||
|
||||
@@ -72,7 +72,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </value>
|
||||
public IDictionary<TerminalModes, uint> TerminalModeValues { get; set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -84,7 +83,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PseudoTerminalRequestInfo"/> class.
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </value>
|
||||
public bool WantReply { get; protected set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -39,7 +38,6 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
/// </summary>
|
||||
internal class SignalRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _signalName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name.
|
||||
@@ -31,17 +29,12 @@
|
||||
/// <value>
|
||||
/// The name of the signal.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string SignalName
|
||||
{
|
||||
get { return Ascii.GetString(_signalName, 0, _signalName.Length); }
|
||||
private set { _signalName = Ascii.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string SignalName { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -58,7 +51,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SignalRequestInfo"/> class.
|
||||
@@ -85,11 +77,7 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_signalName = ReadBinary();
|
||||
#else
|
||||
SignalName = ReadAsciiString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,11 +87,7 @@
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_signalName);
|
||||
#else
|
||||
WriteAscii(SignalName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
/// </summary>
|
||||
internal class SubsystemRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _subsystemName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name
|
||||
@@ -31,17 +29,12 @@
|
||||
/// <value>
|
||||
/// The name of the subsystem.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string SubsystemName
|
||||
{
|
||||
get { return Ascii.GetString(_subsystemName, 0, _subsystemName.Length); }
|
||||
private set { _subsystemName = Ascii.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string SubsystemName { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
protected override int BufferCapacity
|
||||
{
|
||||
get
|
||||
@@ -52,7 +45,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SubsystemRequestInfo"/> class.
|
||||
@@ -79,11 +71,7 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
#if TUNING
|
||||
_subsystemName = ReadBinary();
|
||||
#else
|
||||
SubsystemName = ReadAsciiString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,11 +81,7 @@
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_subsystemName);
|
||||
#else
|
||||
WriteAscii(SubsystemName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
/// </summary>
|
||||
public uint Height { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -60,7 +59,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WindowChangeRequestInfo"/> class.
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
/// </summary>
|
||||
internal class X11ForwardingRequestInfo : RequestInfo
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _authenticationProtocol;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Channel request name
|
||||
@@ -39,15 +37,11 @@
|
||||
/// <value>
|
||||
/// The authentication protocol.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public string AuthenticationProtocol
|
||||
{
|
||||
get { return Ascii.GetString(_authenticationProtocol, 0, _authenticationProtocol.Length); }
|
||||
private set { _authenticationProtocol = Ascii.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string AuthenticationProtocol { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authentication cookie.
|
||||
@@ -65,7 +59,6 @@
|
||||
/// </value>
|
||||
public uint ScreenNumber { get; set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -86,7 +79,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="X11ForwardingRequestInfo"/> class.
|
||||
@@ -120,13 +112,8 @@
|
||||
base.LoadData();
|
||||
|
||||
IsSingleConnection = ReadBoolean();
|
||||
#if TUNING
|
||||
_authenticationProtocol = ReadBinary();
|
||||
AuthenticationCookie = ReadBinary();
|
||||
#else
|
||||
AuthenticationProtocol = ReadAsciiString();
|
||||
AuthenticationCookie = ReadBinaryString();
|
||||
#endif
|
||||
ScreenNumber = ReadUInt32();
|
||||
}
|
||||
|
||||
@@ -138,11 +125,7 @@
|
||||
base.SaveData();
|
||||
|
||||
Write(IsSingleConnection);
|
||||
#if TUNING
|
||||
WriteBinaryString(_authenticationProtocol);
|
||||
#else
|
||||
WriteAscii(AuthenticationProtocol);
|
||||
#endif
|
||||
WriteBinaryString(AuthenticationCookie);
|
||||
Write(ScreenNumber);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
/// </value>
|
||||
public bool ClientCanDo { get; set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -45,7 +44,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="XonXoffRequestInfo"/> class.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/// </summary>
|
||||
public uint BytesToAdd { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -27,7 +26,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelWindowAdjustMessage"/> class.
|
||||
|
||||
@@ -9,10 +9,8 @@ namespace Renci.SshNet.Messages.Connection
|
||||
[Message("SSH_MSG_GLOBAL_REQUEST", 80)]
|
||||
public class GlobalRequestMessage : Message
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _requestName;
|
||||
private byte[] _addressToBind;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the request.
|
||||
@@ -20,14 +18,10 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <value>
|
||||
/// The name of the request.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public GlobalRequestName RequestName
|
||||
{
|
||||
get { return _requestName.ToGlobalRequestName(); }
|
||||
}
|
||||
#else
|
||||
public GlobalRequestName RequestName { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether message reply should be sent..
|
||||
@@ -40,23 +34,17 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <summary>
|
||||
/// Gets the address to bind to.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string AddressToBind
|
||||
{
|
||||
get { return Utf8.GetString(_addressToBind, 0, _addressToBind.Length); }
|
||||
private set { _addressToBind = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string AddressToBind { get; private set; }
|
||||
// TODO: Extract AddressToBind property to be in different class and GlobalREquestMessage to be a base class fo it.
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets port number to bind to.
|
||||
/// </summary>
|
||||
public UInt32 PortToBind { get; private set; }
|
||||
public uint PortToBind { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -77,29 +65,14 @@ namespace Renci.SshNet.Messages.Connection
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GlobalRequestMessage"/> class.
|
||||
/// </summary>
|
||||
public GlobalRequestMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#if !TUNING
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GlobalRequestMessage"/> class.
|
||||
/// </summary>
|
||||
/// <param name="requestName">Name of the request.</param>
|
||||
/// <param name="wantReply">if set to <c>true</c> [want reply].</param>
|
||||
public GlobalRequestMessage(GlobalRequestName requestName, bool wantReply)
|
||||
{
|
||||
RequestName = requestName;
|
||||
WantReply = wantReply;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GlobalRequestMessage"/> class.
|
||||
/// </summary>
|
||||
@@ -108,14 +81,9 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// <param name="addressToBind">The address to bind.</param>
|
||||
/// <param name="portToBind">The port to bind.</param>
|
||||
public GlobalRequestMessage(GlobalRequestName requestName, bool wantReply, string addressToBind, uint portToBind)
|
||||
#if !TUNING
|
||||
: this(requestName, wantReply)
|
||||
#endif
|
||||
{
|
||||
#if TUNING
|
||||
_requestName = requestName.ToArray();
|
||||
WantReply = wantReply;
|
||||
#endif
|
||||
AddressToBind = addressToBind;
|
||||
PortToBind = portToBind;
|
||||
}
|
||||
@@ -125,32 +93,10 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
_requestName = ReadBinary();
|
||||
#else
|
||||
var requestName = ReadAsciiString();
|
||||
#endif
|
||||
|
||||
WantReply = ReadBoolean();
|
||||
|
||||
#if TUNING
|
||||
_addressToBind = ReadBinary();
|
||||
PortToBind = ReadUInt32();
|
||||
#else
|
||||
switch (requestName)
|
||||
{
|
||||
case "tcpip-forward":
|
||||
RequestName = GlobalRequestName.TcpIpForward;
|
||||
AddressToBind = ReadString();
|
||||
PortToBind = ReadUInt32();
|
||||
break;
|
||||
case "cancel-tcpip-forward":
|
||||
RequestName = GlobalRequestName.CancelTcpIpForward;
|
||||
AddressToBind = ReadString();
|
||||
PortToBind = ReadUInt32();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -158,35 +104,10 @@ namespace Renci.SshNet.Messages.Connection
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(_requestName);
|
||||
#else
|
||||
switch (RequestName)
|
||||
{
|
||||
case GlobalRequestName.TcpIpForward:
|
||||
WriteAscii("tcpip-forward");
|
||||
break;
|
||||
case GlobalRequestName.CancelTcpIpForward:
|
||||
WriteAscii("cancel-tcpip-forward");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
Write(WantReply);
|
||||
|
||||
#if TUNING
|
||||
WriteBinaryString(_addressToBind);
|
||||
Write(PortToBind);
|
||||
#else
|
||||
switch (RequestName)
|
||||
{
|
||||
case GlobalRequestName.TcpIpForward:
|
||||
case GlobalRequestName.CancelTcpIpForward:
|
||||
Write(AddressToBind);
|
||||
Write(PortToBind);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/// </summary>
|
||||
public uint? BoundPort { get; private set; }
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -28,7 +27,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestSuccessMessage"/> class.
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Renci.SshNet.Messages
|
||||
}
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -163,26 +162,6 @@ namespace Renci.SshNet.Messages
|
||||
return paddingLength;
|
||||
}
|
||||
|
||||
#else
|
||||
/// <summary>
|
||||
/// Gets data bytes array
|
||||
/// </summary>
|
||||
/// <returns>Byte array representation of the message</returns>
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
var messageAttribute = GetType().GetTypeInfo().GetCustomAttributes(typeof(MessageAttribute), true).SingleOrDefault() as MessageAttribute;
|
||||
|
||||
if (messageAttribute == null)
|
||||
throw new SshException(string.Format(CultureInfo.CurrentCulture, "Type '{0}' is not a valid message type.", GetType().AssemblyQualifiedName));
|
||||
|
||||
var data = new List<byte>(base.GetBytes());
|
||||
|
||||
data.Insert(0, messageAttribute.Number);
|
||||
|
||||
return data.ToArray();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents this instance.
|
||||
/// </summary>
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
[Message("SSH_MSG_DEBUG", 4)]
|
||||
public class DebugMessage : Message
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _message;
|
||||
private byte[] _language;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the message to be always displayed.
|
||||
@@ -22,28 +20,19 @@
|
||||
/// <summary>
|
||||
/// Gets debug message.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Message
|
||||
{
|
||||
get { return Utf8.GetString(_message, 0, _message.Length); }
|
||||
}
|
||||
#else
|
||||
public string Message { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets message language.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Language
|
||||
{
|
||||
get { return Utf8.GetString(_language, 0, _language.Length); }
|
||||
}
|
||||
#else
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -63,7 +52,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
@@ -71,13 +59,8 @@
|
||||
protected override void LoadData()
|
||||
{
|
||||
IsAlwaysDisplay = ReadBoolean();
|
||||
#if TUNING
|
||||
_message = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
#else
|
||||
Message = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,13 +69,8 @@
|
||||
protected override void SaveData()
|
||||
{
|
||||
Write(IsAlwaysDisplay);
|
||||
#if TUNING
|
||||
WriteBinaryString(_message);
|
||||
WriteBinaryString(_language);
|
||||
#else
|
||||
Write(Message);
|
||||
Write(Language);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
[Message("SSH_MSG_DISCONNECT", 1)]
|
||||
public class DisconnectMessage : Message, IKeyExchangedAllowed
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _description;
|
||||
private byte[] _language;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets disconnect reason code.
|
||||
@@ -19,30 +17,21 @@
|
||||
/// <summary>
|
||||
/// Gets disconnect description.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Description
|
||||
{
|
||||
get { return Utf8.GetString(_description, 0, _description.Length); }
|
||||
private set { _description = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string Description { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets message language.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public string Language
|
||||
{
|
||||
get { return Utf8.GetString(_language, 0, _language.Length); }
|
||||
private set { _language = Utf8.GetBytes(value); }
|
||||
}
|
||||
#else
|
||||
public string Language { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -62,7 +51,6 @@
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DisconnectMessage"/> class.
|
||||
@@ -80,9 +68,7 @@
|
||||
{
|
||||
ReasonCode = reasonCode;
|
||||
Description = message;
|
||||
#if TUNING
|
||||
Language = "en";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,14 +76,9 @@
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
ReasonCode = (DisconnectReason)ReadUInt32();
|
||||
#if TUNING
|
||||
ReasonCode = (DisconnectReason) ReadUInt32();
|
||||
_description = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
#else
|
||||
Description = ReadString();
|
||||
Language = ReadString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,14 +86,9 @@
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
Write((uint)ReasonCode);
|
||||
#if TUNING
|
||||
Write((uint) ReasonCode);
|
||||
WriteBinaryString(_description);
|
||||
WriteBinaryString(_language);
|
||||
#else
|
||||
Write(Description);
|
||||
Write(Language ?? "en");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Renci.SshNet.Messages.Transport
|
||||
Data = new byte[0];
|
||||
}
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -40,7 +39,6 @@ namespace Renci.SshNet.Messages.Transport
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IgnoreMessage"/> class.
|
||||
@@ -59,11 +57,7 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
Data = ReadBinary();
|
||||
#else
|
||||
Data = ReadBinaryString();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,10 +10,8 @@ namespace Renci.SshNet.Messages.Transport
|
||||
{
|
||||
internal const byte MessageNumber = 31;
|
||||
|
||||
#if TUNING
|
||||
private byte[] _safePrime;
|
||||
private byte[] _subGroup;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the safe prime.
|
||||
@@ -21,14 +19,10 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// <value>
|
||||
/// The safe prime.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public BigInteger SafePrime
|
||||
{
|
||||
get { return _safePrime.ToBigInteger(); }
|
||||
}
|
||||
#else
|
||||
public BigInteger SafePrime { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the generator for subgroup in GF(p).
|
||||
@@ -36,16 +30,11 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// <value>
|
||||
/// The sub group.
|
||||
/// </value>
|
||||
#if TUNING
|
||||
public BigInteger SubGroup
|
||||
{
|
||||
get { return _subGroup.ToBigInteger(); }
|
||||
}
|
||||
#else
|
||||
public BigInteger SubGroup { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -65,20 +54,14 @@ namespace Renci.SshNet.Messages.Transport
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Called when type specific data need to be loaded.
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
_safePrime = ReadBinary();
|
||||
_subGroup = ReadBinary();
|
||||
#else
|
||||
SafePrime = ReadBigInt();
|
||||
SubGroup = ReadBigInt();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,13 +69,8 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(_safePrime);
|
||||
WriteBinaryString(_subGroup);
|
||||
#else
|
||||
Write(SafePrime);
|
||||
Write(SubGroup);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,16 @@ namespace Renci.SshNet.Messages.Transport
|
||||
[Message("SSH_MSG_KEX_DH_GEX_INIT", 32)]
|
||||
internal class KeyExchangeDhGroupExchangeInit : Message, IKeyExchangedAllowed
|
||||
{
|
||||
#if TUNING
|
||||
private byte[] _eBytes;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the E value.
|
||||
/// </summary>
|
||||
#if TUNING
|
||||
public BigInteger E
|
||||
{
|
||||
get { return _eBytes.ToBigInteger(); }
|
||||
}
|
||||
#else
|
||||
public BigInteger E { get; private set; }
|
||||
#endif
|
||||
|
||||
#if TUNING
|
||||
/// <summary>
|
||||
/// Gets the size of the message in bytes.
|
||||
/// </summary>
|
||||
@@ -41,7 +34,6 @@ namespace Renci.SshNet.Messages.Transport
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="KeyExchangeDhGroupExchangeInit"/> class.
|
||||
@@ -49,11 +41,7 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// <param name="clientExchangeValue">The client exchange value.</param>
|
||||
public KeyExchangeDhGroupExchangeInit(BigInteger clientExchangeValue)
|
||||
{
|
||||
#if TUNING
|
||||
_eBytes = clientExchangeValue.ToByteArray().Reverse();
|
||||
#else
|
||||
E = clientExchangeValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -61,11 +49,7 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
#if TUNING
|
||||
_eBytes = ReadBinary();
|
||||
#else
|
||||
E = ReadBigInt();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,11 +57,7 @@ namespace Renci.SshNet.Messages.Transport
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
#if TUNING
|
||||
WriteBinaryString(_eBytes);
|
||||
#else
|
||||
Write(E);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user