@@ -41,20 +41,57 @@ public sealed class Socks5ProxySettings
41
41
/// </summary>
42
42
public Socks5AuthenticationSettings Authentication { get ; }
43
43
44
- internal Socks5ProxySettings ( string host , int ? port , Socks5AuthenticationSettings authentication )
44
+ /// <summary>
45
+ /// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host.
46
+ /// </summary>
47
+ /// <param name="host">The SOCKS5 proxy host.</param>
48
+ public Socks5ProxySettings ( string host )
49
+ : this ( host , DefaultPort , Socks5AuthenticationSettings . None )
50
+ {
51
+ }
52
+
53
+ /// <summary>
54
+ /// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host and port.
55
+ /// </summary>
56
+ /// <param name="host">The proxy host.</param>
57
+ /// <param name="port">The proxy port.</param>
58
+ public Socks5ProxySettings ( string host , int port )
59
+ : this ( host , port , Socks5AuthenticationSettings . None )
60
+ {
61
+ }
62
+
63
+ /// <summary>
64
+ /// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host and authentication settings.
65
+ /// </summary>
66
+ /// <param name="host">The proxy host.</param>
67
+ /// <param name="authentication">The proxy authentication settings.</param>
68
+ public Socks5ProxySettings ( string host , Socks5AuthenticationSettings authentication )
69
+ : this ( host , DefaultPort , authentication )
70
+ {
71
+ }
72
+
73
+ /// <summary>
74
+ /// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host, port, and authentication settings.
75
+ /// </summary>
76
+ /// <param name="host">The proxy host.</param>
77
+ /// <param name="port">The proxy port.</param>
78
+ /// <param name="authentication">The proxy authentication settings.</param>
79
+ public Socks5ProxySettings ( string host , int port , Socks5AuthenticationSettings authentication )
45
80
{
46
81
Host = Ensure . IsNotNullOrEmpty ( host , nameof ( host ) ) ;
47
- Port = port is null ? DefaultPort : Ensure . IsBetween ( port . Value , 1 , 65535 , nameof ( port ) ) ;
48
- Authentication = authentication ?? Socks5AuthenticationSettings . None ;
82
+ Port = Ensure . IsBetween ( port , 1 , 65535 , nameof ( port ) ) ;
83
+ Authentication = Ensure . IsNotNull ( authentication , nameof ( authentication ) ) ;
49
84
}
50
85
51
- // Convenience method used internally .
86
+ // This is a convenience method to create Socks5ProxySettings from the connection string parameters .
52
87
internal static Socks5ProxySettings Create ( string host , int ? port , string username , string password )
53
88
{
54
- var authentication = ! string . IsNullOrEmpty ( username ) ?
55
- Socks5AuthenticationSettings . UsernamePassword ( username , password ) : Socks5AuthenticationSettings . None ;
89
+ var authentication =
90
+ ! string . IsNullOrEmpty ( username ) && ! string . IsNullOrEmpty ( password )
91
+ ? Socks5AuthenticationSettings . UsernamePassword ( username , password )
92
+ : Socks5AuthenticationSettings . None ;
56
93
57
- return new Socks5ProxySettings ( host , port , authentication ) ;
94
+ return new Socks5ProxySettings ( host , port ?? DefaultPort , authentication ) ;
58
95
}
59
96
60
97
/// <inheritdoc />
0 commit comments