Skip to content

Commit

Permalink
support -s host:port; close #8
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jul 29, 2014
1 parent 6c9bee1 commit de57c66
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion openwrt/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 15 additions & 4 deletions src/chinadns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit de57c66

Please sign in to comment.