[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Revert "report more detailed errors and show stacktraces when unsafe logging"
commit 8cc46cf22d0ff4a5707bf836fcc990ebae9762ff
Author: Ximin Luo <infinity0@xxxxxxx>
Date: Sat Oct 19 17:16:14 2013 +0100
Revert "report more detailed errors and show stacktraces when unsafe logging"
This reverts commit c1af35b2e2d57cb8850b1cf345d29065766a9410.
Conflicts:
facilitator/facilitator
---
facilitator/fac.py | 6 ++---
facilitator/facilitator | 61 ++++++++++++++++++++++++++++-------------------
2 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/facilitator/fac.py b/facilitator/fac.py
index 6a670d3..8e37d39 100644
--- a/facilitator/fac.py
+++ b/facilitator/fac.py
@@ -227,7 +227,7 @@ def parse_transaction(line):
if not (pos < len(line)):
break
if skipped == 0:
- raise ValueError("Expected space before key-value pair: %r" % line)
+ raise ValueError("Expected space before key-value pair")
pos, key = get_token(pos, line)
if not (pos < len(line) and line[pos] == '='):
raise ValueError("No '=' found after key")
@@ -278,7 +278,7 @@ def transact(f, command, *params):
f.flush()
line = f.readline()
if not (len(line) > 0 and line[-1] == '\n'):
- raise ValueError("No newline at end of string returned by facilitator: %r" % line)
+ raise ValueError("No newline at end of string returned by facilitator")
return parse_transaction(line[:-1])
def put_reg(facilitator_addr, client_addr, transport, registrant_addr=None):
@@ -343,7 +343,7 @@ def get_reg(facilitator_addr, proxy_addr, proxy_transport_list):
response["relay"] = format_addr(relay)
return response
else:
- raise ValueError("Facilitator response was not \"OK\": %s: %s" % (command, params))
+ raise ValueError("Facilitator response was not \"OK\"")
def put_reg_base64(b64):
"""Attempt to add a registration by running a facilitator-reg program
diff --git a/facilitator/facilitator b/facilitator/facilitator
index 844836a..63272f1 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -7,7 +7,6 @@ import socket
import sys
import threading
import time
-import traceback
from collections import defaultdict
import fac
@@ -254,7 +253,7 @@ class Handler(SocketServer.StreamRequestHandler):
if not line:
break
num_lines += 1
- except socket.error as e:
+ except socket.error, e:
log("socket error after reading %d lines: %s" % (num_lines, str(e)))
break
if not self.handle_line(line):
@@ -265,46 +264,52 @@ class Handler(SocketServer.StreamRequestHandler):
raise ValueError("No newline at end of string returned by readline")
try:
command, params = fac.parse_transaction(line[:-1])
- except ValueError as e:
- return self.error("fac.parse_transaction: %(cause)s", e)
+ except ValueError, e:
+ log("fac.parse_transaction: %s" % e)
+ self.send_error()
+ return False
if command == "GET":
return self.do_GET(params)
elif command == "PUT":
return self.do_PUT(params)
else:
- return self.error(u"unrecognized command: %s" % command)
+ self.send_error()
+ return False
def send_ok(self):
print >> self.wfile, "OK"
- def error(self, msg="", cause=None):
- msg = safe_str(msg % { "cause": cause })
- log(msg)
- if not options.safe_logging:
- log(traceback.format_exc())
- print >>self.wfile, fac.render_transaction("ERROR", ("MSG", msg))
- return False
+ def send_error(self):
+ print >> self.wfile, "ERROR"
# Handle a GET request (got flashproxy poll; need to return a proper client registration)
# Example: GET FROM="3.3.3.3:3333" TRANSPORT="websocket" TRANSPORT="webrtc"
def do_GET(self, params):
proxy_spec = fac.param_first("FROM", params)
if proxy_spec is None:
- return self.error(u"GET missing FROM param")
+ log(u"GET missing FROM param")
+ self.send_error()
+ return False
try:
proxy_addr = fac.parse_addr_spec(proxy_spec, defport=0)
- except ValueError as e:
- return self.error(u"syntax error in proxy address %s: %%(cause)s" % safe_str(repr(proxy_spec)), e)
+ except ValueError, e:
+ log(u"syntax error in proxy address %s: %s" % (safe_str(repr(proxy_spec)), safe_str(repr(str(e)))))
+ self.send_error()
+ return False
transport_list = fac.param_getlist("PROXY_TRANSPORT", params)
if not transport_list:
- return self.error(u"PROXY_TRANSPORT missing FROM param")
+ log(u"PROXY TRANSPORT missing FROM param")
+ self.send_error()
+ return False
try:
client_reg, relay_reg = get_match_for_proxy(proxy_addr, transport_list)
- except Exception as e:
- return self.error(u"error getting match for proxy address %s: %%(cause)s" % safe_str(repr(proxy_spec)), e)
+ except Exception, e:
+ log(u"error getting reg for proxy address %s: %s" % (safe_str(repr(proxy_spec)), safe_str(repr(str(e)))))
+ self.send_error()
+ return False
check_back_in = get_check_back_in_for_proxy(proxy_addr)
@@ -327,7 +332,9 @@ class Handler(SocketServer.StreamRequestHandler):
# Check out if we recognize the transport in this registration request
transport = fac.param_first("TRANSPORT", params)
if transport is None:
- return self.error(u"PUT missing TRANSPORT param")
+ log(u"PUT missing TRANSPORT param")
+ self.send_error()
+ return False
transport = Transport.parse(transport)
# See if we have relays that support this transport
@@ -336,18 +343,24 @@ class Handler(SocketServer.StreamRequestHandler):
client_spec = fac.param_first("CLIENT", params)
if client_spec is None:
- return self.error(u"PUT missing CLIENT param")
+ log(u"PUT missing CLIENT param")
+ self.send_error()
+ return False
try:
reg = Endpoint.parse(client_spec, transport)
except (UnknownTransport, ValueError) as e:
# XXX should we throw a better error message to the client? Is it possible?
- return self.error(u"syntax error in %s: %%(cause)s" % safe_str(repr(client_spec)), e)
+ log(u"syntax error in %s: %s" % (safe_str(repr(client_spec)), safe_str(repr(str(e)))))
+ self.send_error()
+ return False
try:
ok = put_reg(reg)
- except Exception as e:
- return self.error(u"error putting reg %s: %%(cause)s" % safe_str(repr(client_spec)), e)
+ except Exception, e:
+ log(u"error putting reg %s: %s" % (safe_str(repr(client_spec)), safe_str(repr(str(e)))))
+ self.send_error()
+ return False
if ok:
log(u"client %s (transports: %s) (remaining regs: %d/%d)" % (safe_str(unicode(reg)), reg.transport, num_unhandled_regs(), num_regs()))
@@ -499,7 +512,7 @@ obfs2|websocket 1.4.6.1:4123\
log(u"dropping privileges to those of user %s" % options.privdrop_username)
try:
fac.drop_privs(options.privdrop_username)
- except BaseException as e:
+ except BaseException, e:
print >> sys.stderr, "Can't drop privileges:", str(e)
sys.exit(1)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits