Commit e0c86efd authored by Denis Bilenko's avatar Denis Bilenko

remove HAS_EVDNS and check for EVENTDNS_H

parent 3fc2fc6b
......@@ -375,7 +375,6 @@ def get_method():
cdef extern from *:
cdef void emit_ifdef "#if defined(_EVENT_VERSION) //" ()
cdef void emit_evdns_ifdef "#if defined(EVENTDNS_H) //" ()
cdef void emit_else "#else //" ()
cdef void emit_endif "#endif //" ()
......
......@@ -54,17 +54,9 @@ DNS_IPv6_AAAA = 3
# Flags
DNS_QUERY_NO_SEARCH = 1
emit_evdns_ifdef()
HAS_EVDNS = 1
emit_else()
HAS_EVDNS = 0
emit_endif()
def dns_init():
emit_evdns_ifdef()
"""Initialize async DNS resolver."""
evdns_init()
emit_endif()
cdef void __evdns_callback(int result, char t, int count, int ttl,
void *addrs, void *arg) with gil:
......@@ -102,11 +94,9 @@ def dns_resolve_ipv4(char *name, int flags, callback, *args):
callback -- callback with (result, type, ttl, addrs, *args) prototype
args -- option callback arguments
"""
emit_evdns_ifdef()
t = (callback, args)
Py_INCREF(t)
evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>t)
emit_endif()
def dns_resolve_ipv6(char *name, int flags, callback, *args):
"""Lookup an AAAA record for a given name.
......@@ -118,11 +108,9 @@ def dns_resolve_ipv6(char *name, int flags, callback, *args):
callback -- callback with (result, type, ttl, addrs, *args) prototype
args -- option callback arguments
"""
emit_evdns_ifdef()
t = (callback, args)
Py_INCREF(t)
evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>t)
emit_endif()
def dns_resolve_reverse(char *ip, int flags, callback, *args):
"""Lookup a PTR record for a given IPv4 address.
......@@ -134,13 +122,11 @@ def dns_resolve_reverse(char *ip, int flags, callback, *args):
callback -- callback with (result, type, ttl, addrs, *args) prototype
args -- option callback arguments
"""
emit_evdns_ifdef()
t = (callback, args)
Py_INCREF(t)
cdef in_addr addr
inet_aton(ip, &addr)
evdns_resolve_reverse(&addr, flags, __evdns_callback, <void *>t)
emit_endif()
def dns_resolve_reverse_ipv6(char *ip, int flags, callback, *args):
"""Lookup a PTR record for a given IPv6 address.
......@@ -152,16 +138,12 @@ def dns_resolve_reverse_ipv6(char *ip, int flags, callback, *args):
callback -- callback with (result, type, ttl, addrs, *args) prototype
args -- option callback arguments
"""
emit_evdns_ifdef()
t = (callback, args)
Py_INCREF(t)
cdef in6_addr addr
inet_pton(AF_INET6, ip, &addr)
evdns_resolve_reverse_ipv6(&addr, flags, __evdns_callback, <void *>t)
emit_endif()
def dns_shutdown(int fail_requests=0):
"""Shutdown the async DNS resolver and terminate all active requests."""
emit_evdns_ifdef()
evdns_shutdown(fail_requests)
emit_endif()
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