Commit 585470d1 authored by anonym's avatar anonym
Browse files

tor-controlport-filter: remove unhelpful comments and linebreaks.

parent 5f309e18
...@@ -217,18 +217,13 @@ def handle_controlport_session(controller, readh, writeh, allowed_commands, allo ...@@ -217,18 +217,13 @@ def handle_controlport_session(controller, readh, writeh, allowed_commands, allo
subscribed_event_listeners = [] subscribed_event_listeners = []
client_streams = set() client_streams = set()
while True: while True:
line = str(readh.readline(MAX_LINESIZE), 'ascii').strip() line = str(readh.readline(MAX_LINESIZE), 'ascii').strip()
if not line: break if not line: break
debug_log_recv(line) debug_log_recv(line)
# This regex makes us split on unquoted whitespaces. # This regex makes us split on unquoted whitespaces.
cmd, *args = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', line) cmd, *args = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', line)
cmd = cmd.upper() cmd = cmd.upper()
# Check what it is
if cmd == "PROTOCOLINFO": if cmd == "PROTOCOLINFO":
# Stem call PROTOCOLINFO before authenticating. Tell the # Stem call PROTOCOLINFO before authenticating. Tell the
# client that there is no authentication. # client that there is no authentication.
...@@ -306,16 +301,12 @@ class FilteredControlPortProxyHandler(socketserver.StreamRequestHandler): ...@@ -306,16 +301,12 @@ class FilteredControlPortProxyHandler(socketserver.StreamRequestHandler):
self.filters += filters self.filters += filters
def connect_to_real_control_port(self): def connect_to_real_control_port(self):
# Read authentication cookie
with open(global_args.control_cookie_path, "rb") as f: with open(global_args.control_cookie_path, "rb") as f:
cookie = f.read(32) cookie = f.read(32)
# Connect to the real control port
controller = stem.control.Controller.from_socket_file( controller = stem.control.Controller.from_socket_file(
global_args.control_socket_path global_args.control_socket_path
) )
controller.authenticate(cookie) controller.authenticate(cookie)
return controller return controller
def handle(self): def handle(self):
......
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