Index: src/OFTCPSocketSOCKS5Connector.h ================================================================== --- src/OFTCPSocketSOCKS5Connector.h +++ src/OFTCPSocketSOCKS5Connector.h @@ -20,10 +20,11 @@ @class OFString; @interface OFTCPSocketSOCKS5Connector: OFObject { OFTCPSocket *_socket; + Class _socketClass; OFString *_host; uint16_t _port; id _Nullable _delegate; #ifdef OF_HAVE_BLOCKS OFTCPSocketAsyncConnectBlock _Nullable _block; Index: src/OFTCPSocketSOCKS5Connector.m ================================================================== --- src/OFTCPSocketSOCKS5Connector.m +++ src/OFTCPSocketSOCKS5Connector.m @@ -52,10 +52,18 @@ _delegate = [delegate retain]; #ifdef OF_HAVE_BLOCKS _block = [block copy]; #endif + /* + * Temporarily swizzle it to a TCP socket, so that if it's a + * TLS socket, we still get to talk to the SOCKS5 proxy + * directly. + */ + _socketClass = object_getClass(_socket); + object_setClass(_socket, [OFTCPSocket class]); + _socket.delegate = self; } @catch (id e) { [self release]; @throw e; } @@ -65,10 +73,12 @@ - (void)dealloc { if (_socket.delegate == self) _socket.delegate = _delegate; + + object_setClass(_socket, _socketClass); [_socket release]; [_host release]; [_delegate release]; #ifdef OF_HAVE_BLOCKS @@ -81,10 +91,11 @@ } - (void)didConnect { _socket.delegate = _delegate; + object_setClass(_socket, _socketClass); #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_exception); else {