Update code

This commit is contained in:
Nick Peng
2018-06-09 00:08:06 +08:00
parent 4a6b0baddd
commit b05dd784bc
4 changed files with 27 additions and 11 deletions

View File

@@ -495,8 +495,9 @@ static void *_dns_client_work(void *arg)
int sleep_time;
unsigned int expect_time = 0;
now = get_tick_count() - sleep;
expect_time = now + sleep;
sleep_time = sleep;
now = get_tick_count() - sleep;
expect_time = now + sleep;
while (client.run) {
now = get_tick_count();
if (now >= expect_time) {

View File

@@ -414,7 +414,7 @@ static int _dns_server_process_answer(struct dns_request *request, char *domain,
if (request->rcode == DNS_RC_SERVFAIL) {
request->rcode = packet->head.rcode;
}
tlog(TLOG_ERROR, "inquery failed, %s, rcode = %d, id = %d\n", domain, packet->head.rcode, packet->head.id);
tlog(TLOG_DEBUG, "inquery failed, %s, rcode = %d, id = %d\n", domain, packet->head.rcode, packet->head.id);
return -1;
}
@@ -429,6 +429,12 @@ static int _dns_server_process_answer(struct dns_request *request, char *domain,
unsigned char addr[4];
_dns_server_request_get(request);
dns_get_A(rrs, name, DNS_MAX_CNAME_LEN, &ttl, addr);
if (addr[0] == 127) {
_dns_server_request_release(request);
break;
}
if (request->has_ipv4 == 0) {
memcpy(request->ipv4_addr, addr, DNS_RR_A_LEN);
request->has_ipv4 = 1;
@@ -709,6 +715,7 @@ int dns_server_run(void)
int sleep_time = 0;
unsigned long expect_time = 0;
sleep_time = sleep;
now = get_tick_count() - sleep;
expect_time = now + sleep;
while (server.run) {

View File

@@ -302,7 +302,8 @@ static int _fast_ping_sendping_v6(struct ping_host_struct *ping_host)
goto errout;
}
char ping_host_name[PING_MAX_HOSTLEN];
tlog(TLOG_ERROR, "sendto %s %s", gethost_by_addr(ping_host_name, (struct sockaddr *)&ping_host->addr, ping_host->addr_len), strerror(errno));
tlog(TLOG_ERROR, "sendto %s, id %d, %s", gethost_by_addr(ping_host_name, (struct sockaddr *)&ping_host->addr, ping_host->addr_len), ping_host->sid,
strerror(errno));
goto errout;
}
@@ -333,7 +334,12 @@ static int _fast_ping_sendping_v4(struct ping_host_struct *ping_host)
len = sendto(ping_host->fd, packet, sizeof(struct fast_ping_packet), 0, (struct sockaddr *)&ping_host->addr, ping_host->addr_len);
if (len < 0 || len != sizeof(struct fast_ping_packet)) {
tlog(TLOG_ERROR, "sendto %s\n", strerror(errno));
if (errno == ENETUNREACH) {
goto errout;
}
char ping_host_name[PING_MAX_HOSTLEN];
tlog(TLOG_ERROR, "sendto %s, id %d, %s", gethost_by_addr(ping_host_name, (struct sockaddr *)&ping_host->addr, ping_host->addr_len), ping_host->sid,
strerror(errno));
goto errout;
}
@@ -528,6 +534,7 @@ struct ping_host_struct *fast_ping_start(const char *host, int count, int interv
}
memcpy(&ping_host->addr, gai->ai_addr, gai->ai_addrlen);
tlog(TLOG_DEBUG, "ping %s, id = %d", host, ping_host->sid);
if (_fast_ping_sendping(ping_host) != 0) {
goto errout1;
}
@@ -543,6 +550,7 @@ struct ping_host_struct *fast_ping_start(const char *host, int count, int interv
freeaddrinfo(gai);
return ping_host;
errout:
if (fd > 0) {
@@ -582,7 +590,7 @@ static struct fast_ping_packet *_fast_ping_icmp6_packet(struct ping_host_struct
struct icmp6_hdr *icmp6 = &packet->icmp6;
if (icmp6->icmp6_type != ICMP6_ECHO_REPLY) {
tlog(TLOG_ERROR, "icmp6 type faild, %d:%d", icmp6->icmp6_type, ICMP6_ECHO_REPLY);
tlog(TLOG_DEBUG, "icmp6 type faild, %d:%d", icmp6->icmp6_type, ICMP6_ECHO_REPLY);
return NULL;
}
@@ -624,7 +632,7 @@ static struct fast_ping_packet *_fast_ping_icmp_packet(struct ping_host_struct *
}
if (icmp->icmp_type != ICMP_ECHOREPLY) {
tlog(TLOG_ERROR, "icmp type faild, %d:%d", icmp->icmp_type, ICMP_ECHOREPLY);
tlog(TLOG_DEBUG, "icmp type faild, %d:%d", icmp->icmp_type, ICMP_ECHOREPLY);
return NULL;
}

View File

@@ -11,7 +11,7 @@ server 123.207.137.88
server 119.29.29.29
server 223.5.5.5
server 208.67.222.222:5353
server 202.141.178.13:5353
server 77.88.8.8:53
server 202.141.162.123:53
server 101.132.183.99:53
#server 202.141.178.13:5353
#server 77.88.8.8:53
#server 202.141.162.123:53
#server 101.132.183.99:53