mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Re-introduce ChangeWindow method on ShellStream (#1646)
* Re-introduce ChangeWindow method on ShellStream * Fix pipeline build * Fix pipeline build * tweaks Co-authored-by: Glen Kleidon <glenk@galkam.com.au> Co-authored-by: oheiheiheiheihei <294797392@qq.com> --------- Co-authored-by: Ivan Zaitsev <crackbargains@gmail.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com> Co-authored-by: Glen Kleidon <glenk@galkam.com.au> Co-authored-by: oheiheiheiheihei <294797392@qq.com>
This commit is contained in:
@@ -239,26 +239,18 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="rows">The rows.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <param name="height">The height.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true"/> if request was successful; otherwise <see langword="false"/>.
|
||||
/// </returns>
|
||||
public bool SendWindowChangeRequest(uint columns, uint rows, uint width, uint height)
|
||||
public void SendWindowChangeRequest(uint columns, uint rows, uint width, uint height)
|
||||
{
|
||||
SendMessage(new ChannelRequestMessage(RemoteChannelNumber, new WindowChangeRequestInfo(columns, rows, width, height)));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the local flow request.
|
||||
/// </summary>
|
||||
/// <param name="clientCanDo">if set to <see langword="true"/> [client can do].</param>
|
||||
/// <returns>
|
||||
/// <see langword="true"/> if request was successful; otherwise <see langword="false"/>.
|
||||
/// </returns>
|
||||
public bool SendLocalFlowRequest(bool clientCanDo)
|
||||
public void SendLocalFlowRequest(bool clientCanDo)
|
||||
{
|
||||
SendMessage(new ChannelRequestMessage(RemoteChannelNumber, new XonXoffRequestInfo(clientCanDo)));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -97,19 +97,13 @@ namespace Renci.SshNet.Channels
|
||||
/// <param name="rows">The rows.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <param name="height">The height.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true"/> if request was successful; otherwise <see langword="false"/>.
|
||||
/// </returns>
|
||||
bool SendWindowChangeRequest(uint columns, uint rows, uint width, uint height);
|
||||
void SendWindowChangeRequest(uint columns, uint rows, uint width, uint height);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the local flow request.
|
||||
/// </summary>
|
||||
/// <param name="clientCanDo">if set to <see langword="true"/> [client can do].</param>
|
||||
/// <returns>
|
||||
/// <see langword="true"/> if request was successful; otherwise <see langword="false"/>.
|
||||
/// </returns>
|
||||
bool SendLocalFlowRequest(bool clientCanDo);
|
||||
void SendLocalFlowRequest(bool clientCanDo);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the signal request.
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Renci.SshNet
|
||||
/// <param name="session">The SSH session.</param>
|
||||
/// <param name="terminalName">The <c>TERM</c> environment variable.</param>
|
||||
/// <param name="columns">The terminal width in columns.</param>
|
||||
/// <param name="rows">The terminal width in rows.</param>
|
||||
/// <param name="rows">The terminal height in rows.</param>
|
||||
/// <param name="width">The terminal width in pixels.</param>
|
||||
/// <param name="height">The terminal height in pixels.</param>
|
||||
/// <param name="terminalModeValues">The terminal mode values.</param>
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
/// <param name="terminalName">The <c>TERM</c> environment variable.</param>
|
||||
/// <param name="columns">The terminal width in columns.</param>
|
||||
/// <param name="rows">The terminal width in rows.</param>
|
||||
/// <param name="rows">The terminal height in rows.</param>
|
||||
/// <param name="width">The terminal width in pixels.</param>
|
||||
/// <param name="height">The terminal height in pixels.</param>
|
||||
/// <param name="bufferSize">The size of the buffer.</param>
|
||||
@@ -200,7 +200,7 @@ namespace Renci.SshNet
|
||||
/// You can get a detailed list of these capabilities by using the ‘infocmp’ command.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The column/row dimensions override the pixel dimensions(when nonzero). Pixel dimensions refer
|
||||
/// The column/row dimensions override the pixel dimensions (when nonzero). Pixel dimensions refer
|
||||
/// to the drawable area of the window.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
@@ -211,7 +211,7 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
/// <param name="terminalName">The <c>TERM</c> environment variable.</param>
|
||||
/// <param name="columns">The terminal width in columns.</param>
|
||||
/// <param name="rows">The terminal width in rows.</param>
|
||||
/// <param name="rows">The terminal height in rows.</param>
|
||||
/// <param name="width">The terminal width in pixels.</param>
|
||||
/// <param name="height">The terminal height in pixels.</param>
|
||||
/// <param name="bufferSize">The size of the buffer.</param>
|
||||
@@ -226,7 +226,7 @@ namespace Renci.SshNet
|
||||
/// You can get a detailed list of these capabilities by using the ‘infocmp’ command.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer
|
||||
/// The column/row dimensions override the pixel dimensions (when non-zero). Pixel dimensions refer
|
||||
/// to the drawable area of the window.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
|
||||
@@ -177,31 +177,7 @@ namespace Renci.SshNet
|
||||
return new SftpResponseFactory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a shell stream.
|
||||
/// </summary>
|
||||
/// <param name="session">The SSH session.</param>
|
||||
/// <param name="terminalName">The <c>TERM</c> environment variable.</param>
|
||||
/// <param name="columns">The terminal width in columns.</param>
|
||||
/// <param name="rows">The terminal width in rows.</param>
|
||||
/// <param name="width">The terminal width in pixels.</param>
|
||||
/// <param name="height">The terminal height in pixels.</param>
|
||||
/// <param name="terminalModeValues">The terminal mode values.</param>
|
||||
/// <param name="bufferSize">The size of the buffer.</param>
|
||||
/// <returns>
|
||||
/// The created <see cref="ShellStream"/> instance.
|
||||
/// </returns>
|
||||
/// <exception cref="SshConnectionException">Client is not connected.</exception>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities.
|
||||
/// You can get a detailed list of these capabilities by using the ‘infocmp’ command.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer
|
||||
/// to the drawable area of the window.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <inheritdoc/>
|
||||
public ShellStream CreateShellStream(ISession session, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint> terminalModeValues, int bufferSize)
|
||||
{
|
||||
return new ShellStream(session, terminalName, columns, rows, width, height, terminalModeValues, bufferSize);
|
||||
|
||||
@@ -281,6 +281,25 @@ namespace Renci.SshNet
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends new dimensions of the window (terminal) to the server.
|
||||
/// </summary>
|
||||
/// <param name="columns">The terminal width in columns.</param>
|
||||
/// <param name="rows">The terminal height in rows.</param>
|
||||
/// <param name="width">The terminal width in pixels.</param>
|
||||
/// <param name="height">The terminal height in pixels.</param>
|
||||
/// <remarks>
|
||||
/// The column/row dimensions override the pixel dimensions (when nonzero). Pixel dimensions refer
|
||||
/// to the drawable area of the window.
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">The stream is closed.</exception>
|
||||
public void ChangeWindowSize(uint columns, uint rows, uint width, uint height)
|
||||
{
|
||||
ThrowHelper.ThrowObjectDisposedIf(_disposed, this);
|
||||
|
||||
_channel.SendWindowChangeRequest(columns, rows, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expects the specified expression and performs action when one is found.
|
||||
/// </summary>
|
||||
|
||||
@@ -123,6 +123,30 @@ namespace Renci.SshNet.Tests.Classes
|
||||
Assert.ThrowsException<ObjectDisposedException>(() => shellStream.Write(bytes, 0, bytes.Length));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChangeWindowSize_AfterDispose_ThrowsObjectDisposedException()
|
||||
{
|
||||
var shellStream = CreateShellStream();
|
||||
|
||||
_channelSessionMock.Setup(p => p.Dispose());
|
||||
|
||||
shellStream.Dispose();
|
||||
|
||||
Assert.ThrowsException<ObjectDisposedException>(() => shellStream.ChangeWindowSize(80, 25, 0, 0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChangeWindowSize_SendsWindowChangeRequest()
|
||||
{
|
||||
var shellStream = CreateShellStream();
|
||||
|
||||
_channelSessionMock.Setup(s => s.SendWindowChangeRequest(80, 25, 0, 1));
|
||||
|
||||
shellStream.ChangeWindowSize(80, 25, 0, 1);
|
||||
|
||||
_channelSessionMock.Verify(v => v.SendWindowChangeRequest(80, 25, 0, 1), Times.Once());
|
||||
}
|
||||
|
||||
private ShellStream CreateShellStream()
|
||||
{
|
||||
_sessionMock.Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
|
||||
@@ -426,13 +426,13 @@ namespace Renci.SshNet.Tests.Classes
|
||||
|
||||
public bool SendKeepAliveRequest() => throw new NotImplementedException();
|
||||
|
||||
public bool SendLocalFlowRequest(bool clientCanDo) => throw new NotImplementedException();
|
||||
public void SendLocalFlowRequest(bool clientCanDo) => throw new NotImplementedException();
|
||||
|
||||
public bool SendSignalRequest(string signalName) => throw new NotImplementedException();
|
||||
|
||||
public bool SendSubsystemRequest(string subsystem) => throw new NotImplementedException();
|
||||
|
||||
public bool SendWindowChangeRequest(uint columns, uint rows, uint width, uint height) => throw new NotImplementedException();
|
||||
public void SendWindowChangeRequest(uint columns, uint rows, uint width, uint height) => throw new NotImplementedException();
|
||||
|
||||
public bool SendX11ForwardingRequest(bool isSingleConnection, string protocol, byte[] cookie, uint screenNumber) => throw new NotImplementedException();
|
||||
#pragma warning restore IDE0022 // Use block body for method
|
||||
|
||||
Reference in New Issue
Block a user