[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Add a simple function to guess an address family.



commit 23e1a91fecbda15ec0c01c50e10480b26f752205
Author: David Fifield <david@xxxxxxxxxxxxxxx>
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)."""



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits