Commit f74cec4d authored by anonym's avatar anonym

onion-grater: retry connecting to the real control port.

This should not be necessary and is just placed here as a workaround
until I can figure out the real issue (bug in onion-grater? bug in
stem?).

When working on the Tor Browser 9.0 migration there were issues with
Tor Launcher. It starts and does its initial connection to the control
port where it successfully fetches CONFs etc. When clicking "Connect"
it successfully sends a few more things and disconnects, only to
reconnect immediately later (due to some implementation detail in Tor
Launcher). This reconnection fails:

    [...]
    /usr/local/lib/tor-browser/firefox-unconfined (pid: 8865, user: tor-launcher, port: 57472, filter: tor-launcher): -> SAVECONF
    /usr/local/lib/tor-browser/firefox-unconfined (pid: 8865, user: tor-launcher, port: 57472, filter: tor-launcher) disconnected: Client closed its socket
    [ Here comes the reconnect: ]
    /usr/local/lib/tor-browser/firefox-unconfined (pid: 8865, user: tor-launcher, port: 57476, filter: tor-launcher) connected: loaded filter: tor-launcher
    Final rules: [...]
    Unable to connect to tor. Maybe it's running without a ControlPort?
    /usr/local/lib/tor-browser/firefox-unconfined (pid: 8865, user: tor-launcher, port: 57476, filter: tor-launcher) disconnected: client quit
    ----------------------------------------
    Exception happened during processing of request from ('127.0.0.1', 57476)
    Traceback (most recent call last):
      File "/usr/lib/python3.5/socketserver.py", line 625, in process_request_thread
        self.finish_request(request, client_address)
      File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
        self.handle()
      File "/usr/local/lib/onion-grater", line 629, in handle
        self.controller = self.connect_to_real_control_port()
      File "/usr/local/lib/onion-grater", line 570, in connect_to_real_control_port
        stem.connection.authenticate_cookie(controller, cookie_path=global_args.control_cookie_path)
      File "/usr/lib/python3/dist-packages/stem/connection.py", line 803, in authenticate_cookie
        auth_response = _msg(controller, msg)
      File "/usr/lib/python3/dist-packages/stem/connection.py", line 1055, in _msg
        return controller.msg(message)
    AttributeError: 'NoneType' object has no attribute 'msg'
    ----------------------------------------

But if we just connect yet again, it works, hence the workaround.

Refs: #16356, #15709
parent 74a55d42
......@@ -566,7 +566,9 @@ class FilteredControlPortProxyHandler(socketserver.StreamRequestHandler):
))
def connect_to_real_control_port(self):
controller = stem.connection.connect(control_socket=global_args.control_socket_path)
controller = None
while not controller:
controller = stem.connection.connect(control_socket=global_args.control_socket_path)
stem.connection.authenticate_cookie(controller, cookie_path=global_args.control_cookie_path)
return controller
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment