|  | 
|  | 1 | +#nullable enable | 
|  | 2 | +using System; | 
|  | 3 | +using System.Collections.Generic; | 
|  | 4 | +using System.IO; | 
|  | 5 | +using System.Text; | 
|  | 6 | + | 
|  | 7 | +using Renci.SshNet.Common; | 
|  | 8 | + | 
|  | 9 | +namespace Renci.SshNet | 
|  | 10 | +{ | 
|  | 11 | +    /// <summary> | 
|  | 12 | +    /// Provides client connection to SSH server. | 
|  | 13 | +    /// </summary> | 
|  | 14 | +    public interface ISshClient : IBaseClient | 
|  | 15 | +    { | 
|  | 16 | +        /// <summary> | 
|  | 17 | +        /// Gets the list of forwarded ports. | 
|  | 18 | +        /// </summary> | 
|  | 19 | +        IEnumerable<ForwardedPort> ForwardedPorts { get; } | 
|  | 20 | + | 
|  | 21 | +        /// <summary> | 
|  | 22 | +        /// Adds the forwarded port. | 
|  | 23 | +        /// </summary> | 
|  | 24 | +        /// <param name="port">The port.</param> | 
|  | 25 | +        /// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exception> | 
|  | 26 | +        /// <exception cref="ArgumentNullException"><paramref name="port"/> is <see langword="null"/>.</exception> | 
|  | 27 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 28 | +        public void AddForwardedPort(ForwardedPort port); | 
|  | 29 | + | 
|  | 30 | +        /// <summary> | 
|  | 31 | +        /// Stops and removes the forwarded port from the list. | 
|  | 32 | +        /// </summary> | 
|  | 33 | +        /// <param name="port">Forwarded port.</param> | 
|  | 34 | +        /// <exception cref="ArgumentNullException"><paramref name="port"/> is <see langword="null"/>.</exception> | 
|  | 35 | +        public void RemoveForwardedPort(ForwardedPort port); | 
|  | 36 | + | 
|  | 37 | +        /// <summary> | 
|  | 38 | +        /// Creates the command to be executed. | 
|  | 39 | +        /// </summary> | 
|  | 40 | +        /// <param name="commandText">The command text.</param> | 
|  | 41 | +        /// <returns><see cref="SshCommand"/> object.</returns> | 
|  | 42 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 43 | +        public SshCommand CreateCommand(string commandText); | 
|  | 44 | + | 
|  | 45 | +        /// <summary> | 
|  | 46 | +        /// Creates the command to be executed with specified encoding. | 
|  | 47 | +        /// </summary> | 
|  | 48 | +        /// <param name="commandText">The command text.</param> | 
|  | 49 | +        /// <param name="encoding">The encoding to use for results.</param> | 
|  | 50 | +        /// <returns><see cref="SshCommand"/> object which uses specified encoding.</returns> | 
|  | 51 | +        /// <remarks>This method will change current default encoding.</remarks> | 
|  | 52 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 53 | +        /// <exception cref="ArgumentNullException"><paramref name="commandText"/> or <paramref name="encoding"/> is <see langword="null"/>.</exception> | 
|  | 54 | +        public SshCommand CreateCommand(string commandText, Encoding encoding); | 
|  | 55 | + | 
|  | 56 | +        /// <summary> | 
|  | 57 | +        /// Creates and executes the command. | 
|  | 58 | +        /// </summary> | 
|  | 59 | +        /// <param name="commandText">The command text.</param> | 
|  | 60 | +        /// <returns>Returns an instance of <see cref="SshCommand"/> with execution results.</returns> | 
|  | 61 | +        /// <remarks>This method internally uses asynchronous calls.</remarks> | 
|  | 62 | +        /// <exception cref="ArgumentException">CommandText property is empty.</exception> | 
|  | 63 | +        /// <exception cref="SshException">Invalid Operation - An existing channel was used to execute this command.</exception> | 
|  | 64 | +        /// <exception cref="InvalidOperationException">Asynchronous operation is already in progress.</exception> | 
|  | 65 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 66 | +        /// <exception cref="ArgumentNullException"><paramref name="commandText"/> is <see langword="null"/>.</exception> | 
|  | 67 | +        public SshCommand RunCommand(string commandText); | 
|  | 68 | + | 
|  | 69 | +        /// <summary> | 
|  | 70 | +        /// Creates the shell. | 
|  | 71 | +        /// </summary> | 
|  | 72 | +        /// <param name="input">The input.</param> | 
|  | 73 | +        /// <param name="output">The output.</param> | 
|  | 74 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 75 | +        /// <param name="terminalName">Name of the terminal.</param> | 
|  | 76 | +        /// <param name="columns">The columns.</param> | 
|  | 77 | +        /// <param name="rows">The rows.</param> | 
|  | 78 | +        /// <param name="width">The width.</param> | 
|  | 79 | +        /// <param name="height">The height.</param> | 
|  | 80 | +        /// <param name="terminalModes">The terminal mode.</param> | 
|  | 81 | +        /// <param name="bufferSize">Size of the internal read buffer.</param> | 
|  | 82 | +        /// <returns> | 
|  | 83 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 84 | +        /// </returns> | 
|  | 85 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 86 | +        public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint>? terminalModes, int bufferSize); | 
|  | 87 | + | 
|  | 88 | +        /// <summary> | 
|  | 89 | +        /// Creates the shell. | 
|  | 90 | +        /// </summary> | 
|  | 91 | +        /// <param name="input">The input.</param> | 
|  | 92 | +        /// <param name="output">The output.</param> | 
|  | 93 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 94 | +        /// <param name="terminalName">Name of the terminal.</param> | 
|  | 95 | +        /// <param name="columns">The columns.</param> | 
|  | 96 | +        /// <param name="rows">The rows.</param> | 
|  | 97 | +        /// <param name="width">The width.</param> | 
|  | 98 | +        /// <param name="height">The height.</param> | 
|  | 99 | +        /// <param name="terminalModes">The terminal mode.</param> | 
|  | 100 | +        /// <returns> | 
|  | 101 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 102 | +        /// </returns> | 
|  | 103 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 104 | +        public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint> terminalModes); | 
|  | 105 | + | 
|  | 106 | +        /// <summary> | 
|  | 107 | +        /// Creates the shell. | 
|  | 108 | +        /// </summary> | 
|  | 109 | +        /// <param name="input">The input.</param> | 
|  | 110 | +        /// <param name="output">The output.</param> | 
|  | 111 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 112 | +        /// <returns> | 
|  | 113 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 114 | +        /// </returns> | 
|  | 115 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 116 | +        public Shell CreateShell(Stream input, Stream output, Stream extendedOutput); | 
|  | 117 | + | 
|  | 118 | +        /// <summary> | 
|  | 119 | +        /// Creates the shell. | 
|  | 120 | +        /// </summary> | 
|  | 121 | +        /// <param name="encoding">The encoding to use to send the input.</param> | 
|  | 122 | +        /// <param name="input">The input.</param> | 
|  | 123 | +        /// <param name="output">The output.</param> | 
|  | 124 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 125 | +        /// <param name="terminalName">Name of the terminal.</param> | 
|  | 126 | +        /// <param name="columns">The columns.</param> | 
|  | 127 | +        /// <param name="rows">The rows.</param> | 
|  | 128 | +        /// <param name="width">The width.</param> | 
|  | 129 | +        /// <param name="height">The height.</param> | 
|  | 130 | +        /// <param name="terminalModes">The terminal mode.</param> | 
|  | 131 | +        /// <param name="bufferSize">Size of the internal read buffer.</param> | 
|  | 132 | +        /// <returns> | 
|  | 133 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 134 | +        /// </returns> | 
|  | 135 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 136 | +        public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint>? terminalModes, int bufferSize); | 
|  | 137 | + | 
|  | 138 | +        /// <summary> | 
|  | 139 | +        /// Creates the shell. | 
|  | 140 | +        /// </summary> | 
|  | 141 | +        /// <param name="encoding">The encoding.</param> | 
|  | 142 | +        /// <param name="input">The input.</param> | 
|  | 143 | +        /// <param name="output">The output.</param> | 
|  | 144 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 145 | +        /// <param name="terminalName">Name of the terminal.</param> | 
|  | 146 | +        /// <param name="columns">The columns.</param> | 
|  | 147 | +        /// <param name="rows">The rows.</param> | 
|  | 148 | +        /// <param name="width">The width.</param> | 
|  | 149 | +        /// <param name="height">The height.</param> | 
|  | 150 | +        /// <param name="terminalModes">The terminal modes.</param> | 
|  | 151 | +        /// <returns> | 
|  | 152 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 153 | +        /// </returns> | 
|  | 154 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 155 | +        public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint> terminalModes); | 
|  | 156 | + | 
|  | 157 | +        /// <summary> | 
|  | 158 | +        /// Creates the shell. | 
|  | 159 | +        /// </summary> | 
|  | 160 | +        /// <param name="encoding">The encoding.</param> | 
|  | 161 | +        /// <param name="input">The input.</param> | 
|  | 162 | +        /// <param name="output">The output.</param> | 
|  | 163 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 164 | +        /// <returns> | 
|  | 165 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 166 | +        /// </returns> | 
|  | 167 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 168 | +        public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput); | 
|  | 169 | + | 
|  | 170 | +        /// <summary> | 
|  | 171 | +        /// Creates the shell without allocating a pseudo terminal, | 
|  | 172 | +        /// similar to the <c>ssh -T</c> option. | 
|  | 173 | +        /// </summary> | 
|  | 174 | +        /// <param name="input">The input.</param> | 
|  | 175 | +        /// <param name="output">The output.</param> | 
|  | 176 | +        /// <param name="extendedOutput">The extended output.</param> | 
|  | 177 | +        /// <param name="bufferSize">Size of the internal read buffer.</param> | 
|  | 178 | +        /// <returns> | 
|  | 179 | +        /// Returns a representation of a <see cref="Shell" /> object. | 
|  | 180 | +        /// </returns> | 
|  | 181 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 182 | +        public Shell CreateShellNoTerminal(Stream input, Stream output, Stream extendedOutput, int bufferSize = -1); | 
|  | 183 | + | 
|  | 184 | +        /// <summary> | 
|  | 185 | +        /// Creates the shell stream. | 
|  | 186 | +        /// </summary> | 
|  | 187 | +        /// <param name="terminalName">The <c>TERM</c> environment variable.</param> | 
|  | 188 | +        /// <param name="columns">The terminal width in columns.</param> | 
|  | 189 | +        /// <param name="rows">The terminal width in rows.</param> | 
|  | 190 | +        /// <param name="width">The terminal width in pixels.</param> | 
|  | 191 | +        /// <param name="height">The terminal height in pixels.</param> | 
|  | 192 | +        /// <param name="bufferSize">The size of the buffer.</param> | 
|  | 193 | +        /// <returns> | 
|  | 194 | +        /// The created <see cref="ShellStream"/> instance. | 
|  | 195 | +        /// </returns> | 
|  | 196 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 197 | +        /// <remarks> | 
|  | 198 | +        /// <para> | 
|  | 199 | +        /// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities. | 
|  | 200 | +        /// You can get a detailed list of these capabilities by using the ‘infocmp’ command. | 
|  | 201 | +        /// </para> | 
|  | 202 | +        /// <para> | 
|  | 203 | +        /// The column/row dimensions override the pixel dimensions(when nonzero). Pixel dimensions refer | 
|  | 204 | +        /// to the drawable area of the window. | 
|  | 205 | +        /// </para> | 
|  | 206 | +        /// </remarks> | 
|  | 207 | +        public ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize); | 
|  | 208 | + | 
|  | 209 | +        /// <summary> | 
|  | 210 | +        /// Creates the shell stream. | 
|  | 211 | +        /// </summary> | 
|  | 212 | +        /// <param name="terminalName">The <c>TERM</c> environment variable.</param> | 
|  | 213 | +        /// <param name="columns">The terminal width in columns.</param> | 
|  | 214 | +        /// <param name="rows">The terminal width in rows.</param> | 
|  | 215 | +        /// <param name="width">The terminal width in pixels.</param> | 
|  | 216 | +        /// <param name="height">The terminal height in pixels.</param> | 
|  | 217 | +        /// <param name="bufferSize">The size of the buffer.</param> | 
|  | 218 | +        /// <param name="terminalModeValues">The terminal mode values.</param> | 
|  | 219 | +        /// <returns> | 
|  | 220 | +        /// The created <see cref="ShellStream"/> instance. | 
|  | 221 | +        /// </returns> | 
|  | 222 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 223 | +        /// <remarks> | 
|  | 224 | +        /// <para> | 
|  | 225 | +        /// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities. | 
|  | 226 | +        /// You can get a detailed list of these capabilities by using the ‘infocmp’ command. | 
|  | 227 | +        /// </para> | 
|  | 228 | +        /// <para> | 
|  | 229 | +        /// The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer | 
|  | 230 | +        /// to the drawable area of the window. | 
|  | 231 | +        /// </para> | 
|  | 232 | +        /// </remarks> | 
|  | 233 | +        public ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize, IDictionary<TerminalModes, uint>? terminalModeValues); | 
|  | 234 | + | 
|  | 235 | +        /// <summary> | 
|  | 236 | +        /// Creates the shell stream without allocating a pseudo terminal, | 
|  | 237 | +        /// similar to the <c>ssh -T</c> option. | 
|  | 238 | +        /// </summary> | 
|  | 239 | +        /// <param name="bufferSize">The size of the buffer.</param> | 
|  | 240 | +        /// <returns> | 
|  | 241 | +        /// The created <see cref="ShellStream"/> instance. | 
|  | 242 | +        /// </returns> | 
|  | 243 | +        /// <exception cref="SshConnectionException">Client is not connected.</exception> | 
|  | 244 | +        public ShellStream CreateShellStreamNoTerminal(int bufferSize = -1); | 
|  | 245 | +    } | 
|  | 246 | +} | 
0 commit comments