def stub_rules_check(data): if len(data) == 5 and view_exist(data['view']) and is_domain( data['domain']) and data['ttl'] > 0 and (len( data['ns']) == 0 or is_domain(data['ns'])) and (len( data['ip']) == 0 or is_ip(data['ip'])): return True return False
def rrset_rules_check(data): if len(data) == 6 and view_exist(data['view']) and is_domain( data['domain']) and is_qtype( data['qtype'] ) and data['ttl'] > 0 and data['weight'] > 0 and is_dns_answer( data['qtype'], data['answer']): return True return False
def dns64_rules_check(data): if len(data) == 3 and view_exist(data['view']) and is_domain( data['domain']) and is_ip(data['ipv6prefix']): return True return False
def forward_rules_check(data): if len(data) == 5 and view_exist(data['view']) and is_domain(data['domain']) and len(data['servergroup']) > 0 and (data['type'] == 'first' or data['type'] == 'only')\ and (data['action'] == 'merge' or data['action'] == 'normal'): return True return False
def forward_server_check(data): if len(data) == 4 and view_exist( data['view']) and len(data['servergroup']) > 0 and is_ip( data['ip']) and data['weight'] < 16 and data['weight'] > 0: return True return False
def view_domain_qtype_check(data): if len(data) == 3 and view_exist(data['view']) and is_domain( data['domain']) and is_qtype(data['qtype']): return True return False
def file_view_check(data): if len(data) == 2 and view_exist(data['view']) and len(data['file']) > 0: return True return False
def view_ip_domain_check(data): if len(data) == 3 and view_exist(data['view']) and is_domain( data['domain']) and is_ip(data['ip']): return True return False
def rrfilter_rules_check(data): if len(data) == 4 and view_exist(data['view']) and is_domain( data['domain']) and is_qtype(data['qtype']) and is_answer( data['qtype'], data['answer']): return True return False
def view_ip_check(data): if len(data) == 2 and view_exist(data['view']) and is_ip(data['ip']): return True return False
def ttl_rules_check(data): if len(data) == 4 and view_exist(data['view']) and is_domain( data['domain']) and data['minttl'] > 0 and data[ 'maxttl'] > 0 and data['maxttl'] > data['minttl']: return True return False
def cache_qtype_check(data): if len(data) == 2 and view_exist(data['view']) and is_qtype(data['qtype']): return True return False
def sortlist_rules_check(data): # 需要判断sortlist数据 if len(data) == 3 and view_exist(data['view']) and is_domain( data['domain']) and len(data['sortlist']) > 0: return True return False
def view_redirect_ip_check(data): if len(data) == 3 and view_exist(data['view']) and is_ip( data['ip']) and data['weight'] < 16 and data['weight'] > 0: return True return False
def view_switch_check(data): if len(data) == 2 and view_exist( data['view']) and (data['switch'] == 'enable' or data['switch'] == 'disable'): return True return False