diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..bd10178 --- /dev/null +++ b/CHANGES @@ -0,0 +1,8 @@ +1.0.2 2014-07-29 +- Support -s hostname:port + +1.0.1 2014-07-28 +- Use autotools + +1.0.0 2014-07-25 +- Initial version diff --git a/configure.ac b/configure.ac index 1d56f36..e03184f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.67]) -AC_INIT([ChinaDNS-C], [1.0.1], [clowwindy42@gmail.com]) +AC_INIT([ChinaDNS-C], [1.0.2], [clowwindy42@gmail.com]) AC_CONFIG_SRCDIR([src/chinadns.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/openwrt/Makefile b/openwrt/Makefile index dadc92a..55c6c65 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ChinaDNS-C -PKG_VERSION:=1.0.1 +PKG_VERSION:=1.0.2 PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_SOURCE_URL:=https://github.com/clowwindy/ChinaDNS-C/releases/download/$(PKG_VERSION) diff --git a/src/chinadns.c b/src/chinadns.c index 8b8792c..89ad139 100644 --- a/src/chinadns.c +++ b/src/chinadns.c @@ -254,7 +254,17 @@ static int resolve_dns_servers() { hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */ token = strtok(dns_servers, ","); while (token) { - if (0 != (r = getaddrinfo(token, "53", &hints, &addr_ip))) { + char *port; + memset(global_buf, 0, BUF_SIZE); + strncpy(global_buf, token, BUF_SIZE - 1); + port = (strrchr(global_buf, ':')); + if (port) { + *port = '\0'; + port++; + } else { + port = "53"; + } + if (0 != (r = getaddrinfo(global_buf, port, &hints, &addr_ip))) { VERR("%s:%s\n", gai_strerror(r), token); return -1; } @@ -351,7 +361,7 @@ static void dns_handle_local() { // TODO generate id for each request to avoid conflicts query_id = ns_msg_id(msg); question_hostname = hostname_from_question(msg); - LOG("request: %s\n", question_hostname); + LOG("request %s\n", question_hostname); id_addr_t id_addr; id_addr.id = query_id; id_addr.addr = src_addr; @@ -388,8 +398,9 @@ static void dns_handle_remote() { id_addr_t *id_addr = queue_lookup(query_id); id_addr->addr->sa_family = AF_INET; question_hostname = hostname_from_question(msg); - LOG("response %s from %s: ", question_hostname, - inet_ntoa(((struct sockaddr_in *)src_addr)->sin_addr)); + LOG("response %s from %s:%d - ", question_hostname, + inet_ntoa(((struct sockaddr_in *)src_addr)->sin_addr), + htons(((struct sockaddr_in *)src_addr)->sin_port)); free(src_addr); if (id_addr) { r = should_filter_query(msg);