2022-02-16 06:49:32 +00:00
|
|
|
import socks
|
|
|
|
|
|
|
|
|
|
|
|
class TorPeer:
|
|
|
|
|
|
|
|
def __init__(self, socks_host, socks_port, onion_address):
|
2022-02-22 20:34:19 +00:00
|
|
|
self.transport_address = self.onion_address = onion_address
|
2022-02-16 06:49:32 +00:00
|
|
|
self.socks_host = socks_host
|
|
|
|
self.socks_port = socks_port
|
|
|
|
|
|
|
|
def get_socket(self) -> socks.socksocket:
|
|
|
|
s = socks.socksocket()
|
2022-02-21 21:15:26 +00:00
|
|
|
s.set_proxy(socks.SOCKS4, self.socks_host, self.socks_port, rdns=True)
|
2022-02-16 06:49:32 +00:00
|
|
|
s.connect((self.onion_address, 80))
|
|
|
|
return s
|