<s> from django . http import HttpResponse <EOL> from django . utils . http import http_date <EOL> import dns . resolver <EOL> import json <EOL> import time <EOL> def spit_json ( request , j , expires = <NUM_LIT:0> , raw = False ) : <EOL> if raw : <EOL> body = j <EOL> else : <EOL> body = json . dumps ( j ) <EOL> if '<STR_LIT>' in request . META : <EOL> if '<STR_LIT>' in request . META [ '<STR_LIT>' ] : <EOL> body += '<STR_LIT:\n>' <EOL> response = HttpResponse ( body , content_type = "<STR_LIT:application/json>" ) <EOL> if expires > <NUM_LIT:0> : <EOL> response [ '<STR_LIT>' ] = http_date ( time . time ( ) + expires ) <EOL> return response <EOL> def check_body ( request ) : <EOL> if int ( request . META [ '<STR_LIT>' ] ) > <NUM_LIT> : <EOL> response = HttpResponse ( json . dumps ( { '<STR_LIT:error>' : '<STR_LIT>' } ) , content_type = "<STR_LIT:application/json>" ) <EOL> response . status_code = <NUM_LIT> <EOL> return response <EOL> def dns_check ( name , uuid ) : <EOL> resolver = dns . resolver . Resolver ( ) <EOL> resolver . timeout = <NUM_LIT:3> <EOL> try : <EOL> ns_list = resolver . query ( name , '<STR_LIT>' ) <EOL> except : <EOL> ns_list = [ ] <EOL> if len ( ns_list ) > <NUM_LIT:4> : <EOL> ns_list = ns_list [ <NUM_LIT:0> : <NUM_LIT:4> ] <EOL> servers = [ ] <EOL> for ns in ns_list : <EOL> ns = str ( ns ) <EOL> servers . append ( str ( resolver . query ( ns , '<STR_LIT:A>' ) [ <NUM_LIT:0> ] ) ) <EOL> if servers : <EOL> resolver . nameservers = servers <EOL> parts = name . split ( '<STR_LIT:.>' ) <EOL> while len ( parts ) > <NUM_LIT:1> : <EOL> try : <EOL> print '<STR_LIT:.>' . join ( parts ) <EOL> txt_list = resolver . query ( '<STR_LIT:.>' . join ( parts ) , '<STR_LIT>' ) <EOL> for txt in txt_list : <EOL> if '<STR_LIT>' % uuid in str ( txt ) : <EOL> return True <EOL> except : <EOL> pass <EOL> parts = parts [ <NUM_LIT:1> : ] <EOL> return False </s>
