-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
148 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
#Changelog | ||
|
||
## 0.1.1 (2015-07-16) | ||
|
||
### 增加 | ||
* localdns 劫持检测 | ||
|
||
|
||
## 0.1.0 (2015-07-15) | ||
|
||
### 增加 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// QNHijackingDetectWrapper.h | ||
// HappyDNS | ||
// | ||
// Created by bailong on 15/7/16. | ||
// Copyright (c) 2015年 Qiniu Cloud Storage. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "QNResolverDelegate.h" | ||
|
||
@class QNResolver; | ||
@interface QNHijackingDetectWrapper : NSObject <QNResolverDelegate> | ||
- (NSArray *)query:(QNDomain *)domain networkInfo:(QNNetworkInfo *)netInfo error:(NSError *__autoreleasing *)error; | ||
- (instancetype)initWithResolver:(QNResolver *)resolver; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// QNHijackingDetectWrapper.m | ||
// HappyDNS | ||
// | ||
// Created by bailong on 15/7/16. | ||
// Copyright (c) 2015年 Qiniu Cloud Storage. All rights reserved. | ||
// | ||
|
||
#import "QNHijackingDetectWrapper.h" | ||
#import "QNResolver.h" | ||
#import "QNDomain.h" | ||
#import "QNRecord.h" | ||
|
||
@interface QNHijackingDetectWrapper () | ||
@property (nonatomic, readonly) QNResolver* resolver; | ||
@end | ||
|
||
@implementation QNHijackingDetectWrapper | ||
|
||
- (NSArray *)query:(QNDomain *)domain networkInfo:(QNNetworkInfo *)netInfo error:(NSError *__autoreleasing *)error { | ||
NSArray *result = [_resolver query:domain networkInfo:netInfo error:error]; | ||
if (((!domain.hasCname) && domain.maxTtl == 0) || result == nil || result.count == 0) { | ||
return result; | ||
} | ||
BOOL hasCname = NO; | ||
BOOL outOfTtl = NO; | ||
for (int i = 0; i<result.count; i++) { | ||
QNRecord* record = [result objectAtIndex:i]; | ||
if (record.type == kQNTypeCname) { | ||
hasCname = YES; | ||
} | ||
if (domain.maxTtl > 0 && record.type ==kQNTypeA && record.ttl>domain.maxTtl) { | ||
outOfTtl = YES; | ||
} | ||
} | ||
if ((domain.hasCname && !hasCname) || outOfTtl) { | ||
if (error != nil) { | ||
*error = [[NSError alloc] initWithDomain:domain.domain code:kQNDomainHijackingCode userInfo:nil]; | ||
} | ||
return nil; | ||
} | ||
return result; | ||
} | ||
- (instancetype)initWithResolver:(QNResolver *)resolver { | ||
if (self = [super init]) { | ||
_resolver = resolver; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.