Commit 4519a83c authored by Denis Bilenko's avatar Denis Bilenko

evdns: drop dns_ prefix from function names

parent 1da2c497
......@@ -2,14 +2,14 @@
This module contains synchronous wrappers around some of the libevent DNS API.
>>> dns_resolve_ipv4('www.python.org')
>>> resolve_ipv4('www.python.org')
['82.94.164.162']
>>> dns_resolve_reverse('82.94.164.162').endswith('python.org')
>>> resolve_reverse('82.94.164.162').endswith('python.org')
True
The errors are reported through a subclass of :class:`socket.gaierror`.
>>> dns_resolve_ipv4('aaaaaaaaaaa')
>>> resolve_ipv4('aaaaaaaaaaa')
Traceback (most recent call last):
...
DNSError: [Errno 3] name does not exist
......@@ -22,10 +22,10 @@ from gevent.core import DNS_QUERY_NO_SEARCH as QUERY_NO_SEARCH
__all__ = ['DNSError',
'dns_resolve_ipv4',
'dns_resolve_ipv6',
'dns_resolve_reverse',
'dns_resolve_reverse_ipv6',
'resolve_ipv4',
'resolve_ipv6',
'resolve_reverse',
'resolve_reverse_ipv6',
'QUERY_NO_SEARCH']
......@@ -47,7 +47,7 @@ class DNSError(gaierror):
gaierror.__init__(self, *args)
def dns_resolve_ipv4(name, flags=0):
def resolve_ipv4(name, flags=0):
waiter = Waiter()
core.dns_resolve_ipv4(name, flags, waiter.switch_args)
result, _type, _ttl, addrs = waiter.get()
......@@ -57,7 +57,7 @@ def dns_resolve_ipv4(name, flags=0):
# QQQ would be nice to have ttl as an attribute
def dns_resolve_ipv6(name, flags=0):
def resolve_ipv6(name, flags=0):
waiter = Waiter()
core.dns_resolve_ipv6(name, flags, waiter.switch_args)
result, _type, _ttl, addrs = waiter.get()
......@@ -66,7 +66,7 @@ def dns_resolve_ipv6(name, flags=0):
return addrs
def dns_resolve_reverse(ip, flags=0):
def resolve_reverse(ip, flags=0):
waiter = Waiter()
core.dns_resolve_reverse(ip, flags, waiter.switch_args)
result, _type, _ttl, addr = waiter.get()
......@@ -75,7 +75,7 @@ def dns_resolve_reverse(ip, flags=0):
return addr
def dns_resolve_reverse_ipv6(ip, flags=0):
def resolve_reverse_ipv6(ip, flags=0):
waiter = Waiter()
core.dns_resolve_reverse_ipv6(ip, flags, waiter.switch_args)
result, _type, _ttl, addrs = waiter.get()
......
......@@ -681,7 +681,7 @@ def wrap_ssl000(sock, keyfile=None, certfile=None):
return ssl_sock
try:
from gevent.evdns import dns_resolve_ipv4, dns_resolve_ipv6
from gevent.evdns import resolve_ipv4, resolve_ipv6
except:
import traceback
traceback.print_exc()
......@@ -709,7 +709,7 @@ else:
return hostname
if hostname == _socket.gethostname():
return _socket.gethostbyname(hostname)
addrs = dns_resolve_ipv4(hostname)
addrs = resolve_ipv4(hostname)
return random.choice(addrs)
......@@ -719,7 +719,7 @@ else:
If *host* is not a string, does not has any dots or is a numeric IP address, then
the standard :func:`socket.getaddrinfo` is called.
Otherwise, calls either :func:`dns_resolve_ipv4` or :func:`dns_resolve_ipv6` and
Otherwise, calls either :func:`resolve_ipv4` or :func:`resolve_ipv6` and
formats the result the way :func:`socket.getaddrinfo` does it.
Differs in the following ways:
......@@ -746,9 +746,9 @@ else:
if family in (None, AF_INET, AF_UNSPEC):
family = AF_INET
# TODO: AF_UNSPEC means try both AF_INET and AF_INET6
addrs = dns_resolve_ipv4(host, evdns_flags)
addrs = resolve_ipv4(host, evdns_flags)
elif family == AF_INET6:
addrs = dns_resolve_ipv6(host, evdns_flags)
addrs = resolve_ipv6(host, evdns_flags)
else:
raise NotImplementedError('family is not among AF_UNSPEC/AF_INET/AF_INET6: %r' % (family, ))
r = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment