Add some log, fix tlog issue
This commit is contained in:
@@ -246,6 +246,31 @@ static LIST_HEAD(pending_servers);
|
|||||||
static pthread_mutex_t pending_server_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t pending_server_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static int dns_client_has_bootstrap_dns = 0;
|
static int dns_client_has_bootstrap_dns = 0;
|
||||||
|
|
||||||
|
const char *_dns_server_get_type_string(dns_server_type_t type)
|
||||||
|
{
|
||||||
|
const char *type_str = "";
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DNS_SERVER_UDP:
|
||||||
|
type_str = "udp";
|
||||||
|
break;
|
||||||
|
case DNS_SERVER_TCP:
|
||||||
|
type_str = "tcp";
|
||||||
|
break;
|
||||||
|
case DNS_SERVER_TLS:
|
||||||
|
type_str = "tls";
|
||||||
|
break;
|
||||||
|
case DNS_SERVER_HTTPS:
|
||||||
|
type_str = "https";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return type_str;
|
||||||
|
}
|
||||||
|
|
||||||
/* get addr info */
|
/* get addr info */
|
||||||
static struct addrinfo *_dns_client_getaddr(const char *host, char *port, int type, int protocol)
|
static struct addrinfo *_dns_client_getaddr(const char *host, char *port, int type, int protocol)
|
||||||
{
|
{
|
||||||
@@ -823,6 +848,8 @@ static int _dns_client_server_add(char *server_ip, char *server_host, int port,
|
|||||||
atomic_inc(&client.dns_server_num);
|
atomic_inc(&client.dns_server_num);
|
||||||
freeaddrinfo(gai);
|
freeaddrinfo(gai);
|
||||||
|
|
||||||
|
tlog(TLOG_INFO, "add server %s:%d, type: %s", server_ip, port, _dns_server_get_type_string(server_info->type));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
errout:
|
errout:
|
||||||
if (server_info) {
|
if (server_info) {
|
||||||
@@ -1753,8 +1780,10 @@ static int _dns_client_process_tcp_buff(struct dns_server_info *server_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (http_head_get_httpcode(http_head) != 200) {
|
if (http_head_get_httpcode(http_head) != 200) {
|
||||||
tlog(TLOG_WARN, "http server query failed, server return http code : %d, %s", http_head_get_httpcode(http_head),
|
tlog(TLOG_WARN, "http server query from %s:%d failed, server return http code : %d, %s",
|
||||||
http_head_get_httpcode_msg(http_head));
|
server_info->ip, server_info->port,
|
||||||
|
http_head_get_httpcode(http_head),
|
||||||
|
http_head_get_httpcode_msg(http_head));
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1829,7 +1858,7 @@ static int _dns_client_process_tcp(struct dns_server_info *server_info, struct e
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlog(TLOG_ERROR, "recv failed, server %s, %s\n", server_info->ip, strerror(errno));
|
tlog(TLOG_ERROR, "recv failed, server %s:%d, %s\n", server_info->ip, server_info->port, strerror(errno));
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1721,7 +1721,12 @@ static void _dns_server_update_rule_by_flags(struct dns_request *request)
|
|||||||
{
|
{
|
||||||
struct dns_rule_flags *rule_flag =
|
struct dns_rule_flags *rule_flag =
|
||||||
(struct dns_rule_flags *)request->domain_rule.rules[0];
|
(struct dns_rule_flags *)request->domain_rule.rules[0];
|
||||||
unsigned flags = rule_flag->flags;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
if (rule_flag == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
flags = rule_flag->flags;
|
||||||
|
|
||||||
if (flags & DOMAIN_FLAG_ADDR_IGN) {
|
if (flags & DOMAIN_FLAG_ADDR_IGN) {
|
||||||
request->domain_rule.rules[DOMAIN_RULE_ADDRESS_IPV4] = NULL;
|
request->domain_rule.rules[DOMAIN_RULE_ADDRESS_IPV4] = NULL;
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ typedef enum {
|
|||||||
|
|
||||||
struct tlog_time {
|
struct tlog_time {
|
||||||
int year;
|
int year;
|
||||||
|
unsigned int usec;
|
||||||
unsigned char mon;
|
unsigned char mon;
|
||||||
unsigned char mday;
|
unsigned char mday;
|
||||||
unsigned char hour;
|
unsigned char hour;
|
||||||
unsigned char min;
|
unsigned char min;
|
||||||
unsigned char sec;
|
unsigned char sec;
|
||||||
unsigned char usec;
|
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#ifndef TLOG_MAX_LINE_LEN
|
#ifndef TLOG_MAX_LINE_LEN
|
||||||
|
|||||||
Reference in New Issue
Block a user