49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
@"-c --class "
@" The DNS class to query (defaults to IN)\n "
@"-h --help "
@" Show this help\n "
@"-s --server"
@" The server to query\n "
@"-t --type "
@" The record type to query (defaults to ALL)")];
}
[OFApplication terminateWithStatus: status];
}
@implementation OFDNS
- (void)resolver: (OFDNSResolver *)resolver
|
|
>
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
@"-c --class "
@" The DNS class to query (defaults to IN)\n "
@"-h --help "
@" Show this help\n "
@"-s --server"
@" The server to query\n "
@"-t --type "
@" The record type to query (defaults to ALL, can be "
@"repeated)")];
}
[OFApplication terminateWithStatus: status];
}
@implementation OFDNS
- (void)resolver: (OFDNSResolver *)resolver
|
79
80
81
82
83
84
85
86
87
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
120
121
122
123
124
125
126
127
128
129
130
|
if (_inFlight == 0)
[OFApplication terminateWithStatus: _errors];
}
- (void)applicationDidFinishLaunching
{
OFString *DNSClassString, *server, *recordTypeString;
const of_options_parser_option_t options[] = {
{ 'c', @"class", 1, NULL, &DNSClassString },
{ 'h', @"help", 0, NULL, NULL },
{ 's', @"server", 1, NULL, &server },
{ 't', @"type", 1, NULL, &recordTypeString },
{ '\0', nil, 0, NULL, NULL }
};
OFOptionsParser *optionsParser;
of_unichar_t option;
OFArray OF_GENERIC(OFString *) *remainingArguments;
OFDNSResolver *resolver;
of_dns_class_t DNSClass;
of_dns_record_type_t recordType;
#ifdef OF_HAVE_FILES
# ifndef OF_AMIGAOS
[OFLocale addLanguageDirectory: @LANGUAGE_DIR];
# else
[OFLocale addLanguageDirectory: @"PROGDIR:/share/ofdns/lang"];
# endif
#endif
#ifdef OF_HAVE_SANDBOX
OFSandbox *sandbox = [[OFSandbox alloc] init];
@try {
sandbox.allowsStdIO = true;
sandbox.allowsDNS = true;
[OFApplication activateSandbox: sandbox];
} @finally {
[sandbox release];
}
#endif
optionsParser = [OFOptionsParser parserWithOptions: options];
while ((option = [optionsParser nextOption]) != '\0') {
switch (option) {
case 'h':
help(of_stdout, true, 0);
break;
case ':':
if (optionsParser.lastLongOption != nil)
[of_stderr writeLine: OF_LOCALIZED(
@"long_option_required_argument",
|
|
|
>
<
>
>
>
>
>
|
80
81
82
83
84
85
86
87
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
if (_inFlight == 0)
[OFApplication terminateWithStatus: _errors];
}
- (void)applicationDidFinishLaunching
{
OFString *DNSClassString, *server;
const of_options_parser_option_t options[] = {
{ 'c', @"class", 1, NULL, &DNSClassString },
{ 'h', @"help", 0, NULL, NULL },
{ 's', @"server", 1, NULL, &server },
{ 't', @"type", 1, NULL, NULL },
{ '\0', nil, 0, NULL, NULL }
};
OFMutableArray OF_GENERIC(OFString *) *recordTypes;
OFOptionsParser *optionsParser;
of_unichar_t option;
OFArray OF_GENERIC(OFString *) *remainingArguments;
OFDNSResolver *resolver;
of_dns_class_t DNSClass;
#ifdef OF_HAVE_FILES
# ifndef OF_AMIGAOS
[OFLocale addLanguageDirectory: @LANGUAGE_DIR];
# else
[OFLocale addLanguageDirectory: @"PROGDIR:/share/ofdns/lang"];
# endif
#endif
#ifdef OF_HAVE_SANDBOX
OFSandbox *sandbox = [[OFSandbox alloc] init];
@try {
sandbox.allowsStdIO = true;
sandbox.allowsDNS = true;
[OFApplication activateSandbox: sandbox];
} @finally {
[sandbox release];
}
#endif
recordTypes = [OFMutableArray array];
optionsParser = [OFOptionsParser parserWithOptions: options];
while ((option = [optionsParser nextOption]) != '\0') {
switch (option) {
case 't':
[recordTypes addObject: optionsParser.argument];
break;
case 'h':
help(of_stdout, true, 0);
break;
case ':':
if (optionsParser.lastLongOption != nil)
[of_stderr writeLine: OF_LOCALIZED(
@"long_option_required_argument",
|
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
remainingArguments = optionsParser.remainingArguments;
if (remainingArguments.count < 1)
help(of_stderr, false, 1);
resolver = [OFDNSResolver resolver];
recordType = (recordTypeString != nil
? of_dns_record_type_parse(recordTypeString)
: OF_DNS_RECORD_TYPE_ALL);
DNSClass = (DNSClassString != nil
? of_dns_class_parse(DNSClassString)
: OF_DNS_CLASS_IN);
if (server != nil) {
resolver.configReloadInterval = 0;
resolver.nameServers = [OFArray arrayWithObject: server];
}
_inFlight = remainingArguments.count;
for (OFString *domainName in remainingArguments) {
OFDNSQuery *query =
[OFDNSQuery queryWithDomainName: domainName
DNSClass: DNSClass
recordType: recordType];
[resolver asyncPerformQuery: query
delegate: self];
}
}
@end
|
<
<
<
>
>
>
<
>
>
>
|
|
|
|
>
|
|
>
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
remainingArguments = optionsParser.remainingArguments;
if (remainingArguments.count < 1)
help(of_stderr, false, 1);
resolver = [OFDNSResolver resolver];
DNSClass = (DNSClassString != nil
? of_dns_class_parse(DNSClassString)
: OF_DNS_CLASS_IN);
if (recordTypes.count == 0)
[recordTypes addObject: @"ALL"];
if (server != nil) {
resolver.configReloadInterval = 0;
resolver.nameServers = [OFArray arrayWithObject: server];
}
for (OFString *domainName in remainingArguments) {
for (OFString *recordTypeString in recordTypes) {
of_dns_record_type_t recordType =
of_dns_record_type_parse(recordTypeString);
OFDNSQuery *query =
[OFDNSQuery queryWithDomainName: domainName
DNSClass: DNSClass
recordType: recordType];
_inFlight++;
[resolver asyncPerformQuery: query
delegate: self];
}
}
}
@end
|