@@ -954,7 +954,7 @@ internal void SendMessage(Message message)
954
954
hash = _clientMac . ComputeHash ( packetData ) ;
955
955
}
956
956
957
- // Encrypt packet data
957
+ // Encrypt packet data
958
958
if ( _clientCipher != null )
959
959
{
960
960
packetData = _clientCipher . Encrypt ( packetData , packetDataOffset , ( packetData . Length - packetDataOffset ) ) ;
@@ -1952,9 +1952,9 @@ private void MessageListener()
1952
1952
break ;
1953
1953
}
1954
1954
#elif FEATURE_SOCKET_POLL
1955
- // when Socket.Select(IList, IList, IList, Int32) is not available or is buggy, we use
1956
- // Socket.Poll(Int, SelectMode) to block until either data is available or the socket
1957
- // is closed
1955
+ // when Socket.Select(IList, IList, IList, Int32) is not available or is buggy, we use
1956
+ // Socket.Poll(Int, SelectMode) to block until either data is available or the socket
1957
+ // is closed
1958
1958
_socket . Poll ( - 1 , SelectMode . SelectRead ) ;
1959
1959
1960
1960
if ( ! _socket . IsConnected ( ) )
@@ -2271,14 +2271,16 @@ private static byte[] CreateSocks5ConnectionRequest(string hostname, ushort port
2271
2271
2272
2272
private static byte [ ] GetSocks4DestinationAddress ( string hostname )
2273
2273
{
2274
- var ip = DnsAbstraction . GetHostAddresses ( hostname ) [ 0 ] ;
2274
+ var addresses = DnsAbstraction . GetHostAddresses ( hostname ) ;
2275
2275
2276
- if ( ip . AddressFamily != AddressFamily . InterNetwork )
2276
+ for ( var i = 0 ; i < addresses . Length ; i ++ )
2277
2277
{
2278
- throw new ProxyException ( "SOCKS4 only supports IPv4." ) ;
2278
+ var address = addresses [ i ] ;
2279
+ if ( address . AddressFamily == AddressFamily . InterNetwork )
2280
+ return address . GetAddressBytes ( ) ;
2279
2281
}
2280
2282
2281
- return ip . GetAddressBytes ( ) ;
2283
+ throw new ProxyException ( string . Format ( "SOCKS4 only supports IPv4. No such address found for '{0}'." , hostname ) ) ;
2282
2284
}
2283
2285
2284
2286
private static byte [ ] GetSocks5DestinationAddress ( string hostname , out byte addressType )
@@ -2442,7 +2444,7 @@ private void Reset()
2442
2444
private static SshConnectionException CreateConnectionAbortedByServerException ( )
2443
2445
{
2444
2446
return new SshConnectionException ( "An established connection was aborted by the server." ,
2445
- DisconnectReason . ConnectionLost ) ;
2447
+ DisconnectReason . ConnectionLost ) ;
2446
2448
}
2447
2449
2448
2450
#region IDisposable implementation
0 commit comments