#NEWLINE# def is_valid_dns( name , dns , **kwargs ) : #NEWLINE# #INDENT# 'Valid the format of DNS.' #NEWLINE# if isinstance ( dns , list ) : #NEWLINE# #INDENT# return all ( [ is_valid_dns ( name , item , ** kwargs ) for item in dns ] ) #NEWLINE# #UNINDENT# if is_valid_ip ( dns ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# socket . gethostbyname_ex ( dns ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# logging . debug ( '%s invalid dns name %s' , name , dns ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True