mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Cleanup formatting and style and enforce it in CI (#1380)
* Preparation to enforce formatting and style in CI - enabled IDE0055 to enforce formatting on build - disabled SA1137 and SA1025 because they are already covered by IDE0055 - disabled SA1021 because it conflicts with csharp_space_after_cast * Cleanup formatting and style on codebase This commit has no manual changes, it is the result of running "dotnet format whitespace" and "dotnet format style" * new formatting fixes after merge * appveyor: set git autocrlf as suggested by sharwell to hopefully fix Windows CI. * use autocrlf input to hopefully fix Linux tests * fix formatting * use autocrlf input for Linux only * set csharp_space_after_cast to false * Revert SA1021 suppression --------- Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
This commit is contained in:
+12
-13
@@ -63,6 +63,12 @@ dotnet_diagnostic.S1125.severity = none
|
||||
# This is a duplicate of MA0026.
|
||||
dotnet_diagnostic.S1135.severity = none
|
||||
|
||||
|
||||
# SA1137: Elements should have the same indentation
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md
|
||||
# duplicate of IDE0055
|
||||
dotnet_diagnostic.SA1137.severity = none
|
||||
|
||||
# S1168: Empty arrays and collections should be returned instead of null
|
||||
# https://rules.sonarsource.com/csharp/RSPEC-1168
|
||||
#
|
||||
@@ -339,6 +345,11 @@ dotnet_diagnostic.SA1008.severity = none
|
||||
# var x = (int) z;
|
||||
dotnet_diagnostic.SA1009.severity = none
|
||||
|
||||
# SA1025: Code should not contain multiple whitespace in a row
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md
|
||||
# duplicate of IDE0055
|
||||
dotnet_diagnostic.SA1025.severity = none
|
||||
|
||||
# SA1101: Prefix local calls with this
|
||||
dotnet_diagnostic.SA1101.severity = none
|
||||
|
||||
@@ -743,18 +754,6 @@ dotnet_diagnostic.IDE0046.severity = suggestion
|
||||
# Removing "unnecessary" parentheses is not always a clear win for readability.
|
||||
dotnet_diagnostic.IDE0047.severity = suggestion
|
||||
|
||||
# IDE0055: Fix formatting
|
||||
#
|
||||
# When enabled, diagnostics are reported for indented object initializers.
|
||||
# For example:
|
||||
# _content = new Person
|
||||
# {
|
||||
# Name = "\u13AAlarm"
|
||||
# };
|
||||
#
|
||||
# There are no settings to configure this correctly, unless https://github.com/dotnet/roslyn/issues/63256 (or similar) is ever implemented.
|
||||
dotnet_diagnostic.IDE0055.severity = none
|
||||
|
||||
# IDE0130: Namespace does not match folder structure
|
||||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
|
||||
#
|
||||
@@ -925,7 +924,7 @@ csharp_indent_block_contents = true
|
||||
|
||||
# Spacing options
|
||||
|
||||
csharp_space_after_cast = true
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
|
||||
@@ -10,6 +10,9 @@ for:
|
||||
matrix:
|
||||
only:
|
||||
- image: Ubuntu2204
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
before_build:
|
||||
- sh: mkdir artifacts -p
|
||||
@@ -30,6 +33,9 @@ for:
|
||||
only:
|
||||
- image: Visual Studio 2022
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
before_build:
|
||||
- ps: mkdir artifacts -f
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Abstractions
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace Renci.SshNet.Abstractions
|
||||
{
|
||||
var connectCompleted = new ManualResetEvent(initialState: false);
|
||||
var args = new SocketAsyncEventArgs
|
||||
{
|
||||
UserToken = connectCompleted,
|
||||
RemoteEndPoint = remoteEndpoint
|
||||
};
|
||||
{
|
||||
UserToken = connectCompleted,
|
||||
RemoteEndPoint = remoteEndpoint
|
||||
};
|
||||
args.Completed += ConnectCompleted;
|
||||
|
||||
if (socket.ConnectAsync(args))
|
||||
@@ -96,7 +96,7 @@ namespace Renci.SshNet.Abstractions
|
||||
|
||||
if (args.SocketError != SocketError.Success)
|
||||
{
|
||||
var socketError = (int) args.SocketError;
|
||||
var socketError = (int)args.SocketError;
|
||||
|
||||
if (ownsSocket)
|
||||
{
|
||||
@@ -374,7 +374,7 @@ namespace Renci.SshNet.Abstractions
|
||||
|
||||
private static void ConnectCompleted(object sender, SocketAsyncEventArgs e)
|
||||
{
|
||||
var eventWaitHandle = (ManualResetEvent) e.UserToken;
|
||||
var eventWaitHandle = (ManualResetEvent)e.UserToken;
|
||||
_ = eventWaitHandle?.Set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Renci.SshNet.Abstractions
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
await args.ExecuteAsync(socket.ConnectAsync);
|
||||
@@ -113,9 +113,9 @@ namespace Renci.SshNet.Abstractions
|
||||
args.SetBuffer(buffer, offset, length);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
await args.ExecuteAsync(socket.ReceiveAsync);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Renci.SshNet
|
||||
/// </returns>
|
||||
AuthenticationResult IAuthenticationMethod.Authenticate(ISession session)
|
||||
{
|
||||
return Authenticate((Session) session);
|
||||
return Authenticate((Session)session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ namespace Renci.SshNet.Channels
|
||||
|
||||
private void AdjustDataWindow(byte[] messageData)
|
||||
{
|
||||
LocalWindowSize -= (uint) messageData.Length;
|
||||
LocalWindowSize -= (uint)messageData.Length;
|
||||
|
||||
// Adjust window if window size is too low
|
||||
if (LocalWindowSize < LocalPacketSize)
|
||||
@@ -794,10 +794,10 @@ namespace Renci.SshNet.Channels
|
||||
}
|
||||
else
|
||||
{
|
||||
var bytesThatCanBeSent = Math.Min(Math.Min(RemotePacketSize, (uint) messageLength),
|
||||
var bytesThatCanBeSent = Math.Min(Math.Min(RemotePacketSize, (uint)messageLength),
|
||||
serverWindowSize);
|
||||
RemoteWindowSize -= bytesThatCanBeSent;
|
||||
return (int) bytesThatCanBeSent;
|
||||
return (int)bytesThatCanBeSent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
using Renci.SshNet.Abstractions;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
@@ -59,13 +60,13 @@ namespace Renci.SshNet.Channels
|
||||
_forwardedPort = forwardedPort;
|
||||
_forwardedPort.Closing += ForwardedPort_Closing;
|
||||
|
||||
var ep = (IPEndPoint) socket.RemoteEndPoint;
|
||||
var ep = (IPEndPoint)socket.RemoteEndPoint;
|
||||
|
||||
// Open channel
|
||||
SendMessage(new ChannelOpenMessage(LocalChannelNumber,
|
||||
LocalWindowSize,
|
||||
LocalPacketSize,
|
||||
new DirectTcpipChannelInfo(remoteHost, port, ep.Address.ToString(), (uint) ep.Port)));
|
||||
new DirectTcpipChannelInfo(remoteHost, port, ep.Address.ToString(), (uint)ep.Port)));
|
||||
|
||||
// Wait for channel to open
|
||||
WaitOnHandle(_channelOpen);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
using Renci.SshNet.Abstractions;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Channels
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Channels
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Channels
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
var bytesArray = new byte[(bitLength / 8) + (((bitLength % 8) > 0) ? 1 : 0)];
|
||||
CryptoAbstraction.GenerateRandom(bytesArray);
|
||||
bytesArray[bytesArray.Length - 1] = (byte) (bytesArray[bytesArray.Length - 1] & 0x7F); // Ensure not a negative value
|
||||
bytesArray[bytesArray.Length - 1] = (byte)(bytesArray[bytesArray.Length - 1] & 0x7F); // Ensure not a negative value
|
||||
return new BigInteger(bytesArray);
|
||||
}
|
||||
|
||||
@@ -207,14 +207,12 @@ namespace Renci.SshNet.Common
|
||||
else if (value > 0)
|
||||
{
|
||||
_sign = 1;
|
||||
_data = new[] { (uint) value };
|
||||
_data = new[] { (uint)value };
|
||||
}
|
||||
else
|
||||
{
|
||||
_sign = -1;
|
||||
#pragma warning disable SA1021 // Negative signs should be spaced correctly
|
||||
_data = new[] { (uint) -value };
|
||||
#pragma warning restore SA1021 // Negative signs should be spaced correctly
|
||||
_data = new[] { (uint)-value };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,8 +290,8 @@ namespace Renci.SshNet.Common
|
||||
else
|
||||
{
|
||||
_sign = 1;
|
||||
var low = (uint) value;
|
||||
var high = (uint) (value >> 32);
|
||||
var low = (uint)value;
|
||||
var high = (uint)(value >> 32);
|
||||
|
||||
_data = new uint[high != 0 ? 2 : 1];
|
||||
_data[0] = low;
|
||||
@@ -341,7 +339,7 @@ namespace Renci.SshNet.Common
|
||||
BigInteger res = mantissa;
|
||||
res = exponent > Bias ? res << (exponent - Bias) : res >> (Bias - exponent);
|
||||
|
||||
_sign = (short) (Negative(bytes) ? -1 : 1);
|
||||
_sign = (short)(Negative(bytes) ? -1 : 1);
|
||||
_data = res._data;
|
||||
}
|
||||
}
|
||||
@@ -351,7 +349,7 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="value">A single-precision floating-point value.</param>
|
||||
public BigInteger(float value)
|
||||
: this((double) value)
|
||||
: this((double)value)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -377,18 +375,18 @@ namespace Renci.SshNet.Common
|
||||
return;
|
||||
}
|
||||
|
||||
_sign = (short) ((bits[3] & DecimalSignMask) != 0 ? -1 : 1);
|
||||
_sign = (short)((bits[3] & DecimalSignMask) != 0 ? -1 : 1);
|
||||
|
||||
_data = new uint[size];
|
||||
_data[0] = (uint) bits[0];
|
||||
_data[0] = (uint)bits[0];
|
||||
if (size > 1)
|
||||
{
|
||||
_data[1] = (uint) bits[1];
|
||||
_data[1] = (uint)bits[1];
|
||||
}
|
||||
|
||||
if (size > 2)
|
||||
{
|
||||
_data[2] = (uint) bits[2];
|
||||
_data[2] = (uint)bits[2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,10 +446,10 @@ namespace Renci.SshNet.Common
|
||||
var j = 0;
|
||||
for (var i = 0; i < fullWords; ++i)
|
||||
{
|
||||
_data[i] = (uint) value[j++] |
|
||||
(uint) (value[j++] << 8) |
|
||||
(uint) (value[j++] << 16) |
|
||||
(uint) (value[j++] << 24);
|
||||
_data[i] = (uint)value[j++] |
|
||||
(uint)(value[j++] << 8) |
|
||||
(uint)(value[j++] << 16) |
|
||||
(uint)(value[j++] << 24);
|
||||
}
|
||||
|
||||
size = len & 0x3;
|
||||
@@ -460,7 +458,7 @@ namespace Renci.SshNet.Common
|
||||
var idx = _data.Length - 1;
|
||||
for (var i = 0; i < size; ++i)
|
||||
{
|
||||
_data[idx] |= (uint) (value[j++] << (i * 8));
|
||||
_data[idx] |= (uint)(value[j++] << (i * 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -481,14 +479,14 @@ namespace Renci.SshNet.Common
|
||||
|
||||
for (var i = 0; i < fullWords; ++i)
|
||||
{
|
||||
word = (uint) value[j++] |
|
||||
(uint) (value[j++] << 8) |
|
||||
(uint) (value[j++] << 16) |
|
||||
(uint) (value[j++] << 24);
|
||||
word = (uint)value[j++] |
|
||||
(uint)(value[j++] << 8) |
|
||||
(uint)(value[j++] << 16) |
|
||||
(uint)(value[j++] << 24);
|
||||
|
||||
sub = (ulong) word - borrow;
|
||||
word = (uint) sub;
|
||||
borrow = (uint) (sub >> 32) & 0x1u;
|
||||
sub = (ulong)word - borrow;
|
||||
word = (uint)sub;
|
||||
borrow = (uint)(sub >> 32) & 0x1u;
|
||||
_data[i] = ~word;
|
||||
}
|
||||
|
||||
@@ -500,13 +498,13 @@ namespace Renci.SshNet.Common
|
||||
uint storeMask = 0;
|
||||
for (var i = 0; i < size; ++i)
|
||||
{
|
||||
word |= (uint) (value[j++] << (i * 8));
|
||||
word |= (uint)(value[j++] << (i * 8));
|
||||
storeMask = (storeMask << 8) | 0xFF;
|
||||
}
|
||||
|
||||
sub = word - borrow;
|
||||
word = (uint) sub;
|
||||
borrow = (uint) (sub >> 32) & 0x1u;
|
||||
word = (uint)sub;
|
||||
borrow = (uint)(sub >> 32) & 0x1u;
|
||||
|
||||
if ((~word & storeMask) == 0)
|
||||
{
|
||||
@@ -542,7 +540,7 @@ namespace Renci.SshNet.Common
|
||||
var i1 = (uint)v[0] | ((uint)v[1] << 8) | ((uint)v[2] << 16) | ((uint)v[3] << 24);
|
||||
var i2 = (uint)v[4] | ((uint)v[5] << 8) | ((uint)(v[6] & 0xF) << 16);
|
||||
|
||||
return (ulong) i1 | ((ulong) i2 << 32);
|
||||
return (ulong)i1 | ((ulong)i2 << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -577,7 +575,7 @@ namespace Renci.SshNet.Common
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x += x >> 8;
|
||||
x += x >> 16;
|
||||
return (int) (x & 0x0000003F);
|
||||
return (int)(x & 0x0000003F);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -793,7 +791,7 @@ namespace Renci.SshNet.Common
|
||||
|
||||
if (value._sign == 1)
|
||||
{
|
||||
if (data > (uint) int.MaxValue)
|
||||
if (data > (uint)int.MaxValue)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
@@ -850,13 +848,13 @@ namespace Renci.SshNet.Common
|
||||
public static explicit operator short(BigInteger value)
|
||||
#pragma warning restore CA2225 // Operator overloads have named alternates
|
||||
{
|
||||
var val = (int) value;
|
||||
var val = (int)value;
|
||||
if (val is < short.MinValue or > short.MaxValue)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
|
||||
return (short) val;
|
||||
return (short)val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -871,13 +869,13 @@ namespace Renci.SshNet.Common
|
||||
public static explicit operator ushort(BigInteger value)
|
||||
#pragma warning restore CA2225 // Operator overloads have named alternates
|
||||
{
|
||||
var val = (uint) value;
|
||||
var val = (uint)value;
|
||||
if (val > ushort.MaxValue)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
|
||||
return (ushort) val;
|
||||
return (ushort)val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -891,13 +889,13 @@ namespace Renci.SshNet.Common
|
||||
public static explicit operator byte(BigInteger value)
|
||||
#pragma warning restore CA2225 // Operator overloads have named alternates
|
||||
{
|
||||
var val = (uint) value;
|
||||
var val = (uint)value;
|
||||
if (val > byte.MaxValue)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
|
||||
return (byte) val;
|
||||
return (byte)val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -912,13 +910,13 @@ namespace Renci.SshNet.Common
|
||||
public static explicit operator sbyte(BigInteger value)
|
||||
#pragma warning restore CA2225 // Operator overloads have named alternates
|
||||
{
|
||||
var val = (int) value;
|
||||
var val = (int)value;
|
||||
if (val is < sbyte.MinValue or > sbyte.MaxValue)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
|
||||
return (sbyte) val;
|
||||
return (sbyte)val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -948,7 +946,7 @@ namespace Renci.SshNet.Common
|
||||
{
|
||||
if (value._sign == 1)
|
||||
{
|
||||
return (long) low;
|
||||
return (long)low;
|
||||
}
|
||||
|
||||
var res = (long)low;
|
||||
@@ -1039,7 +1037,7 @@ namespace Renci.SshNet.Common
|
||||
case 1:
|
||||
return BuildDouble(value._sign, value._data[0], 0);
|
||||
case 2:
|
||||
return BuildDouble(value._sign, (ulong) value._data[1] << 32 | (ulong) value._data[0], 0);
|
||||
return BuildDouble(value._sign, (ulong)value._data[1] << 32 | (ulong)value._data[0], 0);
|
||||
default:
|
||||
var index = value._data.Length - 1;
|
||||
var word = value._data[index];
|
||||
@@ -1070,7 +1068,7 @@ namespace Renci.SshNet.Common
|
||||
public static explicit operator float(BigInteger value)
|
||||
#pragma warning restore CA2225 // Operator overloads have named alternates
|
||||
{
|
||||
return (float) (double) value;
|
||||
return (float)(double)value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1098,17 +1096,17 @@ namespace Renci.SshNet.Common
|
||||
int lo = 0, mi = 0, hi = 0;
|
||||
if (data.Length > 2)
|
||||
{
|
||||
hi = (int) data[2];
|
||||
hi = (int)data[2];
|
||||
}
|
||||
|
||||
if (data.Length > 1)
|
||||
{
|
||||
mi = (int) data[1];
|
||||
mi = (int)data[1];
|
||||
}
|
||||
|
||||
if (data.Length > 0)
|
||||
{
|
||||
lo = (int) data[0];
|
||||
lo = (int)data[0];
|
||||
}
|
||||
|
||||
return new decimal(lo, mi, hi, value._sign < 0, 0);
|
||||
@@ -1330,9 +1328,7 @@ namespace Renci.SshNet.Common
|
||||
|
||||
if (left._sign == 0)
|
||||
{
|
||||
#pragma warning disable SA1021 // Negative signs should be spaced correctly
|
||||
return new BigInteger((short) -right._sign, right._data);
|
||||
#pragma warning restore SA1021 // Negative signs should be spaced correctly
|
||||
return new BigInteger((short)-right._sign, right._data);
|
||||
}
|
||||
|
||||
if (left._sign == right._sign)
|
||||
@@ -1404,7 +1400,7 @@ namespace Renci.SshNet.Common
|
||||
ulong carry = 0;
|
||||
for (var j = 0; j < b.Length; ++j)
|
||||
{
|
||||
carry = carry + (((ulong) ai) * b[j]) + res[k];
|
||||
carry = carry + (((ulong)ai) * b[j]) + res[k];
|
||||
res[k++] = (uint)carry;
|
||||
carry >>= 32;
|
||||
}
|
||||
@@ -1428,7 +1424,7 @@ namespace Renci.SshNet.Common
|
||||
Array.Resize(ref res, m + 1);
|
||||
}
|
||||
|
||||
return new BigInteger((short) (left._sign*right._sign), res);
|
||||
return new BigInteger((short)(left._sign * right._sign), res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1528,9 +1524,7 @@ namespace Renci.SshNet.Common
|
||||
return value;
|
||||
}
|
||||
|
||||
#pragma warning disable SA1021 // Negative signs should be spaced correctly
|
||||
return new BigInteger((short) -value._sign, value._data);
|
||||
#pragma warning restore SA1021 // Negative signs should be spaced correctly
|
||||
return new BigInteger((short)-value._sign, value._data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2770,9 +2764,9 @@ namespace Renci.SshNet.Common
|
||||
for (var i = 0; i < v.Length; ++i)
|
||||
{
|
||||
var word = v[i];
|
||||
carry = (ulong) ~word + carry;
|
||||
word = (uint) carry;
|
||||
carry = (uint) (carry >> 32);
|
||||
carry = (ulong)~word + carry;
|
||||
word = (uint)carry;
|
||||
carry = (uint)(carry >> 32);
|
||||
res[i] = word;
|
||||
}
|
||||
|
||||
@@ -2833,7 +2827,7 @@ namespace Renci.SshNet.Common
|
||||
while (a != 0)
|
||||
{
|
||||
a = DivRem(a, radix, out var rem);
|
||||
digits.Add(characterSet[(int) rem]);
|
||||
digits.Add(characterSet[(int)rem]);
|
||||
}
|
||||
|
||||
if (_sign == -1 && radix == 10)
|
||||
@@ -3022,7 +3016,7 @@ namespace Renci.SshNet.Common
|
||||
if (fp != null)
|
||||
{
|
||||
var typeNfi = typeof(NumberFormatInfo);
|
||||
nfi = (NumberFormatInfo) fp.GetFormat(typeNfi);
|
||||
nfi = (NumberFormatInfo)fp.GetFormat(typeNfi);
|
||||
}
|
||||
|
||||
nfi ??= NumberFormatInfo.CurrentInfo;
|
||||
@@ -3172,15 +3166,15 @@ namespace Renci.SshNet.Common
|
||||
byte digitValue;
|
||||
if (char.IsDigit(hexDigit))
|
||||
{
|
||||
digitValue = (byte) (hexDigit - '0');
|
||||
digitValue = (byte)(hexDigit - '0');
|
||||
}
|
||||
else if (char.IsLower(hexDigit))
|
||||
{
|
||||
digitValue = (byte) (hexDigit - 'a' + 10);
|
||||
digitValue = (byte)(hexDigit - 'a' + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitValue = (byte) (hexDigit - 'A' + 10);
|
||||
digitValue = (byte)(hexDigit - 'A' + 10);
|
||||
}
|
||||
|
||||
if (firstHexDigit && digitValue >= 8)
|
||||
@@ -3484,7 +3478,7 @@ namespace Renci.SshNet.Common
|
||||
}
|
||||
|
||||
exc = null;
|
||||
exponent = (int) exp;
|
||||
exponent = (int)exp;
|
||||
pos = i;
|
||||
return true;
|
||||
}
|
||||
@@ -3606,7 +3600,7 @@ namespace Renci.SshNet.Common
|
||||
|
||||
if (c is >= '0' and <= '9')
|
||||
{
|
||||
var d = (byte) (c - '0');
|
||||
var d = (byte)(c - '0');
|
||||
|
||||
val = (val * 10) + d;
|
||||
|
||||
@@ -4080,7 +4074,7 @@ namespace Renci.SshNet.Common
|
||||
/// </returns>
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
var hash = (uint) (_sign * 0x01010101u);
|
||||
var hash = (uint)(_sign * 0x01010101u);
|
||||
if (_data != null)
|
||||
{
|
||||
foreach (var bit in _data)
|
||||
@@ -4089,7 +4083,7 @@ namespace Renci.SshNet.Common
|
||||
}
|
||||
}
|
||||
|
||||
return (int) hash;
|
||||
return (int)hash;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4347,8 +4341,8 @@ namespace Renci.SshNet.Common
|
||||
other = -other;
|
||||
}
|
||||
|
||||
var low = (uint) other;
|
||||
var high = (uint) ((ulong) other >> 32);
|
||||
var low = (uint)other;
|
||||
var high = (uint)((ulong)other >> 32);
|
||||
|
||||
var r = LongCompare(low, high);
|
||||
if (ls == -1)
|
||||
@@ -4643,14 +4637,14 @@ namespace Renci.SshNet.Common
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
sum += a[i];
|
||||
res[i] = (uint) sum;
|
||||
res[i] = (uint)sum;
|
||||
sum >>= 32;
|
||||
}
|
||||
|
||||
if (sum != 0)
|
||||
{
|
||||
Array.Resize(ref res, len + 1);
|
||||
res[i] = (uint) sum;
|
||||
res[i] = (uint)sum;
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -4876,7 +4870,7 @@ namespace Renci.SshNet.Common
|
||||
q[j] = (uint)div;
|
||||
}
|
||||
|
||||
r[0] = (uint) rem;
|
||||
r[0] = (uint)rem;
|
||||
}
|
||||
else if (m >= n)
|
||||
{
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Renci.SshNet.Common
|
||||
return data;
|
||||
}
|
||||
|
||||
return new[] { (byte) length };
|
||||
return new[] { (byte)length };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Abstractions;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Renci.SshNet.Common
|
||||
return BinaryPrimitives.ReadUInt16LittleEndian(buffer);
|
||||
#else
|
||||
ushort n = buffer[0];
|
||||
n |= (ushort) (buffer[1] << 8);
|
||||
n |= (ushort)(buffer[1] << 8);
|
||||
return n;
|
||||
#endif
|
||||
}
|
||||
@@ -37,9 +37,9 @@ namespace Renci.SshNet.Common
|
||||
return BinaryPrimitives.ReadUInt32LittleEndian(buffer);
|
||||
#else
|
||||
uint n = buffer[0];
|
||||
n |= (uint) buffer[1] << 8;
|
||||
n |= (uint) buffer[2] << 16;
|
||||
n |= (uint) buffer[3] << 24;
|
||||
n |= (uint)buffer[1] << 8;
|
||||
n |= (uint)buffer[2] << 16;
|
||||
n |= (uint)buffer[3] << 24;
|
||||
return n;
|
||||
#endif
|
||||
}
|
||||
@@ -55,13 +55,13 @@ namespace Renci.SshNet.Common
|
||||
return BinaryPrimitives.ReadUInt64LittleEndian(buffer);
|
||||
#else
|
||||
ulong n = buffer[0];
|
||||
n |= (ulong) buffer[1] << 8;
|
||||
n |= (ulong) buffer[2] << 16;
|
||||
n |= (ulong) buffer[3] << 24;
|
||||
n |= (ulong) buffer[4] << 32;
|
||||
n |= (ulong) buffer[5] << 40;
|
||||
n |= (ulong) buffer[6] << 48;
|
||||
n |= (ulong) buffer[7] << 56;
|
||||
n |= (ulong)buffer[1] << 8;
|
||||
n |= (ulong)buffer[2] << 16;
|
||||
n |= (ulong)buffer[3] << 24;
|
||||
n |= (ulong)buffer[4] << 32;
|
||||
n |= (ulong)buffer[5] << 40;
|
||||
n |= (ulong)buffer[6] << 48;
|
||||
n |= (ulong)buffer[7] << 56;
|
||||
return n;
|
||||
#endif
|
||||
}
|
||||
@@ -87,8 +87,8 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(buffer, value);
|
||||
#else
|
||||
buffer[0] = (byte) (value & 0x00FF);
|
||||
buffer[1] = (byte) ((value & 0xFF00) >> 8);
|
||||
buffer[0] = (byte)(value & 0x00FF);
|
||||
buffer[1] = (byte)((value & 0xFF00) >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(buffer, value);
|
||||
#else
|
||||
buffer[0] = (byte) (value & 0x000000FF);
|
||||
buffer[1] = (byte) ((value & 0x0000FF00) >> 8);
|
||||
buffer[2] = (byte) ((value & 0x00FF0000) >> 16);
|
||||
buffer[3] = (byte) ((value & 0xFF000000) >> 24);
|
||||
buffer[0] = (byte)(value & 0x000000FF);
|
||||
buffer[1] = (byte)((value & 0x0000FF00) >> 8);
|
||||
buffer[2] = (byte)((value & 0x00FF0000) >> 16);
|
||||
buffer[3] = (byte)((value & 0xFF000000) >> 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -141,14 +141,14 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt64LittleEndian(buffer, value);
|
||||
#else
|
||||
buffer[0] = (byte) (value & 0x00000000000000FF);
|
||||
buffer[1] = (byte) ((value & 0x000000000000FF00) >> 8);
|
||||
buffer[2] = (byte) ((value & 0x0000000000FF0000) >> 16);
|
||||
buffer[3] = (byte) ((value & 0x00000000FF000000) >> 24);
|
||||
buffer[4] = (byte) ((value & 0x000000FF00000000) >> 32);
|
||||
buffer[5] = (byte) ((value & 0x0000FF0000000000) >> 40);
|
||||
buffer[6] = (byte) ((value & 0x00FF000000000000) >> 48);
|
||||
buffer[7] = (byte) ((value & 0xFF00000000000000) >> 56);
|
||||
buffer[0] = (byte)(value & 0x00000000000000FF);
|
||||
buffer[1] = (byte)((value & 0x000000000000FF00) >> 8);
|
||||
buffer[2] = (byte)((value & 0x0000000000FF0000) >> 16);
|
||||
buffer[3] = (byte)((value & 0x00000000FF000000) >> 24);
|
||||
buffer[4] = (byte)((value & 0x000000FF00000000) >> 32);
|
||||
buffer[5] = (byte)((value & 0x0000FF0000000000) >> 40);
|
||||
buffer[6] = (byte)((value & 0x00FF000000000000) >> 48);
|
||||
buffer[7] = (byte)((value & 0xFF00000000000000) >> 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt16BigEndian(buffer.AsSpan(offset), value);
|
||||
#else
|
||||
buffer[offset] = (byte) (value >> 8);
|
||||
buffer[offset + 1] = (byte) (value & 0x00FF);
|
||||
buffer[offset] = (byte)(value >> 8);
|
||||
buffer[offset + 1] = (byte)(value & 0x00FF);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -179,10 +179,10 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt32BigEndian(buffer.AsSpan(offset), value);
|
||||
#else
|
||||
buffer[offset++] = (byte) ((value & 0xFF000000) >> 24);
|
||||
buffer[offset++] = (byte) ((value & 0x00FF0000) >> 16);
|
||||
buffer[offset++] = (byte) ((value & 0x0000FF00) >> 8);
|
||||
buffer[offset] = (byte) (value & 0x000000FF);
|
||||
buffer[offset++] = (byte)((value & 0xFF000000) >> 24);
|
||||
buffer[offset++] = (byte)((value & 0x00FF0000) >> 16);
|
||||
buffer[offset++] = (byte)((value & 0x0000FF00) >> 8);
|
||||
buffer[offset] = (byte)(value & 0x000000FF);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -205,14 +205,14 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
BinaryPrimitives.WriteUInt64BigEndian(buffer.AsSpan(offset), value);
|
||||
#else
|
||||
buffer[offset++] = (byte) ((value & 0xFF00000000000000) >> 56);
|
||||
buffer[offset++] = (byte) ((value & 0x00FF000000000000) >> 48);
|
||||
buffer[offset++] = (byte) ((value & 0x0000FF0000000000) >> 40);
|
||||
buffer[offset++] = (byte) ((value & 0x000000FF00000000) >> 32);
|
||||
buffer[offset++] = (byte) ((value & 0x00000000FF000000) >> 24);
|
||||
buffer[offset++] = (byte) ((value & 0x0000000000FF0000) >> 16);
|
||||
buffer[offset++] = (byte) ((value & 0x000000000000FF00) >> 8);
|
||||
buffer[offset] = (byte) (value & 0x00000000000000FF);
|
||||
buffer[offset++] = (byte)((value & 0xFF00000000000000) >> 56);
|
||||
buffer[offset++] = (byte)((value & 0x00FF000000000000) >> 48);
|
||||
buffer[offset++] = (byte)((value & 0x0000FF0000000000) >> 40);
|
||||
buffer[offset++] = (byte)((value & 0x000000FF00000000) >> 32);
|
||||
buffer[offset++] = (byte)((value & 0x00000000FF000000) >> 24);
|
||||
buffer[offset++] = (byte)((value & 0x0000000000FF0000) >> 16);
|
||||
buffer[offset++] = (byte)((value & 0x000000000000FF00) >> 8);
|
||||
buffer[offset] = (byte)(value & 0x00000000000000FF);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
return BinaryPrimitives.ReadUInt16BigEndian(buffer);
|
||||
#else
|
||||
return (ushort) (buffer[0] << 8 | buffer[1]);
|
||||
return (ushort)(buffer[0] << 8 | buffer[1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -241,9 +241,9 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
return BinaryPrimitives.ReadUInt32BigEndian(buffer.AsSpan(offset));
|
||||
#else
|
||||
return (uint) buffer[offset + 0] << 24 |
|
||||
(uint) buffer[offset + 1] << 16 |
|
||||
(uint) buffer[offset + 2] << 8 |
|
||||
return (uint)buffer[offset + 0] << 24 |
|
||||
(uint)buffer[offset + 1] << 16 |
|
||||
(uint)buffer[offset + 2] << 8 |
|
||||
buffer[offset + 3];
|
||||
#endif
|
||||
}
|
||||
@@ -268,13 +268,13 @@ namespace Renci.SshNet.Common
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
return BinaryPrimitives.ReadUInt64BigEndian(buffer);
|
||||
#else
|
||||
return (ulong) buffer[0] << 56 |
|
||||
(ulong) buffer[1] << 48 |
|
||||
(ulong) buffer[2] << 40 |
|
||||
(ulong) buffer[3] << 32 |
|
||||
(ulong) buffer[4] << 24 |
|
||||
(ulong) buffer[5] << 16 |
|
||||
(ulong) buffer[6] << 8 |
|
||||
return (ulong)buffer[0] << 56 |
|
||||
(ulong)buffer[1] << 48 |
|
||||
(ulong)buffer[2] << 40 |
|
||||
(ulong)buffer[3] << 32 |
|
||||
(ulong)buffer[4] << 24 |
|
||||
(ulong)buffer[5] << 16 |
|
||||
(ulong)buffer[6] << 8 |
|
||||
buffer[7];
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Renci.SshNet.Common
|
||||
var line = new byte[lineWidth];
|
||||
var indentChars = new string(' ', indentLevel);
|
||||
|
||||
for (var pos = 0; pos < data.Length; )
|
||||
for (var pos = 0; pos < data.Length;)
|
||||
{
|
||||
var linePos = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
#if NETFRAMEWORK
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
#endif // NETFRAMEWORK
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Renci.SshNet.Common
|
||||
/// </returns>
|
||||
protected byte[] ReadBytes()
|
||||
{
|
||||
var bytesLength = (int) (_stream.Length - _stream.Position);
|
||||
var bytesLength = (int)(_stream.Length - _stream.Position);
|
||||
var data = new byte[bytesLength];
|
||||
_ = _stream.Read(data, 0, bytesLength);
|
||||
return data;
|
||||
@@ -173,7 +173,7 @@ namespace Renci.SshNet.Common
|
||||
throw new InvalidOperationException("Attempt to read past the end of the SSH data stream.");
|
||||
}
|
||||
|
||||
return (byte) byteRead;
|
||||
return (byte)byteRead;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -319,7 +319,7 @@ namespace Renci.SshNet.Common
|
||||
/// <param name="data"><see cref="bool" /> data to write.</param>
|
||||
protected void Write(bool data)
|
||||
{
|
||||
Write(data ? (byte) 1 : (byte) 0);
|
||||
Write(data ? (byte)1 : (byte)0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Renci.SshNet.Common
|
||||
var count = encoding.GetByteCount(value);
|
||||
var bytes = count <= 256 ? stackalloc byte[count] : new byte[count];
|
||||
encoding.GetBytes(value, bytes);
|
||||
Write((uint) count);
|
||||
Write((uint)count);
|
||||
Write(bytes);
|
||||
#else
|
||||
var bytes = encoding.GetBytes(s);
|
||||
@@ -183,7 +183,7 @@ namespace Renci.SshNet.Common
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> or <paramref name="count"/> is negative.</exception>
|
||||
public void WriteBinary(byte[] buffer, int offset, int count)
|
||||
{
|
||||
Write((uint) count);
|
||||
Write((uint)count);
|
||||
Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Renci.SshNet.Common
|
||||
public BigInteger ReadBigInt()
|
||||
{
|
||||
var length = ReadUInt32();
|
||||
var data = ReadBytes((int) length);
|
||||
var data = ReadBytes((int)length);
|
||||
return new BigInteger(data.Reverse());
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace Renci.SshNet.Common
|
||||
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue));
|
||||
}
|
||||
|
||||
var bytes = ReadBytes((int) length);
|
||||
var bytes = ReadBytes((int)length);
|
||||
return encoding.GetString(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace System.Threading.Tasks
|
||||
public bool IsCompleted => _task.IsCompleted;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public WaitHandle AsyncWaitHandle => ((IAsyncResult) _task).AsyncWaitHandle;
|
||||
public WaitHandle AsyncWaitHandle => ((IAsyncResult)_task).AsyncWaitHandle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Renci.SshNet.Common
|
||||
var timeoutInMilliseconds = timeSpan.TotalMilliseconds;
|
||||
return timeoutInMilliseconds is < -1d or > int.MaxValue
|
||||
? throw new ArgumentOutOfRangeException(callerMemberName, OutOfRangeTimeoutMessage)
|
||||
: (int) timeoutInMilliseconds;
|
||||
: (int)timeoutInMilliseconds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Renci.SshNet.Connection
|
||||
if (statusMatch.Success)
|
||||
{
|
||||
var httpStatusCode = statusMatch.Result("${statusCode}");
|
||||
statusCode = (HttpStatusCode) int.Parse(httpStatusCode, CultureInfo.InvariantCulture);
|
||||
statusCode = (HttpStatusCode)int.Parse(httpStatusCode, CultureInfo.InvariantCulture);
|
||||
if (statusCode != HttpStatusCode.OK)
|
||||
{
|
||||
throw new ProxyException($"HTTP: Status code {httpStatusCode}, \"{statusMatch.Result("${reasonPhrase}")}\"");
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Renci.SshNet.Connection
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(o => ((Socket) o).Dispose(), socket, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
#pragma warning disable MA0042 // Do not use blocking calls in an async method; false positive caused by https://github.com/meziantou/Meziantou.Analyzer/issues/613
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Renci.SshNet.Connection
|
||||
throw new ProxyException($"SOCKS5: Chosen authentication method '0x{authenticationMethod:x2}' is not supported.");
|
||||
}
|
||||
|
||||
var connectionRequest = CreateSocks5ConnectionRequest(connectionInfo.Host, (ushort) connectionInfo.Port);
|
||||
var connectionRequest = CreateSocks5ConnectionRequest(connectionInfo.Host, (ushort)connectionInfo.Port);
|
||||
SocketAbstraction.Send(socket, connectionRequest);
|
||||
|
||||
// Read Server SOCKS5 version
|
||||
@@ -133,7 +133,7 @@ namespace Renci.SshNet.Connection
|
||||
break;
|
||||
case 0x04:
|
||||
var ipv6 = new byte[16];
|
||||
_ =SocketRead(socket, ipv6, 0, 16, connectionInfo.Timeout);
|
||||
_ = SocketRead(socket, ipv6, 0, 16, connectionInfo.Timeout);
|
||||
break;
|
||||
default:
|
||||
throw new ProxyException(string.Format("Address type '{0}' is not supported.", addressType));
|
||||
@@ -181,17 +181,17 @@ namespace Renci.SshNet.Connection
|
||||
authenticationRequest[index++] = 0x01;
|
||||
|
||||
// Length of the username
|
||||
authenticationRequest[index++] = (byte) username.Length;
|
||||
authenticationRequest[index++] = (byte)username.Length;
|
||||
|
||||
// Username
|
||||
_ = SshData.Ascii.GetBytes(username, 0, username.Length, authenticationRequest, index);
|
||||
index += username.Length;
|
||||
|
||||
// Length of the password
|
||||
authenticationRequest[index++] = (byte) password.Length;
|
||||
authenticationRequest[index++] = (byte)password.Length;
|
||||
|
||||
// Password
|
||||
_ =SshData.Ascii.GetBytes(password, 0, password.Length, authenticationRequest, index);
|
||||
_ = SshData.Ascii.GetBytes(password, 0, password.Length, authenticationRequest, index);
|
||||
|
||||
return authenticationRequest;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Renci.SshNet
|
||||
ip = Dns.GetHostAddresses(BoundHost)[0];
|
||||
}
|
||||
|
||||
var ep = new IPEndPoint(ip, (int) BoundPort);
|
||||
var ep = new IPEndPoint(ip, (int)BoundPort);
|
||||
|
||||
_listener = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };
|
||||
_listener.Bind(ep);
|
||||
@@ -738,7 +738,7 @@ namespace Renci.SshNet
|
||||
break;
|
||||
}
|
||||
|
||||
_ = text.Append((char) byteRead);
|
||||
_ = text.Append((char)byteRead);
|
||||
}
|
||||
|
||||
return text.ToString();
|
||||
|
||||
@@ -201,14 +201,14 @@ namespace Renci.SshNet
|
||||
private void InternalStart()
|
||||
{
|
||||
var addr = Dns.GetHostAddresses(BoundHost)[0];
|
||||
var ep = new IPEndPoint(addr, (int) BoundPort);
|
||||
var ep = new IPEndPoint(addr, (int)BoundPort);
|
||||
|
||||
_listener = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };
|
||||
_listener.Bind(ep);
|
||||
_listener.Listen(5);
|
||||
|
||||
// update bound port (in case original was passed as zero)
|
||||
BoundPort = (uint) ((IPEndPoint) _listener.LocalEndPoint).Port;
|
||||
BoundPort = (uint)((IPEndPoint)_listener.LocalEndPoint).Port;
|
||||
|
||||
Session.ErrorOccured += Session_ErrorOccured;
|
||||
Session.Disconnected += Session_Disconnected;
|
||||
@@ -305,10 +305,10 @@ namespace Renci.SshNet
|
||||
|
||||
try
|
||||
{
|
||||
var originatorEndPoint = (IPEndPoint) clientSocket.RemoteEndPoint;
|
||||
var originatorEndPoint = (IPEndPoint)clientSocket.RemoteEndPoint;
|
||||
|
||||
RaiseRequestReceived(originatorEndPoint.Address.ToString(),
|
||||
(uint) originatorEndPoint.Port);
|
||||
(uint)originatorEndPoint.Port);
|
||||
|
||||
using (var channel = Session.CreateChannelDirectTcpip())
|
||||
{
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Renci.SshNet
|
||||
using (var channel = Session.CreateChannelForwardedTcpip(channelOpenMessage.LocalChannelNumber, channelOpenMessage.InitialWindowSize, channelOpenMessage.MaximumPacketSize))
|
||||
{
|
||||
channel.Exception += Channel_Exception;
|
||||
channel.Bind(new IPEndPoint(HostAddress, (int) Port), this);
|
||||
channel.Bind(new IPEndPoint(HostAddress, (int)Port), this);
|
||||
}
|
||||
}
|
||||
catch (Exception exp)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Renci.SshNet
|
||||
|
||||
public static bool operator !=(ForwardedPortStatus left, ForwardedPortStatus right)
|
||||
{
|
||||
return !(left==right);
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Messages.Authentication
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Renci.SshNet.Messages.Authentication
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
Write((uint) Responses.Count);
|
||||
Write((uint)Responses.Count);
|
||||
|
||||
foreach (var response in Responses)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Messages.Authentication
|
||||
|
||||
@@ -141,15 +141,15 @@ namespace Renci.SshNet.Messages.Connection
|
||||
// write total length of encoded terminal modes, which is 1 bytes for the opcode / terminal mode
|
||||
// and 4 bytes for the uint argument for each entry; the encoded terminal modes are terminated by
|
||||
// opcode TTY_OP_END (which is 1 byte)
|
||||
Write(((uint) TerminalModeValues.Count*(1 + 4)) + 1);
|
||||
Write(((uint)TerminalModeValues.Count * (1 + 4)) + 1);
|
||||
|
||||
foreach (var item in TerminalModeValues)
|
||||
{
|
||||
Write((byte) item.Key);
|
||||
Write((byte)item.Key);
|
||||
Write(item.Value);
|
||||
}
|
||||
|
||||
Write((byte) TerminalModes.TTY_OP_END);
|
||||
Write((byte)TerminalModes.TTY_OP_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Renci.SshNet.Messages
|
||||
WriteBytes(sshDataStream);
|
||||
}
|
||||
|
||||
messageLength = (int) sshDataStream.Length - (outboundPacketSequenceSize + 4 + 1);
|
||||
messageLength = (int)sshDataStream.Length - (outboundPacketSequenceSize + 4 + 1);
|
||||
|
||||
var packetLength = messageLength + 4 + 1;
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Renci.SshNet.Messages
|
||||
|
||||
private static uint GetPacketDataLength(int messageLength, byte paddingLength)
|
||||
{
|
||||
return (uint) (messageLength + paddingLength + 1);
|
||||
return (uint)(messageLength + paddingLength + 1);
|
||||
}
|
||||
|
||||
private static byte GetPaddingLength(byte paddingMultiplier, long packetLength)
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
/// </summary>
|
||||
protected override void LoadData()
|
||||
{
|
||||
ReasonCode = (DisconnectReason) ReadUInt32();
|
||||
ReasonCode = (DisconnectReason)ReadUInt32();
|
||||
_description = ReadBinary();
|
||||
_language = ReadBinary();
|
||||
}
|
||||
@@ -103,7 +103,7 @@
|
||||
/// </summary>
|
||||
protected override void SaveData()
|
||||
{
|
||||
Write((uint) ReasonCode);
|
||||
Write((uint)ReasonCode);
|
||||
WriteBinaryString(_description);
|
||||
WriteBinaryString(_language);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Messages.Transport
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Messages.Transport
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Messages.Transport
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Renci.SshNet
|
||||
protected override void SaveData()
|
||||
{
|
||||
WriteBinaryString(_sessionId);
|
||||
Write((byte) RequestMessage.AuthenticationMessageCode);
|
||||
Write((byte)RequestMessage.AuthenticationMessageCode);
|
||||
WriteBinaryString(_message.Username);
|
||||
WriteBinaryString(_serviceName);
|
||||
WriteBinaryString(_authenticationMethod);
|
||||
|
||||
@@ -473,9 +473,9 @@ namespace Renci.SshNet
|
||||
var rounds = 0;
|
||||
if (kdfOptionsLen > 0)
|
||||
{
|
||||
var saltLength = (int) keyReader.ReadUInt32();
|
||||
var saltLength = (int)keyReader.ReadUInt32();
|
||||
salt = keyReader.ReadBytes(saltLength);
|
||||
rounds = (int) keyReader.ReadUInt32();
|
||||
rounds = (int)keyReader.ReadUInt32();
|
||||
}
|
||||
|
||||
// number of public keys, only supporting 1 for now
|
||||
@@ -489,7 +489,7 @@ namespace Renci.SshNet
|
||||
_ = keyReader.ReadString(Encoding.UTF8);
|
||||
|
||||
// possibly encrypted private key
|
||||
var privateKeyLength = (int) keyReader.ReadUInt32();
|
||||
var privateKeyLength = (int)keyReader.ReadUInt32();
|
||||
var privateKeyBytes = keyReader.ReadBytes(privateKeyLength);
|
||||
|
||||
// decrypt private key if necessary
|
||||
@@ -551,8 +551,8 @@ namespace Renci.SshNet
|
||||
var privateKeyReader = new SshDataReader(privateKeyBytes);
|
||||
|
||||
// check ints should match, they wouldn't match for example if the wrong passphrase was supplied
|
||||
var checkInt1 = (int) privateKeyReader.ReadUInt32();
|
||||
var checkInt2 = (int) privateKeyReader.ReadUInt32();
|
||||
var checkInt1 = (int)privateKeyReader.ReadUInt32();
|
||||
var checkInt2 = (int)privateKeyReader.ReadUInt32();
|
||||
if (checkInt1 != checkInt2)
|
||||
{
|
||||
throw new SshException(string.Format(CultureInfo.InvariantCulture,
|
||||
@@ -583,7 +583,7 @@ namespace Renci.SshNet
|
||||
case "ecdsa-sha2-nistp384":
|
||||
case "ecdsa-sha2-nistp521":
|
||||
// curve
|
||||
var len = (int) privateKeyReader.ReadUInt32();
|
||||
var len = (int)privateKeyReader.ReadUInt32();
|
||||
var curve = Encoding.ASCII.GetString(privateKeyReader.ReadBytes(len));
|
||||
|
||||
// public key
|
||||
@@ -613,7 +613,7 @@ namespace Renci.SshNet
|
||||
var padding = privateKeyReader.ReadBytes();
|
||||
for (var i = 0; i < padding.Length; i++)
|
||||
{
|
||||
if ((int) padding[i] != i + 1)
|
||||
if ((int)padding[i] != i + 1)
|
||||
{
|
||||
throw new SshException("Padding of openssh key format contained wrong byte at position: " +
|
||||
i.ToString(CultureInfo.InvariantCulture));
|
||||
@@ -648,7 +648,7 @@ namespace Renci.SshNet
|
||||
var key = _key;
|
||||
if (key != null)
|
||||
{
|
||||
((IDisposable) key).Dispose();
|
||||
((IDisposable)key).Dispose();
|
||||
_key = null;
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ namespace Renci.SshNet
|
||||
/// <returns>mpint read.</returns>
|
||||
public BigInteger ReadBigIntWithBits()
|
||||
{
|
||||
var length = (int) base.ReadUInt32();
|
||||
var length = (int)base.ReadUInt32();
|
||||
|
||||
length = (length + 7) / 8;
|
||||
|
||||
|
||||
@@ -623,7 +623,7 @@ namespace Renci.SshNet
|
||||
|
||||
while (b != SshNet.Session.LineFeed)
|
||||
{
|
||||
buffer.Add((byte) b);
|
||||
buffer.Add((byte)b);
|
||||
b = ReadByte(stream);
|
||||
}
|
||||
|
||||
@@ -651,8 +651,8 @@ namespace Renci.SshNet
|
||||
#else
|
||||
var zeroTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
#endif
|
||||
var modificationSeconds = (long) (fileOrDirectory.LastWriteTimeUtc - zeroTime).TotalSeconds;
|
||||
var accessSeconds = (long) (fileOrDirectory.LastAccessTimeUtc - zeroTime).TotalSeconds;
|
||||
var modificationSeconds = (long)(fileOrDirectory.LastWriteTimeUtc - zeroTime).TotalSeconds;
|
||||
var accessSeconds = (long)(fileOrDirectory.LastAccessTimeUtc - zeroTime).TotalSeconds;
|
||||
SendData(channel, string.Format(CultureInfo.InvariantCulture, "T{0} 0 {1} 0\n", modificationSeconds, accessSeconds));
|
||||
CheckReturnCode(input);
|
||||
}
|
||||
@@ -707,7 +707,7 @@ namespace Renci.SshNet
|
||||
|
||||
do
|
||||
{
|
||||
var read = input.Read(buffer, 0, (int) Math.Min(needToRead, BufferSize));
|
||||
var read = input.Read(buffer, 0, (int)Math.Min(needToRead, BufferSize));
|
||||
|
||||
output.Write(buffer, 0, read);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Security.Cryptography.Ciphers;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
|
||||
// creates the Counter array filled with incrementing copies of IV
|
||||
// creates the Counter array filled with incrementing copies of IV
|
||||
private void CTRCreateCounterArray(byte[] buffer)
|
||||
{
|
||||
for (var i = 0; i < buffer.Length; i += 16)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
_impl = new BclImpl(
|
||||
key,
|
||||
iv,
|
||||
(System.Security.Cryptography.CipherMode) mode,
|
||||
(System.Security.Cryptography.CipherMode)mode,
|
||||
pkcs7Padding ? PaddingMode.PKCS7 : PaddingMode.None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
// reset the state of the engine
|
||||
for (var i = 0; i < STATE_LENGTH; i++)
|
||||
{
|
||||
_engineState[i] = (byte) i;
|
||||
_engineState[i] = (byte)i;
|
||||
}
|
||||
|
||||
var i1 = 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
@@ -708,15 +709,15 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
private static void Bits32ToInts(uint inData, int[] b, int offset)
|
||||
{
|
||||
b[offset + 3] = (int) (inData & 0xff);
|
||||
b[offset + 2] = (int) ((inData >> 8) & 0xff);
|
||||
b[offset + 1] = (int) ((inData >> 16) & 0xff);
|
||||
b[offset] = (int) ((inData >> 24) & 0xff);
|
||||
b[offset + 3] = (int)(inData & 0xff);
|
||||
b[offset + 2] = (int)((inData >> 8) & 0xff);
|
||||
b[offset + 1] = (int)((inData >> 16) & 0xff);
|
||||
b[offset] = (int)((inData >> 24) & 0xff);
|
||||
}
|
||||
|
||||
private static uint IntsTo32Bits(int[] b, int i)
|
||||
{
|
||||
return (uint) (((b[i] & 0xff) << 24) |
|
||||
return (uint)(((b[i] & 0xff) << 24) |
|
||||
((b[i + 1] & 0xff) << 16) |
|
||||
((b[i + 2] & 0xff) << 8) |
|
||||
(b[i + 3] & 0xff));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
@@ -300,7 +301,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
{
|
||||
int l = Pc1[j];
|
||||
|
||||
pc1m[j] = (key[(uint) l >> 3] & Bytebit[l & 07]) != 0;
|
||||
pc1m[j] = (key[(uint)l >> 3] & Bytebit[l & 07]) != 0;
|
||||
}
|
||||
|
||||
for (var i = 0; i < 16; i++)
|
||||
@@ -368,15 +369,15 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
var i1 = newKey[i];
|
||||
var i2 = newKey[i + 1];
|
||||
|
||||
newKey[i] = (int) ((uint) ((i1 & 0x00fc0000) << 6) |
|
||||
(uint) ((i1 & 0x00000fc0) << 10) |
|
||||
((uint) (i2 & 0x00fc0000) >> 10) |
|
||||
((uint) (i2 & 0x00000fc0) >> 6));
|
||||
newKey[i] = (int)((uint)((i1 & 0x00fc0000) << 6) |
|
||||
(uint)((i1 & 0x00000fc0) << 10) |
|
||||
((uint)(i2 & 0x00fc0000) >> 10) |
|
||||
((uint)(i2 & 0x00000fc0) >> 6));
|
||||
|
||||
newKey[i + 1] = (int) ((uint) ((i1 & 0x0003f000) << 12) |
|
||||
(uint) ((i1 & 0x0000003f) << 16) |
|
||||
((uint) (i2 & 0x0003f000) >> 4) |
|
||||
(uint) (i2 & 0x0000003f));
|
||||
newKey[i + 1] = (int)((uint)((i1 & 0x0003f000) << 12) |
|
||||
(uint)((i1 & 0x0000003f) << 16) |
|
||||
((uint)(i2 & 0x0003f000) >> 4) |
|
||||
(uint)(i2 & 0x0000003f));
|
||||
}
|
||||
|
||||
return newKey;
|
||||
@@ -434,7 +435,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
fval |= Sp5[(work >> 8) & 0x3f];
|
||||
fval |= Sp3[(work >> 16) & 0x3f];
|
||||
fval |= Sp1[(work >> 24) & 0x3f];
|
||||
work = right ^ (uint) wKey[(round * 4) + 1];
|
||||
work = right ^ (uint)wKey[(round * 4) + 1];
|
||||
fval |= Sp8[work & 0x3f];
|
||||
fval |= Sp6[(work >> 8) & 0x3f];
|
||||
fval |= Sp4[(work >> 16) & 0x3f];
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
|
||||
|
||||
for (var i = 0; i < _blockSize; i++)
|
||||
{
|
||||
outputBuffer[outputOffset + i] = (byte) (_ivOutput[i] ^ inputBuffer[inputOffset + i]);
|
||||
outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
|
||||
}
|
||||
|
||||
return _blockSize;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings
|
||||
|
||||
for (var i = 0; i < paddinglength; i++)
|
||||
{
|
||||
output[length + i] = (byte) paddinglength;
|
||||
output[length + i] = (byte)paddinglength;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings
|
||||
|
||||
for (var i = 0; i < paddinglength; i++)
|
||||
{
|
||||
output[length + i] = (byte) paddinglength;
|
||||
output[length + i] = (byte)paddinglength;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -669,12 +669,12 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
private static int RotateLeft(int x, int bits)
|
||||
{
|
||||
return (x << bits) | (int) ((uint) x >> (32 - bits));
|
||||
return (x << bits) | (int)((uint)x >> (32 - bits));
|
||||
}
|
||||
|
||||
private static int RotateRight(int x, int bits)
|
||||
{
|
||||
return (int) ((uint) x >> bits) | (x << (32 - bits));
|
||||
return (int)((uint)x >> bits) | (x << (32 - bits));
|
||||
}
|
||||
|
||||
private static int BytesToWord(byte[] src, int srcOff)
|
||||
@@ -685,10 +685,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
private static void WordToBytes(int word, byte[] dst, int dstOff)
|
||||
{
|
||||
dst[dstOff + 3] = (byte) word;
|
||||
dst[dstOff + 2] = (byte) ((uint)word >> 8);
|
||||
dst[dstOff + 1] = (byte) ((uint)word >> 16);
|
||||
dst[dstOff] = (byte) ((uint)word >> 24);
|
||||
dst[dstOff + 3] = (byte)word;
|
||||
dst[dstOff + 2] = (byte)((uint)word >> 8);
|
||||
dst[dstOff + 1] = (byte)((uint)word >> 16);
|
||||
dst[dstOff] = (byte)((uint)word >> 24);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -187,14 +187,14 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
var t0 = Fe32_0(_gSBox, x2);
|
||||
var t1 = Fe32_3(_gSBox, x3);
|
||||
x1 ^= t0 + (2 * t1) + _gSubKeys[k--];
|
||||
x0 = (x0 << 1 | (int) ((uint) x0 >> 31)) ^ (t0 + t1 + _gSubKeys[k--]);
|
||||
x1 = (int) ((uint) x1 >> 1) | x1 << 31;
|
||||
x0 = (x0 << 1 | (int)((uint)x0 >> 31)) ^ (t0 + t1 + _gSubKeys[k--]);
|
||||
x1 = (int)((uint)x1 >> 1) | x1 << 31;
|
||||
|
||||
t0 = Fe32_0(_gSBox, x0);
|
||||
t1 = Fe32_3(_gSBox, x1);
|
||||
x3 ^= t0 + (2 * t1) + _gSubKeys[k--];
|
||||
x2 = (x2 << 1 | (int) ((uint) x2 >> 31)) ^ (t0 + t1 + _gSubKeys[k--]);
|
||||
x3 = (int) ((uint) x3 >> 1) | x3 << 31;
|
||||
x2 = (x2 << 1 | (int)((uint)x2 >> 31)) ^ (t0 + t1 + _gSubKeys[k--]);
|
||||
x3 = (int)((uint)x3 >> 1) | x3 << 31;
|
||||
}
|
||||
|
||||
Bits32ToBytes(x0 ^ _gSubKeys[INPUT_WHITEN], outputBuffer, outputOffset);
|
||||
@@ -430,9 +430,9 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
*/
|
||||
private static int RS_rem(int x)
|
||||
{
|
||||
var b = (int) (((uint) x >> 24) & 0xff);
|
||||
var b = (int)(((uint)x >> 24) & 0xff);
|
||||
var g2 = ((b << 1) ^ ((b & 0x80) != 0 ? RS_GF_FDBK : 0)) & 0xff;
|
||||
var g3 = ((int) ((uint) b >> 1) ^ ((b & 0x01) != 0 ? (int) ((uint) RS_GF_FDBK >> 1) : 0)) ^ g2;
|
||||
var g3 = ((int)((uint)b >> 1) ^ ((b & 0x01) != 0 ? (int)((uint)RS_GF_FDBK >> 1) : 0)) ^ g2;
|
||||
return (x << 8) ^ (g3 << 24) ^ (g2 << 16) ^ (g3 << 8) ^ b;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
|
||||
|
||||
private static int Fe32_3(int[] gSBox1, int x)
|
||||
{
|
||||
return gSBox1[0x000 + (2 * ((int) ((uint) x >> 24) & 0xff))] ^
|
||||
return gSBox1[0x000 + (2 * ((int)((uint)x >> 24) & 0xff))] ^
|
||||
gSBox1[0x001 + (2 * (x & 0xff))] ^
|
||||
gSBox1[0x200 + (2 * ((int)((uint)x >> 8) & 0xff))] ^
|
||||
gSBox1[0x201 + (2 * ((int)((uint)x >> 16) & 0xff))];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Security.Chaos.NaCl;
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue));
|
||||
}
|
||||
|
||||
return ReadBytes((int) length);
|
||||
return ReadBytes((int)length);
|
||||
}
|
||||
|
||||
protected override int BufferCapacity
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Security
|
||||
|
||||
@@ -427,11 +427,11 @@ namespace Renci.SshNet.Security
|
||||
while (size > result.Count)
|
||||
{
|
||||
var sessionKeyAdjustment = new SessionKeyAdjustment
|
||||
{
|
||||
SharedKey = sharedKey,
|
||||
ExchangeHash = exchangeHash,
|
||||
Key = key,
|
||||
};
|
||||
{
|
||||
SharedKey = sharedKey,
|
||||
ExchangeHash = exchangeHash,
|
||||
Key = key,
|
||||
};
|
||||
|
||||
result.AddRange(Hash(sessionKeyAdjustment.GetBytes()));
|
||||
}
|
||||
@@ -452,12 +452,12 @@ namespace Renci.SshNet.Security
|
||||
private static byte[] GenerateSessionKey(byte[] sharedKey, byte[] exchangeHash, char p, byte[] sessionId)
|
||||
{
|
||||
var sessionKeyGeneration = new SessionKeyGeneration
|
||||
{
|
||||
SharedKey = sharedKey,
|
||||
ExchangeHash = exchangeHash,
|
||||
Char = p,
|
||||
SessionId = sessionId
|
||||
};
|
||||
{
|
||||
SharedKey = sharedKey,
|
||||
ExchangeHash = exchangeHash,
|
||||
Char = p,
|
||||
SessionId = sessionId
|
||||
};
|
||||
return sessionKeyGeneration.GetBytes();
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ namespace Renci.SshNet.Security
|
||||
{
|
||||
WriteBinaryString(SharedKey);
|
||||
Write(ExchangeHash);
|
||||
Write((byte) Char);
|
||||
Write((byte)Char);
|
||||
Write(SessionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ namespace Renci.SshNet.Security
|
||||
protected override byte[] CalculateHash()
|
||||
{
|
||||
var groupExchangeHashData = new GroupExchangeHashData
|
||||
{
|
||||
ClientVersion = Session.ClientVersion,
|
||||
ServerVersion = Session.ServerVersion,
|
||||
ClientPayload = _clientPayload,
|
||||
ServerPayload = _serverPayload,
|
||||
HostKey = _hostKey,
|
||||
MinimumGroupSize = MinimumGroupSize,
|
||||
PreferredGroupSize = PreferredGroupSize,
|
||||
MaximumGroupSize = MaximumProupSize,
|
||||
Prime = _prime,
|
||||
SubGroup = _group,
|
||||
ClientExchangeValue = _clientExchangeValue,
|
||||
ServerExchangeValue = _serverExchangeValue,
|
||||
SharedKey = SharedKey,
|
||||
};
|
||||
{
|
||||
ClientVersion = Session.ClientVersion,
|
||||
ServerVersion = Session.ServerVersion,
|
||||
ClientPayload = _clientPayload,
|
||||
ServerPayload = _serverPayload,
|
||||
HostKey = _hostKey,
|
||||
MinimumGroupSize = MinimumGroupSize,
|
||||
PreferredGroupSize = PreferredGroupSize,
|
||||
MaximumGroupSize = MaximumProupSize,
|
||||
Prime = _prime,
|
||||
SubGroup = _group,
|
||||
ClientExchangeValue = _clientExchangeValue,
|
||||
ServerExchangeValue = _serverExchangeValue,
|
||||
SharedKey = SharedKey,
|
||||
};
|
||||
|
||||
return Hash(groupExchangeHashData.GetBytes());
|
||||
}
|
||||
|
||||
@@ -53,16 +53,16 @@ namespace Renci.SshNet.Security
|
||||
protected override byte[] CalculateHash()
|
||||
{
|
||||
var hashData = new KeyExchangeHashData
|
||||
{
|
||||
ClientVersion = Session.ClientVersion,
|
||||
ServerVersion = Session.ServerVersion,
|
||||
ClientPayload = _clientPayload,
|
||||
ServerPayload = _serverPayload,
|
||||
HostKey = _hostKey,
|
||||
ClientExchangeValue = _clientExchangeValue,
|
||||
ServerExchangeValue = _serverExchangeValue,
|
||||
SharedKey = SharedKey,
|
||||
};
|
||||
{
|
||||
ClientVersion = Session.ClientVersion,
|
||||
ServerVersion = Session.ServerVersion,
|
||||
ClientPayload = _clientPayload,
|
||||
ServerPayload = _serverPayload,
|
||||
HostKey = _hostKey,
|
||||
ClientExchangeValue = _clientExchangeValue,
|
||||
ServerExchangeValue = _serverExchangeValue,
|
||||
SharedKey = SharedKey,
|
||||
};
|
||||
|
||||
return Hash(hashData.GetBytes());
|
||||
}
|
||||
@@ -86,5 +86,5 @@ namespace Renci.SshNet.Security
|
||||
_serverPayload = message.GetBytes();
|
||||
_clientPayload = Session.ClientInitMessage.GetBytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ namespace Renci.SshNet
|
||||
|
||||
// find an algorithm that is supported by both client and server
|
||||
var keyExchangeAlgorithmFactory = (from c in clientAlgorithms
|
||||
from s in serverAlgorithms
|
||||
where s == c.Key
|
||||
select c.Value).FirstOrDefault();
|
||||
from s in serverAlgorithms
|
||||
where s == c.Key
|
||||
select c.Value).FirstOrDefault();
|
||||
|
||||
if (keyExchangeAlgorithmFactory is null)
|
||||
{
|
||||
|
||||
@@ -1036,7 +1036,7 @@ namespace Renci.SshNet
|
||||
|
||||
DiagnosticAbstraction.Log(string.Format("[{0}] Sending message '{1}' to server: '{2}'.", ToHex(SessionId), message.GetType().Name, message));
|
||||
|
||||
var paddingMultiplier = _clientCipher is null ? (byte) 8 : Math.Max((byte) 8, _clientCipher.MinimumSize);
|
||||
var paddingMultiplier = _clientCipher is null ? (byte)8 : Math.Max((byte)8, _clientCipher.MinimumSize);
|
||||
var packetData = message.GetPacket(paddingMultiplier, _clientCompression, _clientEtm || _clientAead);
|
||||
|
||||
// take a write lock to ensure the outbound packet sequence number is incremented
|
||||
@@ -1207,15 +1207,15 @@ namespace Renci.SshNet
|
||||
// Determine the size of the first block which is 8 or cipher block size (whichever is larger) bytes, or 4 if "packet length" field is handled separately.
|
||||
if (_serverEtm || _serverAead)
|
||||
{
|
||||
blockSize = (byte) 4;
|
||||
blockSize = (byte)4;
|
||||
}
|
||||
else if (_serverCipher != null)
|
||||
{
|
||||
blockSize = Math.Max((byte) 8, _serverCipher.MinimumSize);
|
||||
blockSize = Math.Max((byte)8, _serverCipher.MinimumSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockSize = (byte) 8;
|
||||
blockSize = (byte)8;
|
||||
}
|
||||
|
||||
var serverMacLength = 0;
|
||||
@@ -1253,7 +1253,7 @@ namespace Renci.SshNet
|
||||
packetLength = Pack.BigEndianToUInt32(firstBlock);
|
||||
|
||||
// Test packet minimum and maximum boundaries
|
||||
if (packetLength < Math.Max((byte) 16, blockSize) - 4 || packetLength > MaximumSshPacketSize - 4)
|
||||
if (packetLength < Math.Max((byte)16, blockSize) - 4 || packetLength > MaximumSshPacketSize - 4)
|
||||
{
|
||||
throw new SshConnectionException(string.Format(CultureInfo.CurrentCulture, "Bad packet length: {0}.", packetLength),
|
||||
DisconnectReason.ProtocolError);
|
||||
@@ -1261,7 +1261,7 @@ namespace Renci.SshNet
|
||||
|
||||
// Determine the number of bytes left to read; We've already read "blockSize" bytes, but the
|
||||
// "packet length" field itself - which is 4 bytes - is not included in the length of the packet
|
||||
var bytesToRead = (int) (packetLength - (blockSize - packetLengthFieldLength)) + serverMacLength;
|
||||
var bytesToRead = (int)(packetLength - (blockSize - packetLengthFieldLength)) + serverMacLength;
|
||||
|
||||
// Construct buffer for holding the payload and the inbound packet sequence as we need both in order
|
||||
// to generate the hash.
|
||||
@@ -1312,7 +1312,7 @@ namespace Renci.SshNet
|
||||
}
|
||||
|
||||
var paddingLength = data[inboundPacketSequenceLength + packetLengthFieldLength];
|
||||
var messagePayloadLength = (int) packetLength - paddingLength - paddingLengthFieldLength;
|
||||
var messagePayloadLength = (int)packetLength - paddingLength - paddingLengthFieldLength;
|
||||
var messagePayloadOffset = inboundPacketSequenceLength + packetLengthFieldLength + paddingLengthFieldLength;
|
||||
|
||||
// validate decrypted message against MAC
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
@@ -77,7 +78,7 @@ namespace Renci.SshNet.Sftp.Requests
|
||||
base.SaveData();
|
||||
|
||||
WriteBinaryString(_fileName);
|
||||
Write((uint) Flags);
|
||||
Write((uint)Flags);
|
||||
Write(_attributes);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Sftp.Responses;
|
||||
|
||||
namespace Renci.SshNet.Sftp.Requests
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Renci.SshNet.Sftp.Responses
|
||||
{
|
||||
base.SaveData();
|
||||
|
||||
Write((uint) Files.Length); // count
|
||||
Write((uint)Files.Length); // count
|
||||
|
||||
for (var i = 0; i < Files.Length; i++)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{
|
||||
base.LoadData();
|
||||
|
||||
StatusCode = (StatusCodes) ReadUInt32();
|
||||
StatusCode = (StatusCodes)ReadUInt32();
|
||||
|
||||
if (ProtocolVersion < 3)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Sftp
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Sftp
|
||||
|
||||
@@ -535,13 +535,13 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
if (IsSizeChanged && IsRegularFile)
|
||||
{
|
||||
stream.Write((ulong) Size);
|
||||
stream.Write((ulong)Size);
|
||||
}
|
||||
|
||||
if (IsUserIdChanged || IsGroupIdChanged)
|
||||
{
|
||||
stream.Write((uint) UserId);
|
||||
stream.Write((uint) GroupId);
|
||||
stream.Write((uint)UserId);
|
||||
stream.Write((uint)GroupId);
|
||||
}
|
||||
|
||||
if (IsPermissionsChanged)
|
||||
@@ -551,9 +551,9 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
if (IsLastAccessTimeChanged || IsLastWriteTimeChanged)
|
||||
{
|
||||
var time = (uint) ((LastAccessTimeUtc.ToFileTimeUtc() / 10000000) - 11644473600);
|
||||
var time = (uint)((LastAccessTimeUtc.ToFileTimeUtc() / 10000000) - 11644473600);
|
||||
stream.Write(time);
|
||||
time = (uint) ((LastWriteTimeUtc.ToFileTimeUtc() / 10000000) - 11644473600);
|
||||
time = (uint)((LastWriteTimeUtc.ToFileTimeUtc() / 10000000) - 11644473600);
|
||||
stream.Write(time);
|
||||
}
|
||||
|
||||
@@ -596,14 +596,14 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
if ((flag & SSH_FILEXFER_ATTR_SIZE) == SSH_FILEXFER_ATTR_SIZE)
|
||||
{
|
||||
size = (long) stream.ReadUInt64();
|
||||
size = (long)stream.ReadUInt64();
|
||||
}
|
||||
|
||||
if ((flag & SSH_FILEXFER_ATTR_UIDGID) == SSH_FILEXFER_ATTR_UIDGID)
|
||||
{
|
||||
userId = (int) stream.ReadUInt32();
|
||||
userId = (int)stream.ReadUInt32();
|
||||
|
||||
groupId = (int) stream.ReadUInt32();
|
||||
groupId = (int)stream.ReadUInt32();
|
||||
}
|
||||
|
||||
if ((flag & SSH_FILEXFER_ATTR_PERMISSIONS) == SSH_FILEXFER_ATTR_PERMISSIONS)
|
||||
@@ -628,7 +628,7 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
if ((flag & SSH_FILEXFER_ATTR_EXTENDED) == SSH_FILEXFER_ATTR_EXTENDED)
|
||||
{
|
||||
var extendedCount = (int) stream.ReadUInt32();
|
||||
var extendedCount = (int)stream.ReadUInt32();
|
||||
extensions = new Dictionary<string, string>(extendedCount);
|
||||
for (var i = 0; i < extendedCount; i++)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Renci.SshNet.Sftp
|
||||
// instance is already disposed
|
||||
while (!_queue.TryGetValue(_nextChunkIndex, out nextChunk) && _exception is null)
|
||||
{
|
||||
_ =Monitor.Wait(_readLock);
|
||||
_ = Monitor.Wait(_readLock);
|
||||
}
|
||||
|
||||
// throw when exception occured in read-ahead, or the current instance is already disposed
|
||||
@@ -126,7 +126,7 @@ namespace Renci.SshNet.Sftp
|
||||
_ = _queue.Remove(_nextChunkIndex);
|
||||
|
||||
// update offset
|
||||
_offset += (ulong) data.Length;
|
||||
_offset += (ulong)data.Length;
|
||||
|
||||
// move to next chunk
|
||||
_nextChunkIndex++;
|
||||
@@ -141,7 +141,7 @@ namespace Renci.SshNet.Sftp
|
||||
// When we received an EOF for the next chunk and the size of the file is known, then
|
||||
// we only complete the current chunk if we haven't already read up to the file size.
|
||||
// This way we save an extra round-trip to the server.
|
||||
if (data.Length == 0 && _fileSize.HasValue && _offset == (ulong) _fileSize.Value)
|
||||
if (data.Length == 0 && _fileSize.HasValue && _offset == (ulong)_fileSize.Value)
|
||||
{
|
||||
// avoid future reads
|
||||
_isEndOfFileRead = true;
|
||||
@@ -176,7 +176,7 @@ namespace Renci.SshNet.Sftp
|
||||
* TODO: break loop and interrupt blocking wait in case of exception
|
||||
*/
|
||||
|
||||
var read = _sftpSession.RequestRead(_handle, _offset, (uint) bytesToCatchUp);
|
||||
var read = _sftpSession.RequestRead(_handle, _offset, (uint)bytesToCatchUp);
|
||||
if (read.Length == 0)
|
||||
{
|
||||
// process data in read lock to avoid ObjectDisposedException while releasing semaphore
|
||||
@@ -214,7 +214,7 @@ namespace Renci.SshNet.Sftp
|
||||
}
|
||||
}
|
||||
|
||||
_offset += (uint) read.Length;
|
||||
_offset += (uint)read.Length;
|
||||
|
||||
return read;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ namespace Renci.SshNet.Sftp
|
||||
// if the offset of the read-ahead chunk is greater than that file size, then
|
||||
// we can expect to be reading the last (zero-byte) chunk and switch to synchronous
|
||||
// mode to avoid having multiple read-aheads that read beyond EOF
|
||||
if (_fileSize != null && (long) _readAheadOffset > _fileSize.Value)
|
||||
if (_fileSize != null && (long)_readAheadOffset > _fileSize.Value)
|
||||
{
|
||||
var asyncResult = _sftpSession.BeginRead(_handle, _readAheadOffset, _chunkSize, callback: null, bufferedRead);
|
||||
var data = _sftpSession.EndRead(asyncResult);
|
||||
@@ -399,7 +399,7 @@ namespace Renci.SshNet.Sftp
|
||||
return;
|
||||
}
|
||||
|
||||
var readAsyncResult = (SftpReadAsyncResult) result;
|
||||
var readAsyncResult = (SftpReadAsyncResult)result;
|
||||
|
||||
byte[] data;
|
||||
|
||||
@@ -415,7 +415,7 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
// a read that completes with a zero-byte result signals EOF
|
||||
// but there may be pending reads before that read
|
||||
var bufferedRead = (BufferedRead) readAsyncResult.AsyncState;
|
||||
var bufferedRead = (BufferedRead)readAsyncResult.AsyncState;
|
||||
ReadCompletedCore(bufferedRead, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,8 +209,8 @@ namespace Renci.SshNet.Sftp
|
||||
* or SSH_FXP_WRITE message.
|
||||
*/
|
||||
|
||||
_readBufferSize = (int) session.CalculateOptimalReadLength((uint) bufferSize);
|
||||
_writeBufferSize = (int) session.CalculateOptimalWriteLength((uint) bufferSize, _handle);
|
||||
_readBufferSize = (int)session.CalculateOptimalReadLength((uint)bufferSize);
|
||||
_writeBufferSize = (int)session.CalculateOptimalWriteLength((uint)bufferSize, _handle);
|
||||
|
||||
_position = position;
|
||||
}
|
||||
@@ -321,8 +321,8 @@ namespace Renci.SshNet.Sftp
|
||||
* or SSH_FXP_WRITE message.
|
||||
*/
|
||||
|
||||
_readBufferSize = (int) session.CalculateOptimalReadLength((uint) bufferSize);
|
||||
_writeBufferSize = (int) session.CalculateOptimalWriteLength((uint) bufferSize, _handle);
|
||||
_readBufferSize = (int)session.CalculateOptimalReadLength((uint)bufferSize);
|
||||
_writeBufferSize = (int)session.CalculateOptimalWriteLength((uint)bufferSize, _handle);
|
||||
|
||||
if (mode == FileMode.Append)
|
||||
{
|
||||
@@ -566,7 +566,7 @@ namespace Renci.SshNet.Sftp
|
||||
var bytesAvailableInBuffer = _bufferLen - _bufferPosition;
|
||||
if (bytesAvailableInBuffer <= 0)
|
||||
{
|
||||
var data = _session.RequestRead(_handle, (ulong) _position, (uint) _readBufferSize);
|
||||
var data = _session.RequestRead(_handle, (ulong)_position, (uint)_readBufferSize);
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
@@ -824,7 +824,7 @@ namespace Renci.SshNet.Sftp
|
||||
// Read more data into the internal buffer if necessary.
|
||||
if (_bufferPosition >= _bufferLen)
|
||||
{
|
||||
var data = _session.RequestRead(_handle, (ulong) _position, (uint) _readBufferSize);
|
||||
var data = _session.RequestRead(_handle, (ulong)_position, (uint)_readBufferSize);
|
||||
if (data.Length == 0)
|
||||
{
|
||||
// We've reached EOF.
|
||||
@@ -911,7 +911,7 @@ namespace Renci.SshNet.Sftp
|
||||
if (newPosn >= (_position - _bufferPosition) &&
|
||||
newPosn < (_position - _bufferPosition + _bufferLen))
|
||||
{
|
||||
_bufferPosition = (int) (newPosn - (_position - _bufferPosition));
|
||||
_bufferPosition = (int)(newPosn - (_position - _bufferPosition));
|
||||
_position = newPosn;
|
||||
return _position;
|
||||
}
|
||||
@@ -1082,7 +1082,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
using (var wait = new AutoResetEvent(initialState: false))
|
||||
{
|
||||
_session.RequestWrite(_handle, (ulong) _position, buffer, offset, tempLen, wait);
|
||||
_session.RequestWrite(_handle, (ulong)_position, buffer, offset, tempLen, wait);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1104,7 +1104,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
using (var wait = new AutoResetEvent(initialState: false))
|
||||
{
|
||||
_session.RequestWrite(_handle, (ulong) (_position - _bufferPosition), GetOrCreateWriteBuffer(), 0, _bufferPosition, wait);
|
||||
_session.RequestWrite(_handle, (ulong)(_position - _bufferPosition), GetOrCreateWriteBuffer(), 0, _bufferPosition, wait);
|
||||
}
|
||||
|
||||
_bufferPosition = 0;
|
||||
@@ -1228,7 +1228,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
using (var wait = new AutoResetEvent(initialState: false))
|
||||
{
|
||||
_session.RequestWrite(_handle, (ulong) (_position - _bufferPosition), writeBuffer, 0, _bufferPosition, wait);
|
||||
_session.RequestWrite(_handle, (ulong)(_position - _bufferPosition), writeBuffer, 0, _bufferPosition, wait);
|
||||
}
|
||||
|
||||
_bufferPosition = 0;
|
||||
@@ -1312,7 +1312,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
using (var wait = new AutoResetEvent(initialState: false))
|
||||
{
|
||||
_session.RequestWrite(_handle, (ulong) (_position - _bufferPosition), _writeBuffer, 0, _bufferPosition, wait);
|
||||
_session.RequestWrite(_handle, (ulong)(_position - _bufferPosition), _writeBuffer, 0, _bufferPosition, wait);
|
||||
}
|
||||
|
||||
_bufferPosition = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Renci.SshNet.Sftp
|
||||
|
||||
protected override void SaveData()
|
||||
{
|
||||
Write((byte) SftpMessageType);
|
||||
Write((byte)SftpMessageType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +59,7 @@ namespace Renci.SshNet.Sftp
|
||||
// write the length of the SFTP message where we were positioned before we started
|
||||
// writing the SFTP message data
|
||||
stream.Position = startPosition;
|
||||
stream.Write((uint) dataLength);
|
||||
stream.Write((uint)dataLength);
|
||||
|
||||
// move back to we were positioned when we finished writing the SFTP message data
|
||||
stream.Position = endPosition;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
public SftpMessage Create(uint protocolVersion, byte messageType, Encoding encoding)
|
||||
{
|
||||
var sftpMessageType = (SftpMessageTypes) messageType;
|
||||
var sftpMessageType = (SftpMessageTypes)messageType;
|
||||
|
||||
SftpMessage message;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Renci.SshNet.Sftp
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint) Interlocked.Increment(ref _requestId);
|
||||
return (uint)Interlocked.Increment(ref _requestId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,9 +512,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpOpenRequest(ProtocolVersion,
|
||||
@@ -659,9 +659,9 @@ namespace Renci.SshNet.Sftp
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
_ = await tcs.Task.ConfigureAwait(false);
|
||||
@@ -873,9 +873,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpReadRequest(ProtocolVersion,
|
||||
@@ -970,9 +970,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpWriteRequest(ProtocolVersion,
|
||||
@@ -1160,9 +1160,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<SftpFileAttributes>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileAttributes>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileAttributes>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileAttributes>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileAttributes>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpFStatRequest(ProtocolVersion,
|
||||
@@ -1298,9 +1298,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<byte[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpOpenDirRequest(ProtocolVersion,
|
||||
@@ -1379,9 +1379,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpReadDirRequest(ProtocolVersion,
|
||||
@@ -1450,9 +1450,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpRemoveRequest(ProtocolVersion,
|
||||
@@ -1588,9 +1588,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<KeyValuePair<string, SftpFileAttributes>[]>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpRealPathRequest(ProtocolVersion,
|
||||
@@ -1824,9 +1824,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new SftpRenameRequest(ProtocolVersion,
|
||||
@@ -2057,9 +2057,9 @@ namespace Renci.SshNet.Sftp
|
||||
var tcs = new TaskCompletionSource<SftpFileSytemInformation>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#if NET || NETSTANDARD2_1_OR_GREATER
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileSytemInformation>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
await using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileSytemInformation>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
|
||||
#else
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileSytemInformation>) s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
using (cancellationToken.Register(s => ((TaskCompletionSource<SftpFileSytemInformation>)s).TrySetCanceled(cancellationToken), tcs, useSynchronizationContext: false))
|
||||
#endif // NET || NETSTANDARD2_1_OR_GREATER
|
||||
{
|
||||
SendRequest(new StatVfsRequest(ProtocolVersion,
|
||||
@@ -2223,7 +2223,7 @@ namespace Renci.SshNet.Sftp
|
||||
* WinSCP uses data length of 32739 bytes (total 32768 bytes; 32739 + 25 + 4 bytes for handle)
|
||||
*/
|
||||
|
||||
var lengthOfNonDataProtocolFields = 25u + (uint) handle.Length;
|
||||
var lengthOfNonDataProtocolFields = 25u + (uint)handle.Length;
|
||||
var maximumPacketSize = Channel.RemotePacketSize;
|
||||
return Math.Min(bufferSize, maximumPacketSize) - lengthOfNonDataProtocolFields;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Renci.SshNet
|
||||
throw new SshConnectionException("Client not connected.");
|
||||
}
|
||||
|
||||
return (int) _sftpSession.ProtocolVersion;
|
||||
return (int)_sftpSession.ProtocolVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,7 +1364,7 @@ namespace Renci.SshNet
|
||||
throw new ArgumentNullException(nameof(encoding));
|
||||
}
|
||||
|
||||
return new StreamWriter(new SftpFileStream(_sftpSession, path, FileMode.Append, FileAccess.Write, (int) _bufferSize), encoding);
|
||||
return new StreamWriter(new SftpFileStream(_sftpSession, path, FileMode.Append, FileAccess.Write, (int)_bufferSize), encoding);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1385,7 +1385,7 @@ namespace Renci.SshNet
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
return new SftpFileStream(_sftpSession, path, FileMode.Create, FileAccess.ReadWrite, (int) _bufferSize);
|
||||
return new SftpFileStream(_sftpSession, path, FileMode.Create, FileAccess.ReadWrite, (int)_bufferSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1576,7 +1576,7 @@ namespace Renci.SshNet
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
return new SftpFileStream(_sftpSession, path, mode, access, (int) _bufferSize);
|
||||
return new SftpFileStream(_sftpSession, path, mode, access, (int)_bufferSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1609,7 +1609,7 @@ namespace Renci.SshNet
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
return SftpFileStream.OpenAsync(_sftpSession, path, mode, access, (int) _bufferSize, cancellationToken);
|
||||
return SftpFileStream.OpenAsync(_sftpSession, path, mode, access, (int)_bufferSize, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1659,7 +1659,7 @@ namespace Renci.SshNet
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
return new SftpFileStream(_sftpSession, path, FileMode.OpenOrCreate, FileAccess.Write, (int) _bufferSize);
|
||||
return new SftpFileStream(_sftpSession, path, FileMode.OpenOrCreate, FileAccess.Write, (int)_bufferSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2384,7 +2384,7 @@ namespace Renci.SshNet
|
||||
|
||||
output.Write(data, 0, data.Length);
|
||||
|
||||
totalBytesRead += (ulong) data.Length;
|
||||
totalBytesRead += (ulong)data.Length;
|
||||
|
||||
asyncResult?.Update(totalBytesRead);
|
||||
|
||||
@@ -2451,7 +2451,7 @@ namespace Renci.SshNet
|
||||
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
var writtenBytes = offset + (ulong) bytesRead;
|
||||
var writtenBytes = offset + (ulong)bytesRead;
|
||||
|
||||
_sftpSession.RequestWrite(handle, offset, buffer, offset: 0, bytesRead, wait: null, s =>
|
||||
{
|
||||
@@ -2473,7 +2473,7 @@ namespace Renci.SshNet
|
||||
|
||||
_ = Interlocked.Increment(ref expectedResponses);
|
||||
|
||||
offset += (ulong) bytesRead;
|
||||
offset += (ulong)bytesRead;
|
||||
|
||||
bytesRead = input.Read(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Renci.SshNet
|
||||
while (_channel.IsOpen)
|
||||
{
|
||||
var readTask = _input.ReadAsync(buffer, 0, buffer.Length);
|
||||
var readWaitHandle = ((IAsyncResult) readTask).AsyncWaitHandle;
|
||||
var readWaitHandle = ((IAsyncResult)readTask).AsyncWaitHandle;
|
||||
|
||||
if (WaitHandle.WaitAny(new[] { readWaitHandle, _channelClosedWaitHandle }) == 0)
|
||||
{
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace Renci.SshNet
|
||||
ThreadAbstraction.ExecuteThread(() => _callback(_asyncResult));
|
||||
}
|
||||
|
||||
_ = ((EventWaitHandle) _asyncResult.AsyncWaitHandle).Set();
|
||||
_ = ((EventWaitHandle)_asyncResult.AsyncWaitHandle).Set();
|
||||
}
|
||||
|
||||
private void Channel_Closed(object sender, ChannelEventArgs e)
|
||||
@@ -460,7 +460,7 @@ namespace Renci.SshNet
|
||||
{
|
||||
if (e.Info is ExitStatusRequestInfo exitStatusInfo)
|
||||
{
|
||||
ExitStatus = (int) exitStatusInfo.ExitStatus;
|
||||
ExitStatus = (int)exitStatusInfo.ExitStatus;
|
||||
|
||||
if (exitStatusInfo.WantReply)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user