0

Simply trying to access en.wikipedia.org with a python script where a huge stack of dependencies prevents configuring a proxy (would take a year in order to rewrite dependencies for getting proxy support especially since some of the dependencies like https://pypi.org/project/websocket-client/ or https://pypi.org/project/aiohttp/ don’t support socks proxies).

So I thought I could use torsocks/torify but :

1652642569 ERROR torsocks[327]: [socks5] Resolve destination buffer too small (in socks5_recv_resolve_reply() at socks5.c:701)
2022-05-15 21:22:49,723 - BatchWorkExecutor [ERROR] - An exception occurred while executing work_handler.
Traceback (most recent call last):
  File "/usr/lib/pypy3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/pypy3.9/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib64/pypy3.9/socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
_socket.gaierror: [Errno -4] Non-recoverable failure in name resolution

This means an ɪᴘv6 address is being attempted to be written in the space for an ɪᴘv4 address and can be reproduced with curl :

$ torify curl https://rpc.ethermine.org
1653212429 ERROR torsocks[599]: [socks5] Resolve destination buffer too small (in socks5_recv_resolve_reply() at socks5.c:701)
curl: (6) Could not resolve host: rpc.ethermine.org

How to prevent torsocks from receiving an ɪᴘv6 address on name resolution ? Is it possible to configure tor to not only disable ɪᴘv6 connectivity, but ɪᴘv6 name resolution too ?

1 Answer 1

0

If you only want to use torsocks with python then you can use the python-requests library, first of all, start the tor service in your background. Then use this sort of script -:

import requests

session = requests.session()
session.proxies = {"http": "socks5h://localhost:9050", "https": "socks5h://localhost:9050"}
url = "https://en.wikipedia.org"
response = session.get(url)

And this code will help you to achieve what you want. I guess this is all what you need for now!

4
  • Wrong answer ! I wrote with a python script where a huge stack of dependencies prevents configuring a proxy (would take a year in order to rewrite dependencies for getting proxy support). which means this is the dependencies which perform the various ʜᴛᴛᴘ calls directly. It can’t be changed without extensive work which would be cleared at each update. May 20, 2022 at 8:18
  • TBH I still didn't understand what you are trying to do? What is your final goal to achieve? May 20, 2022 at 17:12
  • I’m using a project which uses things like the web3py pip packages as well as several WebSockets which don’t support proxying and thus tor. Proxy support can’t be added to the code without involving a huge amount of work which would take nearly a year. Thus torsocks is required for wrapping connections to ᴛᴏʀ, but it doesn’t support resvolving domain names where ɪᴘv6 is available. May 20, 2022 at 17:19
  • And pypi.org/project/websocket-client is one of the components out of many you won’t be able to configure with tor. May 22, 2022 at 10:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .