SMHttpDnsCacheManager.h 1.73 KB
//
//  SMHttpDnsCacheManager.h
//  SMHttpDnsProxy
//
//  Created by cairui01 on 16/12/2.
//  Copyright © 2016年 baidu. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, SMDNSCacheIPStack) {
    SMDNSCacheIPStackv4,
    SMDNSCacheIPStackv6
};

// 本地cache时间.单位秒
static const int cacheExpirationSecond = 60;

@interface SMHttpDnsCacheManager : NSObject

@property (atomic, strong, readwrite) NSNumber* cacheExpirSecond;
@property (atomic, readwrite) BOOL isCloudLoad;
@property (atomic, assign) BOOL isAtSpecificArea;
@property (atomic, copy) NSArray *specificHosts;
@property (atomic, copy) NSString *areaInfo;    //  HTTPDNS接口返回的地域.运营商信息,例如: "beijing.cmnet"
@property (atomic, assign) double lastAreaUpdateTimestamp;  //  最近一次AreaInfo更新时间戳, areaInfo为空时为-1

+ (instancetype)sharedInstance;

- (void)setIps:(NSArray*)ips forHost:(NSString*)host ipStack:(SMDNSCacheIPStack)ipStack;

- (id)ipsForHost:(NSString*)host ipStack:(SMDNSCacheIPStack)ipStack;

- (void)setExtIps:(NSArray*)ips forHost:(NSString*)host ipStack:(SMDNSCacheIPStack)ipStack;

- (id)IpCacheForHost:(NSString *)host ipStack:(SMDNSCacheIPStack)ipStack;

- (void)clearMemory;

- (void)setLocalPrefetchSecond;

- (NSNumber*)localPrefetchSecond;

- (id)currentBackupIpForHost:(NSString*)host ipStack:(SMDNSCacheIPStack)ipStack;

- (id)backupIpsForHost:(NSString*)host ipStack:(SMDNSCacheIPStack)ipStack;

- (void)updateBackupIps:(NSDictionary*)ips version:(NSString *)version;

- (NSString *)backupIpsVersion;

- (void)setLocalDnsCache:(NSArray *)ips forHost:(NSString *)host ipStack:(SMDNSCacheIPStack)ipStack;

- (id)localDnsCacheForHost:(NSString *)host ipStack:(SMDNSCacheIPStack)ipStack;

@end