在我的 Android 设备上成功安装 QPython 和 Orbot 后,我 pip 安装了一个著名的stem库,并尝试通过向控制端口发送 NEWNYM 信号来使用它来更改 Tor 身份。在 PC 上,此代码
from stem.control import Controller
from stem import Signal
with Controller.from_port(port=9051) as ctrl:
ctrl.authenticate()
ctrl.signal(Signal.NEWNYM)
完美运行。但是,在 Android 设备上,QPython 返回错误:TypeError: decode() argument 1 must be string, not None
. 身份验证失败。
我怎样才能克服这个问题?也许,我应该看看 AnroidFacade SL4A API 来与 Tor 交互?
我在诺基亚 3 上运行 Android 7.1。通过在 Orbot 设置中使用 Torrc 自定义配置,将 ControlPort 设置为始终为 9051。
Upd这是一个回溯堆栈:
/data/user/0/org.qpython.qpy/files/bin/qpython-android5.sh "/storage/emulated/0/qpython/scripts/new.py" && exit
d/0/qpython/scripts/new.py" && exit <
Traceback (most recent call last):
File "/storage/emulated/0/qpython/scripts/new.py", line 6, in <module>
ctrl.authenticate()
File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/stem-1.6.0-py2.7.egg/stem/control.py", line 1092, in authenticate
stem.connection.authenticate(self, *args, **kwargs)
File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/stem-1.6.0-py2.7.egg/stem/connection.py", line 530, in authenticate
protocolinfo_response = get_protocolinfo(controller)
File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/stem-1.6.0-py2.7.egg/stem/connection.py", line 1022, in get_protocolinfo
stem.response.convert('PROTOCOLINFO', protocolinfo_response)
File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/stem-1.6.0-py2.7.egg/stem/response/__init__.py", line 124, in convert
message._parse_message(**kwargs)
File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/stem-1.6.0-py2.7.egg/stem/response/protocolinfo.py", line 110, in _parse_message
self.cookie_path = line.pop_mapping(True, True, get_bytes = True)[1].decode(sys.getfilesystemencoding())
TypeError: decode() argument 1 must be string, not None
1|NE1:/ $