[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] undo overzealous factoring - enforce v4/v6 behaviour only applies for registration helpers
commit a2c0980e51ac6fe73b1a6fccea240df493201c4c
Author: Ximin Luo <infinity0@xxxxxxxxxxxxxx>
Date: Tue Jul 8 10:32:32 2014 +0100
undo overzealous factoring - enforce v4/v6 behaviour only applies for registration helpers
---
flashproxy-reg-appspot | 1 +
flashproxy-reg-email | 1 +
flashproxy-reg-http | 1 +
flashproxy/util.py | 11 +++++++----
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/flashproxy-reg-appspot b/flashproxy-reg-appspot
index 42aef97..373ffb2 100755
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@ -91,6 +91,7 @@ flashproxy.keys.add_module_opts(parser)
flashproxy.reg.add_registration_args(parser)
options = parser.parse_args(sys.argv[1:])
+flashproxy.util.enforce_address_family(options.address_family)
remote_addr = options.remote_addr
ensure_M2Crypto()
diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index ddfc9fa..d5a7b26 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -50,6 +50,7 @@ parser.add_argument("-d", "--debug",
action="store_true")
options = parser.parse_args(sys.argv[1:])
+flashproxy.util.enforce_address_family(options.address_family)
ensure_M2Crypto()
diff --git a/flashproxy-reg-http b/flashproxy-reg-http
index 3414802..afb3b5c 100755
--- a/flashproxy-reg-http
+++ b/flashproxy-reg-http
@@ -27,6 +27,7 @@ parser.add_argument("-f", "--facilitator", metavar="URL",
default=DEFAULT_FACILITATOR_URL)
options = parser.parse_args(sys.argv[1:])
+flashproxy.util.enforce_address_family(options.address_family)
body = build_reg(options.remote_addr, options.transport)
try:
diff --git a/flashproxy/util.py b/flashproxy/util.py
index 5df15be..3d9804b 100644
--- a/flashproxy/util.py
+++ b/flashproxy/util.py
@@ -22,13 +22,16 @@ def add_module_opts(parser):
def parse_args(namespace):
options.safe_logging = not namespace.unsafe_logging
options.address_family = namespace.address_family or socket.AF_UNSPEC
- if options.address_family != socket.AF_UNSPEC:
- def getaddrinfo_replacement(host, port, family, *args, **kwargs):
- return _old_socket_getaddrinfo(host, port, options.address_family, *args, **kwargs)
- socket.getaddrinfo = getaddrinfo_replacement
return namespace
parser.parse_args = lambda *a, **kw: parse_args(old_parse(*a, **kw))
+def enforce_address_family(address_family):
+ """Force all future name lookups to use the given address family."""
+ if address_family != socket.AF_UNSPEC:
+ def getaddrinfo_replacement(host, port, family, *args, **kwargs):
+ return _old_socket_getaddrinfo(host, port, options.address_family, *args, **kwargs)
+ socket.getaddrinfo = getaddrinfo_replacement
+
def safe_str(s):
"""Return "[scrubbed]" if options.safe_logging is true, and s otherwise."""
if options.safe_logging:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits