Differences From Artifact [9927726f3b]:
- File src/OFTCPSocket.m — part of check-in [3501205f07] at 2018-12-18 17:10:58 on branch trunk — Slightly decrease binary size (user: js, size: 25794) [annotate] [blame] [check-ins using]
To Artifact [b5ab8aeaeb]:
- File
src/OFTCPSocket.m
— part of check-in
[0afb04d93c]
at
2018-12-22 00:29:42
on branch trunk
— OFDNSResolver: Use a delegate for async operations
Because there is usually only one resolver per thread, having the
delegate as a property on the resolver would not work. It is therefore
passed as an argument.This only changes the public API so far. Internally, the old target /
selector / context pattern is still being used. This will be changed
later. (user: js, size: 25444) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
60 61 62 63 64 65 66 | Class of_tls_socket_class = Nil; static of_run_loop_mode_t connectRunLoopMode = @"of_tcp_socket_connect_mode"; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | Class of_tls_socket_class = Nil; static of_run_loop_mode_t connectRunLoopMode = @"of_tcp_socket_connect_mode"; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; @interface OFTCPSocket_AsyncConnectDelegate: OFObject <OFTCPSocketDelegate, OFTCPSocketDelegate_Private, OFDNSResolverDelegate> { OFTCPSocket *_socket; OFString *_host; uint16_t _port; OFString *_SOCKS5Host; uint16_t _SOCKS5Port; id <OFTCPSocketDelegate> _delegate; |
︙ | ︙ | |||
104 105 106 107 108 109 110 | port: (uint16_t)port SOCKS5Host: (OFString *)SOCKS5Host SOCKS5Port: (uint16_t)SOCKS5Port block: (of_tcp_socket_async_connect_block_t)block; #endif - (void)didConnect; - (void)tryNextAddressWithRunLoopMode: (of_run_loop_mode_t)runLoopMode; | < < < < < | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | port: (uint16_t)port SOCKS5Host: (OFString *)SOCKS5Host SOCKS5Port: (uint16_t)SOCKS5Port block: (of_tcp_socket_async_connect_block_t)block; #endif - (void)didConnect; - (void)tryNextAddressWithRunLoopMode: (of_run_loop_mode_t)runLoopMode; - (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode; - (void)sendSOCKS5Request; @end @interface OFTCPSocket_ConnectDelegate: OFObject <OFTCPSocketDelegate> { @public bool _done; id _exception; } @end @implementation OFTCPSocket_AsyncConnectDelegate - (instancetype)initWithSocket: (OFTCPSocket *)sock host: (OFString *)host port: (uint16_t)port SOCKS5Host: (OFString *)SOCKS5Host SOCKS5Port: (uint16_t)SOCKS5Port delegate: (id <OFTCPSocketDelegate>)delegate { |
︙ | ︙ | |||
300 301 302 303 304 305 306 | [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses | < | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses exception: (id)exception { if (exception != nil) { _exception = [exception retain]; [self didConnect]; return; } |
︙ | ︙ | |||
349 350 351 352 353 354 355 | } @catch (OFInvalidFormatException *e) { } [[OFThread DNSResolver] asyncResolveSocketAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY runLoopMode: runLoopMode | | < < < < < | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | } @catch (OFInvalidFormatException *e) { } [[OFThread DNSResolver] asyncResolveSocketAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY runLoopMode: runLoopMode delegate: self]; } - (void)sendSOCKS5Request { OFData *data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; |
︙ | ︙ | |||
726 727 728 729 730 731 732 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode { void *pool = objc_autoreleasePoolPush(); | | | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_AsyncConnectDelegate alloc] initWithSocket: self host: host port: port SOCKS5Host: _SOCKS5Host SOCKS5Port: _SOCKS5Port delegate: _delegate] autorelease] startWithRunLoopMode: runLoopMode]; |
︙ | ︙ | |||
756 757 758 759 760 761 762 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode block: (of_tcp_socket_async_connect_block_t)block { void *pool = objc_autoreleasePoolPush(); | | | 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode block: (of_tcp_socket_async_connect_block_t)block { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_AsyncConnectDelegate alloc] initWithSocket: self host: host port: port SOCKS5Host: _SOCKS5Host SOCKS5Port: _SOCKS5Port block: block] autorelease] startWithRunLoopMode: runLoopMode]; |
︙ | ︙ |