mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-14 14:54:49 -04:00
sync evdns changes with tor - from Nick Mathewson
svn:r238
This commit is contained in:
parent
b6b933af5c
commit
fe1dfe0f40
13
evdns.h
13
evdns.h
@ -36,8 +36,11 @@
|
|||||||
#define DNS_ERR_UNKNOWN 66
|
#define DNS_ERR_UNKNOWN 66
|
||||||
/* Communication with the server timed out */
|
/* Communication with the server timed out */
|
||||||
#define DNS_ERR_TIMEOUT 67
|
#define DNS_ERR_TIMEOUT 67
|
||||||
|
/* The request was canceled because the DNS subsystem was shut down. */
|
||||||
|
#define DNS_ERR_SHUTDOWN 68
|
||||||
|
|
||||||
#define DNS_IPv4_A 1
|
#define DNS_IPv4_A 1
|
||||||
|
#define DNS_PTR 2
|
||||||
|
|
||||||
#define DNS_QUERY_NO_SEARCH 1
|
#define DNS_QUERY_NO_SEARCH 1
|
||||||
|
|
||||||
@ -48,13 +51,17 @@
|
|||||||
|
|
||||||
typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
|
typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
|
||||||
|
|
||||||
int evdns_init();
|
int evdns_init(void);
|
||||||
|
void evdns_shutdown(int fail_requests);
|
||||||
|
const char *evdns_err_to_string(int err);
|
||||||
int evdns_nameserver_add(unsigned long int address);
|
int evdns_nameserver_add(unsigned long int address);
|
||||||
int evdns_count_nameservers(void);
|
int evdns_count_nameservers(void);
|
||||||
int evdns_clear_nameservers_and_suspend(void);
|
int evdns_clear_nameservers_and_suspend(void);
|
||||||
int evdns_resume(void);
|
int evdns_resume(void);
|
||||||
int evdns_nameserver_ip_add(const char *ip_as_string);
|
int evdns_nameserver_ip_add(const char *ip_as_string);
|
||||||
int evdns_resolve(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
||||||
|
struct in_addr;
|
||||||
|
int evdns_resolve_reverse(struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
|
||||||
int evdns_resolv_conf_parse(int flags, const char *);
|
int evdns_resolv_conf_parse(int flags, const char *);
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
int evdns_config_windows_nameservers(void);
|
int evdns_config_windows_nameservers(void);
|
||||||
@ -63,7 +70,7 @@ void evdns_search_clear(void);
|
|||||||
void evdns_search_add(const char *domain);
|
void evdns_search_add(const char *domain);
|
||||||
void evdns_search_ndots_set(const int ndots);
|
void evdns_search_ndots_set(const int ndots);
|
||||||
|
|
||||||
typedef void (*evdns_debug_log_fn_type)(const char *msg);
|
typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg);
|
||||||
void evdns_set_log_fn(evdns_debug_log_fn_type fn);
|
void evdns_set_log_fn(evdns_debug_log_fn_type fn);
|
||||||
|
|
||||||
#define DNS_NO_SEARCH 1
|
#define DNS_NO_SEARCH 1
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
@ -71,7 +72,26 @@ void
|
|||||||
dns_gethostbyname()
|
dns_gethostbyname()
|
||||||
{
|
{
|
||||||
fprintf(stdout, "Simple DNS resolve: ");
|
fprintf(stdout, "Simple DNS resolve: ");
|
||||||
evdns_resolve("www.monkey.org", 0, dns_gethostbyname_cb, NULL);
|
dns_ok = 0;
|
||||||
|
evdns_resolve_ipv4("www.monkey.org", 0, dns_gethostbyname_cb, NULL);
|
||||||
|
event_dispatch();
|
||||||
|
|
||||||
|
if (dns_ok) {
|
||||||
|
fprintf(stdout, "OK\n");
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "FAILED\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dns_gethostbyaddr()
|
||||||
|
{
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = htonl(0x7f000001ul); /* 127.0.0.1 */
|
||||||
|
fprintf(stdout, "Simple reverse DNS resolve: ");
|
||||||
|
dns_ok = 0;
|
||||||
|
evdns_resolve_reverse(&in, 0, dns_gethostbyname_cb, NULL);
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
if (dns_ok) {
|
if (dns_ok) {
|
||||||
@ -87,6 +107,7 @@ dns_suite(void)
|
|||||||
{
|
{
|
||||||
evdns_init();
|
evdns_init();
|
||||||
dns_gethostbyname();
|
dns_gethostbyname();
|
||||||
|
dns_gethostbyaddr();
|
||||||
|
|
||||||
evdns_clear_nameservers_and_suspend();
|
evdns_shutdown(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user