18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
|
-
+
+
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
|
#include "config.h"
#import "OFDNSResponse.h"
#import "OFDictionary.h"
#import "OFString.h"
@implementation OFDNSResponse
@synthesize answerRecords = _answerRecords;
@synthesize domainName = _domainName, answerRecords = _answerRecords;
@synthesize authorityRecords = _authorityRecords;
@synthesize additionalRecords = _additionalRecords;
+ (instancetype)
responseWithDomainName: (OFString *)domainName
responseWithAnswerRecords: (of_dns_response_records_t)answerRecords
authorityRecords: (of_dns_response_records_t)authorityRecords
additionalRecords: (of_dns_response_records_t)additionalRecords
answerRecords: (of_dns_response_records_t)answerRecords
authorityRecords: (of_dns_response_records_t)authorityRecords
additionalRecords: (of_dns_response_records_t)additionalRecords
{
return [[[self alloc]
initWithDomainName: domainName
initWithAnswerRecords: answerRecords
authorityRecords: authorityRecords
additionalRecords: additionalRecords] autorelease];
answerRecords: answerRecords
authorityRecords: authorityRecords
additionalRecords: additionalRecords] autorelease];
}
- (instancetype)
initWithAnswerRecords: (of_dns_response_records_t)answerRecords
authorityRecords: (of_dns_response_records_t)authorityRecords
additionalRecords: (of_dns_response_records_t)additionalRecords
- (instancetype)initWithDomainName: (OFString *)domainName
answerRecords: (of_dns_response_records_t)answerRecords
authorityRecords: (of_dns_response_records_t)authorityRecords
additionalRecords: (of_dns_response_records_t)additionalRecords
{
self = [super init];
@try {
_domainName = [domainName copy];
_answerRecords = [answerRecords copy];
_authorityRecords = [authorityRecords copy];
_additionalRecords = [additionalRecords copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)init OF_UNAVAILABLE
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_domainName release];
[_answerRecords release];
[_authorityRecords release];
[_additionalRecords release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFDNSResponse *other;
OFDNSResponse *response;
if (![object isKindOfClass: [OFDNSResponse class]])
return false;
other = object;
response = object;
if (response->_domainName != _domainName &&
![response->_domainName isEqual: _domainName])
return false;
if (other->_answerRecords != _answerRecords &&
![other->_answerRecords isEqual: _answerRecords])
if (response->_answerRecords != _answerRecords &&
![response->_answerRecords isEqual: _answerRecords])
return false;
if (other->_authorityRecords != _authorityRecords &&
![other->_authorityRecords isEqual: _authorityRecords])
if (response->_authorityRecords != _authorityRecords &&
![response->_authorityRecords isEqual: _authorityRecords])
return false;
if (other->_additionalRecords != _additionalRecords &&
![other->_additionalRecords isEqual: _additionalRecords])
if (response->_additionalRecords != _additionalRecords &&
![response->_additionalRecords isEqual: _additionalRecords])
return false;
return true;
}
- (uint32_t)hash
{
uint32_t hash;
OF_HASH_INIT(hash);
OF_HASH_ADD_HASH(hash, _domainName.hash);
OF_HASH_ADD_HASH(hash, [_answerRecords hash]);
OF_HASH_ADD_HASH(hash, [_authorityRecords hash]);
OF_HASH_ADD_HASH(hash, [_additionalRecords hash]);
OF_HASH_FINALIZE(hash);
return hash;
}
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
+
-
+
+
|
withString: @"\n\t"];
OFString *additionalRecords = [_additionalRecords.description
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
return [OFString stringWithFormat:
@"<%@:\n"
@"\tDomain name = %@\n"
@"\tAnswer records = %@\n"
@"\tAuthority records = %@\n"
@"\tAdditional records = %@\n"
@">",
self.className, answerRecords, authorityRecords, additionalRecords];
self.className, _domainName, answerRecords, authorityRecords,
additionalRecords];
}
@end
|