Overview
Comment: | OFDNSResolver: Add sync resolve socket addresses |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
22700e60828f24c0846de8d014886e86 |
User & Date: | js on 2018-10-06 20:21:47 |
Other Links: | manifest | tags |
Context
2018-10-07
| ||
02:06 | Remove resolver.m check-in: 6e9ee122eb user: js tags: trunk | |
2018-10-06
| ||
20:21 | OFDNSResolver: Add sync resolve socket addresses check-in: 22700e6082 user: js tags: trunk | |
19:41 | OFTCPSocket: -[setBlocking:] on new connections check-in: 02073abe82 user: js tags: trunk | |
Changes
Modified src/OFDNSResolver.h from [d24746b59f] to [e43a0539a7].
︙ | ︙ | |||
383 384 385 386 387 388 389 390 391 392 393 394 395 396 | addressFamily: (of_socket_address_family_t) addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (nullable id)context; /*! * @brief Closes all sockets and cancels all ongoing requests. */ - (void)close; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | addressFamily: (of_socket_address_family_t) addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (nullable id)context; /*! * @brief Synchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param addressFamily The desired socket address family * @return OFData containing several of_socket_address_t */ - (OFData *)resolveSocketAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t) addressFamily; /*! * @brief Closes all sockets and cancels all ongoing requests. */ - (void)close; @end OF_ASSUME_NONNULL_END |
Modified src/OFDNSResolver.m from [3ad875198a] to [8f4fd230d2].
︙ | ︙ | |||
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /* * TODO: * * - Fallback to TCP */ @interface OFDNSResolverSettings: OFObject { @public OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains; of_time_interval_t _timeout; unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName; } | > > | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /* * TODO: * * - Fallback to TCP */ static of_run_loop_mode_t resolveRunLoopMode = @"of_dns_resolver_resolve_mode"; @interface OFDNSResolverSettings: OFObject { @public OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains; of_time_interval_t _timeout; unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName; } |
︙ | ︙ | |||
156 157 158 159 160 161 162 | nameServersIndex: (size_t)nameServersIndex searchDomainsIndex: (size_t)searchDomainsIndex target: (id)target selector: (SEL)selector context: (id)context; @end | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | nameServersIndex: (size_t)nameServersIndex searchDomainsIndex: (size_t)searchDomainsIndex target: (id)target selector: (SEL)selector context: (id)context; @end @interface OFDNSResolver_AsyncResolveSocketAddressesContext: OFObject { OFString *_host; id _target; SEL _selector; id _context; OFMutableArray OF_GENERIC(OF_KINDOF(OFDNSResourceRecord *)) *_records; OFDNSResolver *_resolver; |
︙ | ︙ | |||
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords context: (id)context exception: (id)exception; @end @interface OFDNSResolver () - (void)of_setDefaults; - (void)of_obtainSystemConfig; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS) - (void)of_parseHosts: (OFString *)path; # if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) | > > > > > > > > > > > > > > > | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords context: (id)context exception: (id)exception; @end @interface OFDNSResolver_ResolveSocketAddressesContext: OFObject { @public bool _done; OFData *_socketAddresses; id _exception; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses context: (id)context exception: (id)exception; @end @interface OFDNSResolver () - (void)of_setDefaults; - (void)of_obtainSystemConfig; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS) - (void)of_parseHosts: (OFString *)path; # if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) |
︙ | ︙ | |||
819 820 821 822 823 824 825 | [_queryData release]; [_cancelTimer release]; [super dealloc]; } @end | | | 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | [_queryData release]; [_cancelTimer release]; [super dealloc]; } @end @implementation OFDNSResolver_AsyncResolveSocketAddressesContext - (instancetype)initWithHost: (OFString *)host target: (id)target selector: (SEL)selector context: (id)context { self = [super init]; |
︙ | ︙ | |||
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | recursion: CNAME_RECURSION result: _records]; if (_expectedResponses == 0) [self done]; } @end @implementation OFDNSResolver @synthesize staticHosts = _staticHosts, nameServers = _nameServers; @synthesize localDomain = _localDomain, searchDomains = _searchDomains; @synthesize timeout = _timeout, maxAttempts = _maxAttempts; @synthesize minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName; @synthesize usesTCP = _usesTCP, configReloadInterval = _configReloadInterval; | > > > > > > > > > > > > > > > > > > > > > | 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | recursion: CNAME_RECURSION result: _records]; if (_expectedResponses == 0) [self done]; } @end @implementation OFDNSResolver_ResolveSocketAddressesContext - (void)dealloc { [_socketAddresses release]; [_exception release]; [super dealloc]; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses context: (id)context exception: (id)exception { _socketAddresses = [socketAddresses retain]; _exception = [exception retain]; _done = true; } @end @implementation OFDNSResolver @synthesize staticHosts = _staticHosts, nameServers = _nameServers; @synthesize localDomain = _localDomain, searchDomains = _searchDomains; @synthesize timeout = _timeout, maxAttempts = _maxAttempts; @synthesize minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName; @synthesize usesTCP = _usesTCP, configReloadInterval = _configReloadInterval; |
︙ | ︙ | |||
2030 2031 2032 2033 2034 2035 2036 | addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)userContext { void *pool = objc_autoreleasePoolPush(); | | | | 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 | addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)userContext { void *pool = objc_autoreleasePoolPush(); OFDNSResolver_AsyncResolveSocketAddressesContext *context; context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc] initWithHost: host target: target selector: selector context: userContext] autorelease]; switch (addressFamily) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: |
︙ | ︙ | |||
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 | additionalRecords:context: exception:) context: [OFNumber numberWithInt: OF_DNS_RESOURCE_RECORD_TYPE_A]]; objc_autoreleasePoolPop(pool); } - (void)close { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(OFDNSResolverQuery *) *enumerator; OFDNSResolverQuery *query; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 | additionalRecords:context: exception:) context: [OFNumber numberWithInt: OF_DNS_RESOURCE_RECORD_TYPE_A]]; objc_autoreleasePoolPop(pool); } - (OFData *)resolveSocketAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t) addressFamily { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop = [OFRunLoop currentRunLoop]; OFDNSResolver_ResolveSocketAddressesContext *context; OFData *ret; context = [[[OFDNSResolver_ResolveSocketAddressesContext alloc] init] autorelease]; [self asyncResolveSocketAddressesForHost: host addressFamily: addressFamily runLoopMode: resolveRunLoopMode target: context selector: @selector(resolver: didResolveDomainName: socketAddresses:context: exception:) context: nil]; while (!context->_done) [runLoop runMode: resolveRunLoopMode beforeDate: nil]; /* Cleanup */ [runLoop runMode: resolveRunLoopMode beforeDate: [OFDate date]]; if (context->_exception != nil) @throw context->_exception; ret = [context->_socketAddresses retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)close { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(OFDNSResolverQuery *) *enumerator; OFDNSResolverQuery *query; |
︙ | ︙ |
Modified src/OFTCPSocket.m from [8eaed27d7d] to [2642e89679].
︙ | ︙ | |||
144 145 146 147 148 149 150 | context: (id)context exception: (id)exception; @end @interface OFTCPSocket_ConnectContext: OFObject { @public | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | context: (id)context exception: (id)exception; @end @interface OFTCPSocket_ConnectContext: OFObject { @public bool _done; id _exception; } - (void)socketDidConnect: (OFTCPSocket *)sock context: (id)context exception: (id)exception; @end |
︙ | ︙ | |||
653 654 655 656 657 658 659 | [super dealloc]; } - (void)socketDidConnect: (OFTCPSocket *)sock context: (id)context exception: (id)exception { | < | < | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | [super dealloc]; } - (void)socketDidConnect: (OFTCPSocket *)sock context: (id)context exception: (id)exception { _exception = [exception retain]; _done = true; } @end @implementation OFTCPSocket @synthesize SOCKS5Host = _SOCKS5Host, SOCKS5Port = _SOCKS5Port; + (void)setSOCKS5Host: (OFString *)host |
︙ | ︙ | |||
779 780 781 782 783 784 785 | [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode target: context selector: @selector(socketDidConnect:context:exception:) context: nil]; | | | 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 | [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode target: context selector: @selector(socketDidConnect:context:exception:) context: nil]; while (!context->_done) [runLoop runMode: connectRunLoopMode beforeDate: nil]; /* Cleanup */ [runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]]; |
︙ | ︙ |