Reputation: 131
I have to make a DNS request using python 3 over a SOCKS 5 proxy. (consequently NO DNS requests are made from my ip address, the socks5 proxy does it for me and should respond with the according A/AAA records or nothing/something else if it can not resolve it)
I found the following github projects:
rthalley/dnspython: no proxy/socks support
Anorov/PySocks: no ipv6, no possiblity to receive the remote DNS response
I found the following stackoverflow thread: Python - Using socket.gethostbyname through proxy -> It uses pysocks, which has no ipv6 support -> not useable for me
Do you have any idea how to accomplish my task?
Upvotes: 11
Views: 5698
Reputation: 1616
It's surprisingly easy. It works the same way as in curl:
If you need DNS to be resolved client side, use socks5://host:port
syntax
If you need DNS to be resolved on the proxy side, use socks5h://host:port
syntax
Upvotes: 9
Reputation: 1
in the lin 45 of query.py
# Function used to create a socket. Can be overridden if needed in special
# situations.
socket_factory = socket.socket
you can reset the socket_factory value(use PySocks)
Upvotes: 0