mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 11:43:50 +00:00
Refine query interface
This commit is contained in:
+1
-3
@@ -188,7 +188,7 @@ resolv_shutdown(struct ev_loop *loop)
|
||||
ares_library_cleanup();
|
||||
}
|
||||
|
||||
struct resolv_query *
|
||||
void
|
||||
resolv_start(const char *hostname, uint16_t port,
|
||||
void (*client_cb)(struct sockaddr *, void *),
|
||||
void (*free_cb)(void *), void *data)
|
||||
@@ -214,8 +214,6 @@ resolv_start(const char *hostname, uint16_t port,
|
||||
ares_gethostbyname(default_ctx.channel, hostname, AF_INET6, dns_query_v6_cb, query);
|
||||
|
||||
reset_timer();
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+3
-3
@@ -36,9 +36,9 @@
|
||||
struct resolv_query;
|
||||
|
||||
int resolv_init(struct ev_loop *, char *, int);
|
||||
struct resolv_query *resolv_start(const char *hostname, uint16_t port,
|
||||
void (*client_cb)(struct sockaddr *, void *),
|
||||
void (*free_cb)(void *), void *data);
|
||||
void resolv_start(const char *hostname, uint16_t port,
|
||||
void (*client_cb)(struct sockaddr *, void *),
|
||||
void (*free_cb)(void *), void *data);
|
||||
void resolv_shutdown(struct ev_loop *);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -912,8 +912,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
snprintf(query->hostname, 256, "%s", host);
|
||||
|
||||
server->stage = STAGE_RESOLVE;
|
||||
struct resolv_query *q = resolv_start(host, port,
|
||||
resolv_cb, resolv_free_cb, query);
|
||||
resolv_start(host, port, resolv_cb, resolv_free_cb, query);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
+1
-10
@@ -1293,16 +1293,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
query_ctx->remote_ctx = remote_ctx;
|
||||
}
|
||||
|
||||
struct resolv_query *query = resolv_start(host, htons(atoi(port)),
|
||||
resolv_cb, resolv_free_cb, query_ctx);
|
||||
|
||||
if (query == NULL) {
|
||||
ERROR("[udp] unable to create DNS query");
|
||||
close_and_free_query(EV_A_ query_ctx);
|
||||
goto CLEAN_UP;
|
||||
}
|
||||
|
||||
query_ctx->query = query;
|
||||
resolv_start(host, htons(atoi(port)), resolv_cb, resolv_free_cb, query_ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ typedef struct server_ctx {
|
||||
|
||||
#ifdef MODULE_REMOTE
|
||||
typedef struct query_ctx {
|
||||
struct resolv_query *query;
|
||||
struct sockaddr_storage src_addr;
|
||||
buffer_t *buf;
|
||||
int addr_header_len;
|
||||
|
||||
Reference in New Issue
Block a user