question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config.socks_endpoint fails when having multiple endpoints

See original GitHub issue

Hi,

I have been running some simple examples for performing http requests with txtorcon and treq. Even a simple script has errors:

from twisted.internet.task import react
from twisted.internet.defer import ensureDeferred
from twisted.internet.endpoints import TCP4ClientEndpoint

import treq
import txtorcon
async def main(reactor):
    tor = await txtorcon.connect(
        reactor,
        control_endpoint=TCP4ClientEndpoint(reactor, '127.0.0.1', 9051),
        password_function=lambda: 'mypass',
    )

    state = await tor.create_state()
    circ = await state.build_circuit()
    await circ.when_built()
    print('  path: {}'.format(' -> '.join([r.ip for r in circ.path])))
    config = await tor.get_config()
    resp = await treq.get(
        'http://httpbin.org/ip',
        agent=circ.web_agent(reactor, config.socks_endpoint(reactor)),
        timeout=3,
    )
    data = await resp.text()
    print(data)
    out = await state.close_circuit(circ)


@react
def _main(reactor):
    return ensureDeferred(main(reactor))

But I get a builtins.AttributeError: 'list' object has no attribute 'startswith' error.

I have noticed that the issue is because of the config.socks_endpoint(reactor). When calling that method, I have self.SocksPort = _ListWrapper[['unix:/run/tor/socks WorldWritable', '9050']], which is a list of list. Then, when that method is calling the _endpoint_from_socksport_line things get even worst, as we are passing a list instead of a socket endpoint.

I have tor service listening on port 9050 (and 9051 for control), and also in unix socket /run/tor/socks (and /run/tor/control for control).

A super ugly and nonsense patch to fix it is just to go to _endpoint_from_socksport_line method and force the socks_config argument (which is a list) to get the second value (which is ‘9050’). If I try the first value (which is ‘unix:/run/tor/socks WorldWritable’), I will get an error too.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
javiermatoscommented, Jun 17, 2020

I have installed latest Tor from their official repository. My OS is Ubuntu 20.04 LTS.

https://2019.www.torproject.org/docs/debian.html.en

Latest Tor version there is 0.4.3.5-1~focal+1 (amd64)

0reactions
meejahcommented, Jun 17, 2020

So, I think the value should be _ListWrapper['unix:... WorldWritable', '9050'] … that is, a single list with two strings (what you’ve got looks like a single list with a single entry: another list).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve the "Network Error communicating with endpoint ...
Resolve low-frequency network errors. Use retries with exponential backoff for failed requests. To activate access logging, see setting up ...
Read more >
Configure device proxy and Internet connection settings
Configure the Microsoft Defender for Endpoint proxy and internet settings to enable communication with the cloud service.
Read more >
support multiple endpoints · Issue #62 · quarkiverse/quarkus-cxf
hi all, when i try to use multiple endpoints: application.properties: quarkus.cxf.path=/ws quarkus.cxf.endpoint.
Read more >
Use a SOCKS5 Proxy to Access the Kubernetes API
This page shows how to use a SOCKS5 proxy to access the API of a remote Kubernetes cluster. This is useful when the...
Read more >
Configuring Envoy as an edge proxy
Envoy is a production-ready edge proxy, however, the default settings are ... that gRPC requests will still be rejected with the INTERNAL (13)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found