Commit bd5d9567 authored by anonym's avatar anonym

tor-controlport-filter: move method definition.

The other helpers for handle_controlport_session() are defined inside
the its scope, so why not this one?
parent 0ed20ccb
......@@ -99,16 +99,6 @@ def log(msg):
sys.stderr.flush()
def rewrite_args_in_line(pattern, replacement, line):
# We also want to match the command in `line`...
pattern = r'^(\S+)\s+' + pattern
replacement = "{} " + replacement
match = re.match(pattern + "$", line)
if not match: return None
# ... and add it back to the replacement string.
return replacement.format(*match.groups())
def pid_of_laddr(address):
try:
return next(conn for conn in psutil.net_connections() \
......@@ -177,6 +167,15 @@ def handle_controlport_session(controller, readh, writeh, allowed_commands, allo
log("Command filtered: {}".format(line))
respond("510 Command filtered")
def rewrite_args_in_line(pattern, replacement, line):
# We also want to match the command in `line`...
pattern = r'^(\S+)\s+' + pattern
replacement = "{} " + replacement
match = re.match(pattern + "$", line)
if not match: return None
# ... and add it back to the replacement string.
return replacement.format(*match.groups())
def event_cb(event):
if restrict_stream_events and \
isinstance(event, stem.response.events.StreamEvent) and \
......
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