Overview
Comment: | OFDNSResolver: Parse more options |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0dc20b422643920ed5b0694a48874c6c |
User & Date: | js on 2018-08-13 21:37:39 |
Other Links: | manifest | tags |
Context
2018-08-13
| ||
21:48 | OFDNSResolver: Require sender == receiver check-in: b004db730a user: js tags: trunk | |
21:37 | OFDNSResolver: Parse more options check-in: 0dc20b4226 user: js tags: trunk | |
21:22 | OFDNSResolver: Configurable timeout and retries check-in: fb6ff94c52 user: js tags: trunk | |
Changes
Modified src/OFDNSResolver.h from [005150c49e] to [5f0f9a4d52].
︙ | ︙ | |||
74 75 76 77 78 79 80 | { OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *_staticHosts; OFArray OF_GENERIC(OFString *) *_nameServers; OFString *_Nullable _localDomain; OFArray OF_GENERIC(OFString *) *_searchDomains; of_time_interval_t _timeout; | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | { OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *_staticHosts; OFArray OF_GENERIC(OFString *) *_nameServers; OFString *_Nullable _localDomain; OFArray OF_GENERIC(OFString *) *_searchDomains; of_time_interval_t _timeout; unsigned int _maxAttempts; size_t _minNumberOfDotsInAbsoluteName; bool _usesTCP; of_time_interval_t _configReloadInterval; OFDate *_lastConfigReload; OFUDPSocket *_IPv4Socket; #ifdef OF_HAVE_IPV6 OFUDPSocket *_IPv6Socket; |
︙ | ︙ | |||
119 120 121 122 123 124 125 | /*! * @brief The timeout, in seconds, after which the next name server should be * tried. */ @property (nonatomic) of_time_interval_t timeout; /*! | | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /*! * @brief The timeout, in seconds, after which the next name server should be * tried. */ @property (nonatomic) of_time_interval_t timeout; /*! * @brief The number of attempts before giving up to resolve a host. * * Trying all name servers once is considered a single attempt. */ @property (nonatomic) unsigned int maxAttempts; /*! * @brief The minimum number of dots for a name to be considered absolute. */ @property (nonatomic) size_t minNumberOfDotsInAbsoluteName; /*! |
︙ | ︙ |
Modified src/OFDNSResolver.m from [30c75fb63e] to [cebc2efbe7].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #import "OFTimer.h" #import "OFUDPSocket.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInvalidArgumentException.h" #import "OFInvalidServerReplyException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFResolveHostFailedException.h" #import "OFTruncatedDataException.h" #ifdef OF_WINDOWS | > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFTimer.h" #import "OFUDPSocket.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFResolveHostFailedException.h" #import "OFTruncatedDataException.h" #ifdef OF_WINDOWS |
︙ | ︙ | |||
87 88 89 90 91 92 93 | OFString *_host, *_domainName; of_dns_resource_record_class_t _recordClass; of_dns_resource_record_type_t _recordType; OFNumber *_ID; OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains; size_t _nameServersIndex, _searchDomainsIndex; of_time_interval_t _timeout; | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | OFString *_host, *_domainName; of_dns_resource_record_class_t _recordClass; of_dns_resource_record_type_t _recordType; OFNumber *_ID; OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains; size_t _nameServersIndex, _searchDomainsIndex; of_time_interval_t _timeout; unsigned int _maxAttempts; size_t _attempt; id _target; SEL _selector; id _context; OFData *_queryData; OFTimer *_cancelTimer; } - (instancetype)initWithHost: (OFString *)host domainName: (OFString *)domainName recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType ID: (OFNumber *)ID nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains timeout: (of_time_interval_t)timeout maxAttempts: (unsigned int)maxAttempts target: (id)target selector: (SEL)selector context: (id)context; @end @interface OFDNSResolver () - (void)of_setDefaults; |
︙ | ︙ | |||
529 530 531 532 533 534 535 | domainName: (OFString *)domainName recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType ID: (OFNumber *)ID nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains timeout: (of_time_interval_t)timeout | | | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | domainName: (OFString *)domainName recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType ID: (OFNumber *)ID nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains timeout: (of_time_interval_t)timeout maxAttempts: (unsigned int)maxAttempts target: (id)target selector: (SEL)selector context: (id)context { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFMutableData *queryData; uint16_t tmp; _host = [host copy]; _domainName = [domainName copy]; _recordClass = recordClass; _recordType = recordType; _ID = [ID retain]; _nameServers = [nameServers copy]; _searchDomains = [searchDomains copy]; _timeout = timeout; _maxAttempts = maxAttempts; _target = [target retain]; _selector = selector; _context = [context retain]; queryData = [OFMutableData dataWithCapacity: 512]; /* Header */ |
︙ | ︙ | |||
634 635 636 637 638 639 640 | [super dealloc]; } @end @implementation OFDNSResolver @synthesize staticHosts = _staticHosts, nameServers = _nameServers; @synthesize localDomain = _localDomain, searchDomains = _searchDomains; | | | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | [super dealloc]; } @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; + (instancetype)resolver { return [[[self alloc] init] autorelease]; } |
︙ | ︙ | |||
662 663 664 665 666 667 668 | return self; } - (void)of_setDefaults { _timeout = 2; | | > > | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | return self; } - (void)of_setDefaults { _timeout = 2; _maxAttempts = 3; _minNumberOfDotsInAbsoluteName = 1; _usesTCP = false; _configReloadInterval = 2; } - (void)of_parseConfig { void *pool = objc_autoreleasePoolPush(); #ifdef OF_WINDOWS OFString *path; #endif [self of_setDefaults]; #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES path = [[OFWindowsRegistryKey localMachineKey] stringForValue: @"DataBasePath" subKeyPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters"]; |
︙ | ︙ | |||
905 906 907 908 909 910 911 | _nameServers = [nameServers copy]; objc_autoreleasePoolPop(pool); } - (void)of_parseResolvConfOption: (OFString *)option { | > | | | < > > > | > > > > | > > > > | > | | > > | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | _nameServers = [nameServers copy]; objc_autoreleasePoolPop(pool); } - (void)of_parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { option = [option substringWithRange: of_range(6, [option length] - 6)]; _minNumberOfDotsInAbsoluteName = (size_t)[option decimalValue]; } else if ([option hasPrefix: @"timeout:"]) { option = [option substringWithRange: of_range(8, [option length] - 8)]; _timeout = [option decimalValue]; } else if ([option hasPrefix: @"attempts:"]) { option = [option substringWithRange: of_range(9, [option length] - 9)]; _maxAttempts = (unsigned int)[option decimalValue]; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringWithRange: of_range(14, [option length] - 14)]; _configReloadInterval = [option decimalValue]; } else if ([option isEqual: @"tcp"]) _usesTCP = true; } @catch (OFInvalidFormatException *e) { } } # endif #endif #ifdef OF_WINDOWS - (void)of_parseNetworkParams { |
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 | domainName: domainName recordClass: recordClass recordType: recordType ID: ID nameServers: _nameServers searchDomains: _searchDomains timeout: _timeout | | | 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 | domainName: domainName recordClass: recordClass recordType: recordType ID: ID nameServers: _nameServers searchDomains: _searchDomains timeout: _timeout maxAttempts: _maxAttempts target: target selector: selector context: context] autorelease]; [_queries setObject: query forKey: ID]; [self of_sendQuery: query]; |
︙ | ︙ | |||
1121 1122 1123 1124 1125 1126 1127 | if (query->_nameServersIndex + 1 < [query->_nameServers count]) { query->_nameServersIndex++; [self of_sendQuery: query]; return; } | | | 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | if (query->_nameServersIndex + 1 < [query->_nameServers count]) { query->_nameServersIndex++; [self of_sendQuery: query]; return; } if (query->_attempt < query->_maxAttempts) { query->_attempt++; query->_nameServersIndex = 0; [self of_sendQuery: query]; return; } query = [[query retain] autorelease]; |
︙ | ︙ |