[tor-commits] [flashproxy/master] Add a simple function to guess an address family.
dcf at torproject.org
dcf at torproject.org
Sun Dec 23 09:11:59 UTC 2012
commit 23e1a91fecbda15ec0c01c50e10480b26f752205
Author: David Fifield <david at bamsoftware.com>
Date: Wed Dec 19 19:26:30 2012 -0800
Add a simple function to guess an address family.
---
facilitator/facilitator | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/facilitator/facilitator b/facilitator/facilitator
index a0538d2..916271c 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -313,6 +313,12 @@ def regs_for_af(af):
else:
raise ValueError("unknown address family %d" % af)
+def addr_af(addr_str):
+ """Return the address family for an address string. This is a plain string,
+ not a tuple, and IPv6 addresses are not bracketed."""
+ addrs = socket.getaddrinfo(addr_str, 0, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP, socket.AI_NUMERICHOST)
+ return addrs[0][0]
+
def get_reg_for_proxy(proxy_addr):
"""Get a client registration appropriate for the given proxy (one of a
matching address family)."""
More information about the tor-commits
mailing list