[tor-dev] TOR socket for P2P in Python
Martin Neuenhofen
martinneuenhofen at googlemail.com
Thu Aug 11 09:27:36 UTC 2022
Dear Tor Developers,
in my application, a client connects to a server via:
*client_socket = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)client_socket.connect(ip,port)*
I want to replace these two lines to create a client_socket whose IP
address cannot be seen by the server. The application is e-polling.
I looked into
- torpy (too many timeouts),
- socks (requires too much external configuration),
- and I have tor installed (unknown how to use from within python).
I just need a replacement for the two-liner code above.
*The ideal solution:* is device & OS agnostic, portable, uses no
peripherals or configuration (i.e., just one pip package to install), and
works reliably.
Thus, the below torpy solution would have been ideal if it had worked
reliably:
*from torpy import TorClient # pip install torpy*
*class Torsocket:*
* def __init__(self,ip,port): self.mgr1 = TorClient()
self.tor = type(self.mgr1).__enter__(self.mgr1) self.mgr2 =
self.tor.create_circuit(3) self.circuit =
type(self.mgr2).__enter__(self.mgr2) self.mgr3 =
self.circuit.create_stream((ip,port)) self.socket =
type(self.mgr3).__enter__(self.mgr3) def send(self,data):
self.socket.send(data) def recv(self,size): return
self.socket.recv(size) def __del__(self): for bla in
[self.mgr3,self.mgr2,self.mgr1]: type(bla).__exit__(bla, None, None, None)*
It replaces the two-liner from the beginning with the below one-liner
*client_socket = Torsocket(*server_data.server_address)*
My questions/requests:
- Is torpy connected to the real tor network (or is it a little toy twin)?
If it is the real tor network then I will close this issue and open another
one.
- Are practical solutions available to my problem already?, and which of
them works best for user-friendliness?
- Can a pip package for a torsocket be made, as described above? i.e.,
something like torpy, but connecting to the real network?
- Can I offer anything so that the ideal solution would be crafted and
packaged?*
*) If it helps, I could tell a lot about my project and how I believe it is
significant and will be for the greater good of people. It is a fully
implemented 1000LOC LSAG+WOT decentral P2P e-polling program with GUI that
shall return trust and sovereignty into the people's hands. The only
missing bit is a reliable tor connection.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20220811/d63dafb8/attachment-0001.htm>
More information about the tor-dev
mailing list