diff options
| author | Bob Halley <halley@dnspython.org> | 2005-09-02 05:23:18 +0000 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2005-09-02 05:23:18 +0000 |
| commit | d33a7f336c7637f5f6b86e8be8463e180d5a729f (patch) | |
| tree | 83d7e2cdaf532662ec8851bbe88597c247e0b525 /dns/inet.py | |
| parent | 0865574e6da791d7360dd4a6f9d4267a1b81596d (diff) | |
| download | dnspython-d33a7f336c7637f5f6b86e8be8463e180d5a729f.tar.gz | |
make sending queries via IPv6 work
Original author: Bob Halley <halley@dnspython.org>
Date: 2004-08-04 09:10:14
Diffstat (limited to 'dns/inet.py')
| -rw-r--r-- | dns/inet.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/dns/inet.py b/dns/inet.py index e8e3092..c12dbbf 100644 --- a/dns/inet.py +++ b/dns/inet.py @@ -70,3 +70,21 @@ def inet_ntop(family, address): return dns.ipv6.inet_ntoa(address) else: raise NotImplementedError + +def af_for_address(text): + """Determine the address family of a textual-form network address. + + @param text: the textual address + @type text: string + @raises ValueError: the address family cannot be determined from the input. + @rtype int + """ + try: + junk = dns.ipv4.inet_aton(text) + return AF_INET + except: + try: + junk = dns.ipv6.inet_aton(text) + return AF_INET6 + except: + raise ValueError |
