mirror of https://github.com/getdnsapi/getdns.git
Minor fixes to make it compile on Windows again
This commit is contained in:
parent
258e59242b
commit
57e2a18f94
15
src/server.c
15
src/server.c
|
@ -26,7 +26,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifndef USE_WINSOCK
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#else
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <iphlpapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "getdns/getdns_extra.h"
|
#include "getdns/getdns_extra.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "types-internal.h"
|
#include "types-internal.h"
|
||||||
|
@ -269,7 +276,7 @@ getdns_reply(
|
||||||
else if (conn->l->transport == GETDNS_TRANSPORT_UDP) {
|
else if (conn->l->transport == GETDNS_TRANSPORT_UDP) {
|
||||||
listener *l = conn->l;
|
listener *l = conn->l;
|
||||||
|
|
||||||
if (conn->l->fd >= 0 && sendto(conn->l->fd, buf, len, 0,
|
if (conn->l->fd >= 0 && sendto(conn->l->fd, (void *)buf, len, 0,
|
||||||
(struct sockaddr *)&conn->remote_in, conn->addrlen) == -1) {
|
(struct sockaddr *)&conn->remote_in, conn->addrlen) == -1) {
|
||||||
/* IO error, cleanup this listener */
|
/* IO error, cleanup this listener */
|
||||||
loop->vmt->clear(loop, &conn->l->event);
|
loop->vmt->clear(loop, &conn->l->event);
|
||||||
|
@ -532,7 +539,7 @@ static void udp_read_cb(void *userarg)
|
||||||
|
|
||||||
conn->l = l;
|
conn->l = l;
|
||||||
conn->addrlen = sizeof(conn->remote_in);
|
conn->addrlen = sizeof(conn->remote_in);
|
||||||
if ((len = recvfrom(l->fd, buf, sizeof(buf), 0,
|
if ((len = recvfrom(l->fd, (void *)buf, sizeof(buf), 0,
|
||||||
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
|
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
|
||||||
/* IO error, cleanup this listener. */
|
/* IO error, cleanup this listener. */
|
||||||
loop->vmt->clear(loop, &l->event);
|
loop->vmt->clear(loop, &l->event);
|
||||||
|
@ -704,7 +711,11 @@ static void remove_listeners(listen_set *set)
|
||||||
|
|
||||||
static getdns_return_t add_listeners(listen_set *set)
|
static getdns_return_t add_listeners(listen_set *set)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
static const char enable = 1;
|
||||||
|
#else
|
||||||
static const int enable = 1;
|
static const int enable = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct mem_funcs *mf;
|
struct mem_funcs *mf;
|
||||||
getdns_eventloop *loop;
|
getdns_eventloop *loop;
|
||||||
|
|
|
@ -55,7 +55,9 @@ static const char *default_stubby_config =
|
||||||
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
||||||
"}";
|
"}";
|
||||||
static int clear_listen_list_on_arg = 0;
|
static int clear_listen_list_on_arg = 0;
|
||||||
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
static int run_in_foreground = 1;
|
static int run_in_foreground = 1;
|
||||||
|
#endif
|
||||||
static int quiet = 0;
|
static int quiet = 0;
|
||||||
static int batch_mode = 0;
|
static int batch_mode = 0;
|
||||||
static char *query_file = NULL;
|
static char *query_file = NULL;
|
||||||
|
@ -209,8 +211,10 @@ print_usage(FILE *out, const char *progname)
|
||||||
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
||||||
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
||||||
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
||||||
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
if (i_am_stubby)
|
if (i_am_stubby)
|
||||||
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
||||||
|
#endif
|
||||||
fprintf(out, "\t-G\tgeneral lookup\n");
|
fprintf(out, "\t-G\tgeneral lookup\n");
|
||||||
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
||||||
fprintf(out, "\t-h\tPrint this help\n");
|
fprintf(out, "\t-h\tPrint this help\n");
|
||||||
|
@ -995,10 +999,12 @@ getdns_return_t parse_args(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
if (i_am_stubby && *c == 'g') {
|
if (i_am_stubby && *c == 'g') {
|
||||||
run_in_foreground = 0;
|
run_in_foreground = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
fprintf(stderr, "Unknown option "
|
fprintf(stderr, "Unknown option "
|
||||||
"\"%c\"\n", *c);
|
"\"%c\"\n", *c);
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
|
@ -1608,7 +1614,8 @@ main(int argc, char **argv)
|
||||||
prg_name = prg_name ? prg_name + 1 : argv[0];
|
prg_name = prg_name ? prg_name + 1 : argv[0];
|
||||||
|
|
||||||
i_am_stubby = strcasecmp(prg_name, "stubby") == 0
|
i_am_stubby = strcasecmp(prg_name, "stubby") == 0
|
||||||
|| strcasecmp(prg_name, "lt-stubby") == 0;
|
|| strcasecmp(prg_name, "lt-stubby") == 0
|
||||||
|
|| strcasecmp(prg_name, "stubby.exe") == 0;
|
||||||
|
|
||||||
name = the_root;
|
name = the_root;
|
||||||
if ((r = getdns_context_create(&context, 1))) {
|
if ((r = getdns_context_create(&context, 1))) {
|
||||||
|
@ -1675,6 +1682,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else if (listen_count) {
|
else if (listen_count) {
|
||||||
assert(loop);
|
assert(loop);
|
||||||
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
if (i_am_stubby && !run_in_foreground) {
|
if (i_am_stubby && !run_in_foreground) {
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
|
@ -1693,6 +1701,7 @@ main(int argc, char **argv)
|
||||||
} else
|
} else
|
||||||
loop->vmt->run(loop);
|
loop->vmt->run(loop);
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
loop->vmt->run(loop);
|
loop->vmt->run(loop);
|
||||||
} else
|
} else
|
||||||
r = do_the_call();
|
r = do_the_call();
|
||||||
|
|
Loading…
Reference in New Issue