Use switch instead of if/elseif.

This commit is contained in:
Gert Driesen
2018-07-30 21:34:59 +02:00
parent adeeb8c231
commit cfd412529e
+11 -12
View File
@@ -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;