Skip to content

Commit cfd4125

Browse files
committed
Use switch instead of if/elseif.
1 parent adeeb8c commit cfd4125

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Renci.SshNet/Session.cs

+11-12
Original file line numberDiff line numberDiff line change
@@ -2287,19 +2287,18 @@ private static byte[] GetSocks5DestinationAddress(string hostname, out byte addr
22872287

22882288
byte[] address;
22892289

2290-
if (ip.AddressFamily == AddressFamily.InterNetwork)
2290+
switch (ip.AddressFamily)
22912291
{
2292-
addressType = 0x01; // IPv4
2293-
address = ip.GetAddressBytes();
2294-
}
2295-
else if (ip.AddressFamily == AddressFamily.InterNetworkV6)
2296-
{
2297-
addressType = 0x04; // IPv6
2298-
address = ip.GetAddressBytes();
2299-
}
2300-
else
2301-
{
2302-
throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip));
2292+
case AddressFamily.InterNetwork:
2293+
addressType = 0x01; // IPv4
2294+
address = ip.GetAddressBytes();
2295+
break;
2296+
case AddressFamily.InterNetworkV6:
2297+
addressType = 0x04; // IPv6
2298+
address = ip.GetAddressBytes();
2299+
break;
2300+
default:
2301+
throw new ProxyException(string.Format("SOCKS5: IP address '{0}' is not supported.", ip));
23032302
}
23042303

23052304
return address;

0 commit comments

Comments
 (0)