torpyorg / torpy

Pure python Tor client implementation
Apache License 2.0
411 stars 53 forks source link

How to connect to socket server with TorPy? #21

Closed RealKevinApetrei closed 3 years ago

RealKevinApetrei commented 3 years ago

How do I connect to a socket server with TorPy also being able to send and receive data as you would when normally working with socket?

jbrown299 commented 3 years ago

You can find examples in tests https://github.com/torpyorg/torpy/blob/master/tests/integration/test_integration.py. As simple as:

with TorClient() as tor:
    with tor.create_circuit(3) as circuit:
        with circuit.create_stream((HOSTNAME, PORT)) as stream:
            stream.send(b'...')
            data = stream.recv(1024)
ProtDos commented 1 year ago

Hey, is there any update? For me it doesn't work. Can anyone help connecting to a socket server?

ProtDos commented 1 year ago

You can find examples in tests https://github.com/torpyorg/torpy/blob/master/tests/integration/test_integration.py. As simple as:

with TorClient() as tor:
    with tor.create_circuit(3) as circuit:
        with circuit.create_stream((HOSTNAME, PORT)) as stream:
            stream.send(b'...')
            data = stream.recv(1024)

Does that work with socket.socket(**etc)? Because for me it doesn't.