commit 4fc65393374ed32a9c67c11758b0c5b94ed6f5f5 Author: Damian Johnson <ata...@torproject.org> Date: Wed Aug 7 09:49:25 2013 -0700
Issuing DNS lookups via tor in client usage example Suggestion from Julian to issue DNS lookups via tor. This is based on... http://www.talesofacoldadmin.com/2012/11/13/proxying-dns-with-python.html --- docs/tutorials/to_russia_with_love.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/to_russia_with_love.rst b/docs/tutorials/to_russia_with_love.rst index 5c9883a..97c4da7 100644 --- a/docs/tutorials/to_russia_with_love.rst +++ b/docs/tutorials/to_russia_with_love.rst @@ -20,7 +20,7 @@ Tor makes `configuring your exit locale <https://www.torproject.org/docs/faq.htm In the following example we're using stem to `start Tor <../api/process.html>`_, then reading a site through it with `SocksiPy <http://socksipy.sourceforge.net/>`_. This is not always reliable (some relays are lemons) so you may need to run this more than once. -**Do not rely on the following not to leak.** Though it seems to work, DNS resolution and other edge cases might expose your real IP. If you have a suggestion for how to improve this example then please `let me know <http://www.atagar.com/contact/>`_! +**Do not rely on the following not to leak.** Though it seems to work there may be edge cases that expose your real IP. If you have a suggestion for how to improve this example then please `let me know <http://www.atagar.com/contact/>`_! :: @@ -40,6 +40,13 @@ In the following example we're using stem to `start Tor <../api/process.html>`_, socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT) socket.socket = socks.socksocket + # Perform DNS resolution through the socket + + def getaddrinfo(*args): + return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))] + + socket.getaddrinfo = getaddrinfo + def query(url): """ _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits