Differences From Artifact [944dbcc660]:
- File src/OFDNSResponse.m — part of check-in [6b2fb27dca] at 2019-10-01 00:40:48 on branch trunk — Add OFDNSRequest (user: js, size: 3409) [annotate] [blame] [check-ins using]
To Artifact [e97f58bfa9]:
- File
src/OFDNSResponse.m
— part of check-in
[ee592cf603]
at
2019-10-07 00:07:55
on branch trunk
— OFDNSResolver: Major refactor
This temporarily doesn't use the search domains anymore and makes CNAMEs
slightly more inefficient. The next commits will fix both. (user: js, size: 3831) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | #include "config.h" #import "OFDNSResponse.h" #import "OFDictionary.h" #import "OFString.h" @implementation OFDNSResponse | | > | | | > | | | | | | | > > | | > > > | | | | | | > | 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 domainName = _domainName, answerRecords = _answerRecords;
@synthesize authorityRecords = _authorityRecords;
@synthesize additionalRecords = _additionalRecords;
+ (instancetype)
responseWithDomainName: (OFString *)domainName
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
answerRecords: answerRecords
authorityRecords: authorityRecords
additionalRecords: additionalRecords] autorelease];
}
- (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 *response;
if (![object isKindOfClass: [OFDNSResponse class]])
return false;
response = object;
if (response->_domainName != _domainName &&
![response->_domainName isEqual: _domainName])
return false;
if (response->_answerRecords != _answerRecords &&
![response->_answerRecords isEqual: _answerRecords])
return false;
if (response->_authorityRecords != _authorityRecords &&
![response->_authorityRecords isEqual: _authorityRecords])
return false;
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 | withString: @"\n\t"]; OFString *additionalRecords = [_additionalRecords.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; return [OFString stringWithFormat: @"<%@:\n" @"\tAnswer records = %@\n" @"\tAuthority records = %@\n" @"\tAdditional records = %@\n" @">", | > | > | 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, _domainName, answerRecords, authorityRecords, additionalRecords]; } @end |