Skip to content

Commit

Permalink
Use switch instead of if/elseif.
Browse files Browse the repository at this point in the history
  • Loading branch information
drieseng committed Jul 30, 2018
1 parent adeeb8c commit cfd4125
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Renci.SshNet/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2287,19 +2287,18 @@ private static byte[] GetSocks5DestinationAddress(string hostname, out byte addr

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;
Expand Down

0 comments on commit cfd4125

Please sign in to comment.