| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Connection |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents an SSH identification. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class SshIdentification |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Initializes a new instance of the <see cref="SshIdentification"/> class with the specified protocol version |
| | | 12 | | /// and software version. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="protocolVersion">The SSH protocol version.</param> |
| | | 15 | | /// <param name="softwareVersion">The software version of the implementation.</param> |
| | | 16 | | /// <exception cref="ArgumentNullException"><paramref name="protocolVersion"/> is <see langword="null"/>.</excep |
| | | 17 | | /// <exception cref="ArgumentNullException"><paramref name="softwareVersion"/> is <see langword="null"/>.</excep |
| | | 18 | | public SshIdentification(string protocolVersion, string softwareVersion) |
| | 666 | 19 | | : this(protocolVersion, softwareVersion, comments: null) |
| | 660 | 20 | | { |
| | 660 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Initializes a new instance of the <see cref="SshIdentification"/> class with the specified protocol version, |
| | | 25 | | /// software version and comments. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="protocolVersion">The SSH protocol version.</param> |
| | | 28 | | /// <param name="softwareVersion">The software version of the implementation.</param> |
| | | 29 | | /// <param name="comments">The comments.</param> |
| | | 30 | | /// <exception cref="ArgumentNullException"><paramref name="protocolVersion"/> is <see langword="null"/>.</excep |
| | | 31 | | /// <exception cref="ArgumentNullException"><paramref name="softwareVersion"/> is <see langword="null"/>.</excep |
| | 1919 | 32 | | public SshIdentification(string protocolVersion, string softwareVersion, string comments) |
| | 1919 | 33 | | { |
| | 1919 | 34 | | if (protocolVersion is null) |
| | 6 | 35 | | { |
| | 6 | 36 | | throw new ArgumentNullException(nameof(protocolVersion)); |
| | | 37 | | } |
| | | 38 | | |
| | 1913 | 39 | | if (softwareVersion is null) |
| | 6 | 40 | | { |
| | 6 | 41 | | throw new ArgumentNullException(nameof(softwareVersion)); |
| | | 42 | | } |
| | | 43 | | |
| | 1907 | 44 | | ProtocolVersion = protocolVersion; |
| | 1907 | 45 | | SoftwareVersion = softwareVersion; |
| | 1907 | 46 | | Comments = comments; |
| | 1907 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets the software version of the implementation. |
| | | 51 | | /// </summary> |
| | | 52 | | /// <value> |
| | | 53 | | /// The software version of the implementation. |
| | | 54 | | /// </value> |
| | | 55 | | /// <remarks> |
| | | 56 | | /// This is primarily used to trigger compatibility extensions and to indicate |
| | | 57 | | /// the capabilities of an implementation. |
| | | 58 | | /// </remarks> |
| | 3751 | 59 | | public string SoftwareVersion { get; } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets the SSH protocol version. |
| | | 63 | | /// </summary> |
| | | 64 | | /// <value> |
| | | 65 | | /// The SSH protocol version. |
| | | 66 | | /// </value> |
| | 5478 | 67 | | public string ProtocolVersion { get; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets the comments. |
| | | 71 | | /// </summary> |
| | | 72 | | /// <value> |
| | | 73 | | /// The comments, or <see langword="null"/> if there are no comments. |
| | | 74 | | /// </value> |
| | | 75 | | /// <remarks> |
| | | 76 | | /// <see cref="Comments"/> should contain additional information that might be useful |
| | | 77 | | /// in solving user problems. |
| | | 78 | | /// </remarks> |
| | 3664 | 79 | | public string Comments { get; } |
| | | 80 | | |
| | | 81 | | /// <summary> |
| | | 82 | | /// Returns the SSH identification string. |
| | | 83 | | /// </summary> |
| | | 84 | | /// <returns> |
| | | 85 | | /// The SSH identification string. |
| | | 86 | | /// </returns> |
| | | 87 | | public override string ToString() |
| | 3643 | 88 | | { |
| | 3643 | 89 | | var identificationString = "SSH-" + ProtocolVersion + "-" + SoftwareVersion; |
| | | 90 | | |
| | 3643 | 91 | | if (Comments != null) |
| | 3 | 92 | | { |
| | 3 | 93 | | identificationString += " " + Comments; |
| | 3 | 94 | | } |
| | | 95 | | |
| | 3643 | 96 | | return identificationString; |
| | 3643 | 97 | | } |
| | | 98 | | } |
| | | 99 | | } |