def data_received(self, data):
data = self.get_data(data)
if data is None:
self.transport.close()
return
self.request = DNSRecord.parse(data)
if self.args.debug:
print('Data received: {!r}'.format(self.request))
from IPy import IP
ip = IP(self.peername[0])
client_ip = self.peername[0]
if ip.iptype() == 'PRIVATE':
client_ip = self.args.myip
url = 'https://dns.google.com/resolve?name={}&edns_client_subnet={}/24'.format(str(self.request.q.qname),
client_ip)
# client = ProxyClient()
# google_dns_resp = client.query_domain(url, self.args.proxy)
try:
from asyncio import ensure_future
except ImportError:
from asyncio import async as ensure_future
asyncio.ensure_future(ProxyClient.query_domain(url, self.args.proxy), loop=self.loop).add_done_callback(
functools.partial(self.send_resp))
评论列表
文章目录