mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-04 09:03:42 +00:00
Add c-ares support (#1655)
* Replace udns with c-ares * Get IO loop work * Clean up * Avoid initializing nameservers each query * Add ARES_OPT_SERVERS * Refine resolv_cancel * Fix a memory leak * Replace udns.h with ares.h * Fix all inet_* fucntions * Clean up * Enable servers_ports when VERSION_MINOR >= 11 * Avoid ares_inet_XtoX * Handle multipe nameservers correctly * Use ares_set_servers for IPv4 and IPv6 mixed list * Refine c-ares for udprelay * Refine ares_set_servers() * Refine the timer based on ares_timeout * Avoid resolv_cancel * Fix an issue of null pointer * Fix another null pointer issue * Refine the order of resolv_shutdown * Fix the corrupted ev io
This commit is contained in:
+5
-5
@@ -23,12 +23,12 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <libcork/core.h>
|
||||
#include <udns.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
@@ -97,12 +97,12 @@ bind_to_address(int socket_fd, const char *host)
|
||||
if (cork_ip_init(&ip, host) != -1) {
|
||||
if (ip.version == 4) {
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *)&storage;
|
||||
dns_pton(AF_INET, host, &addr->sin_addr);
|
||||
inet_pton(AF_INET, host, &addr->sin_addr);
|
||||
addr->sin_family = AF_INET;
|
||||
return bind(socket_fd, (struct sockaddr *)addr, sizeof(struct sockaddr_in));
|
||||
} else if (ip.version == 6) {
|
||||
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)&storage;
|
||||
dns_pton(AF_INET6, host, &addr->sin6_addr);
|
||||
inet_pton(AF_INET6, host, &addr->sin6_addr);
|
||||
addr->sin6_family = AF_INET6;
|
||||
return bind(socket_fd, (struct sockaddr *)addr, sizeof(struct sockaddr_in6));
|
||||
}
|
||||
@@ -121,14 +121,14 @@ get_sockaddr(char *host, char *port,
|
||||
if (ip.version == 4) {
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *)storage;
|
||||
addr->sin_family = AF_INET;
|
||||
dns_pton(AF_INET, host, &(addr->sin_addr));
|
||||
inet_pton(AF_INET, host, &(addr->sin_addr));
|
||||
if (port != NULL) {
|
||||
addr->sin_port = htons(atoi(port));
|
||||
}
|
||||
} else if (ip.version == 6) {
|
||||
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)storage;
|
||||
addr->sin6_family = AF_INET6;
|
||||
dns_pton(AF_INET6, host, &(addr->sin6_addr));
|
||||
inet_pton(AF_INET6, host, &(addr->sin6_addr));
|
||||
if (port != NULL) {
|
||||
addr->sin6_port = htons(atoi(port));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user