mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 13:39:09 +00:00
Use switch instead of if/elseif.
This commit is contained in:
+11
-12
@@ -2287,19 +2287,18 @@ namespace Renci.SshNet
|
||||
|
||||
byte[] address;
|
||||
|
||||
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||
switch (ip.AddressFamily)
|
||||
{
|
||||
addressType = 0x01; // IPv4
|
||||
address = ip.GetAddressBytes();
|
||||
}
|
||||
else if (ip.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
addressType = 0x04; // IPv6
|
||||
address = ip.GetAddressBytes();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip));
|
||||
case AddressFamily.InterNetwork:
|
||||
addressType = 0x01; // IPv4
|
||||
address = ip.GetAddressBytes();
|
||||
break;
|
||||
case AddressFamily.InterNetworkV6:
|
||||
addressType = 0x04; // IPv6
|
||||
address = ip.GetAddressBytes();
|
||||
break;
|
||||
default:
|
||||
throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip));
|
||||
}
|
||||
|
||||
return address;
|
||||
|
||||
Reference in New Issue
Block a user