【发布时间】:2021-09-20 07:06:24
【问题描述】:
This is the whonix documentation on stream isolation and tor circuits
This is the whonix documentation on interfacing and controlling Tor via sockets
我之前曾尝试使用 python 请求库向 whonix 工作站 VM (read about whonix here) 内的Tor's official link for checking exit node IP information 发出 GET 请求。该请求始终显示相同的 IP 信息,与我运行脚本、关闭它、再次运行它无关。在第一个链接中,作者描述了已经支持的应用程序。如果未列出,用户必须提供支持。
我试图在我自己的脚本中提供支持,方法是使用第一个套接字与特定套接字通信,然后是 stem 库。套接字本身没有任何作用,现在 stem 库在运行时给我错误。
from stem import Signal
from stem.control import Controller
with Controller.from_port(port=9051) as controller:
controller.signal(Signal.NEWNYM)
controller.close()
此代码给出以下运行时错误:
Traceback (most recent call last):
File "/path/to/stem/connection.py", line 1018, in get_protocolinfo
protocolinfo_response = _msg(controller, 'PROTOCOLINFO 1')
File "/path/to/stem/connection.py", line 1036, in _msg
return controller.msg(message)
File "/path/to/stem/control.py", line 658, in msg
raise response
File "/path/to/stem/control.py", line 937, in _reader_loop
control_message = self._socket.recv()
File "/path/to/stem/socket.py", line 464, in recv
return self._recv(lambda s, sf: recv_message(sf))
File "/path/to/stem/socket.py", line 278, in _recv
return handler(my_socket, my_socket_file)
File "/path/to/stem/socket.py", line 464, in <lambda>
return self._recv(lambda s, sf: recv_message(sf))
File "/path/to/stem/socket.py", line 693, in recv_message
raise stem.SocketClosed('Received empty socket content.')
stem.SocketClosed: Received empty socket content.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/path/to/stem/connection.py", line 530, in authenticate
protocolinfo_response = get_protocolinfo(controller)
File "/path/to/stem/connection.py", line 1020, in get_protocolinfo
raise stem.SocketError(exc)
stem.SocketError: Received empty socket content.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "my_program.py", line 103, in <module>
controller.authenticate()
File "/path/to/stem/control.py", line 1100, in authenticate
stem.connection.authenticate(self, *args, **kwargs)
File "/path/to/stem/connection.py", line 534, in authenticate
raise AuthenticationFailure('socket connection failed (%s)' % exc)
stem.connection.AuthenticationFailure: socket connection failed (Received empty socket content.)
如何解决?有没有更好的解决方案来提供我尚未考虑的支持?
【问题讨论】:
标签: python networking tor