Browse Source

Refine query interface

pull/1877/head
Max Lv 6 years ago
parent
commit
be795e1985
5 changed files with 6 additions and 19 deletions
  1. 4
      src/resolv.c
  2. 6
      src/resolv.h
  3. 3
      src/server.c
  4. 11
      src/udprelay.c
  5. 1
      src/udprelay.h

4
src/resolv.c

@ -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;
}
/*

6
src/resolv.h

@ -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

3
src/server.c

@ -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;

11
src/udprelay.c

@ -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

1
src/udprelay.h

@ -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;

Loading…
Cancel
Save