format code sytle
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#include "dns_cache.h"
|
#include "dns_cache.h"
|
||||||
#include "tlog.h"
|
|
||||||
#include "stringutil.h"
|
#include "stringutil.h"
|
||||||
|
#include "tlog.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
struct dns_cache_head {
|
struct dns_cache_head {
|
||||||
@@ -120,7 +120,7 @@ int dns_cache_replace(char *domain, char *cname, int cname_ttl, int ttl, dns_typ
|
|||||||
return 0;
|
return 0;
|
||||||
errout_unlock:
|
errout_unlock:
|
||||||
pthread_mutex_unlock(&dns_cache_head.lock);
|
pthread_mutex_unlock(&dns_cache_head.lock);
|
||||||
//errout:
|
// errout:
|
||||||
if (dns_cache) {
|
if (dns_cache) {
|
||||||
dns_cache_release(dns_cache);
|
dns_cache_release(dns_cache);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct dns_cache {
|
|||||||
char domain[DNS_MAX_CNAME_LEN];
|
char domain[DNS_MAX_CNAME_LEN];
|
||||||
char cname[DNS_MAX_CNAME_LEN];
|
char cname[DNS_MAX_CNAME_LEN];
|
||||||
unsigned int cname_ttl;
|
unsigned int cname_ttl;
|
||||||
unsigned int ttl;;
|
unsigned int ttl;
|
||||||
int speed;
|
int speed;
|
||||||
atomic_t hitnum;
|
atomic_t hitnum;
|
||||||
int del_pending;
|
int del_pending;
|
||||||
|
|||||||
@@ -943,7 +943,8 @@ errout:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _dns_client_add_server_pending(char *server_ip, char *server_host, int port, dns_server_type_t server_type, struct client_dns_server_flags *flags, int ispending)
|
static int _dns_client_add_server_pending(char *server_ip, char *server_host, int port, dns_server_type_t server_type, struct client_dns_server_flags *flags,
|
||||||
|
int ispending)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define _SMART_DNS_CLIENT_H
|
#define _SMART_DNS_CLIENT_H
|
||||||
|
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#define DNS_SERVER_SPKI_LEN 64
|
#define DNS_SERVER_SPKI_LEN 64
|
||||||
#define DNS_SERVER_GROUP_DEFAULT "default"
|
#define DNS_SERVER_GROUP_DEFAULT "default"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#define DEFAULT_DNS_CACHE_SIZE 512
|
#define DEFAULT_DNS_CACHE_SIZE 512
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ int dns_conf_server_num;
|
|||||||
struct dns_domain_check_order dns_conf_check_order = {
|
struct dns_domain_check_order dns_conf_check_order = {
|
||||||
.order = {DOMAIN_CHECK_ICMP, DOMAIN_CHECK_TCP},
|
.order = {DOMAIN_CHECK_ICMP, DOMAIN_CHECK_TCP},
|
||||||
.tcp_port = 80,
|
.tcp_port = 80,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* logging */
|
/* logging */
|
||||||
int dns_conf_log_level = TLOG_ERROR;
|
int dns_conf_log_level = TLOG_ERROR;
|
||||||
@@ -1169,7 +1169,7 @@ static int _config_log_level(void *data, int argc, char *argv[])
|
|||||||
dns_conf_log_level = TLOG_ERROR;
|
dns_conf_log_level = TLOG_ERROR;
|
||||||
} else if (strncmp("fatal", value, MAX_LINE_LEN) == 0) {
|
} else if (strncmp("fatal", value, MAX_LINE_LEN) == 0) {
|
||||||
dns_conf_log_level = TLOG_FATAL;
|
dns_conf_log_level = TLOG_FATAL;
|
||||||
}else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ struct dns_conf_address_rule {
|
|||||||
radix_tree_t *ipv6;
|
radix_tree_t *ipv6;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dns_bind_ip
|
struct dns_bind_ip {
|
||||||
{
|
|
||||||
DNS_BIND_TYPE type;
|
DNS_BIND_TYPE type;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
char ip[DNS_MAX_IPLEN];
|
char ip[DNS_MAX_IPLEN];
|
||||||
|
|||||||
@@ -1205,7 +1205,6 @@ static int _dns_server_process_answer_A(struct dns_rrs *rrs, struct dns_request
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _dns_server_process_answer_AAAA(struct dns_rrs *rrs, struct dns_request *request, char *domain, unsigned int result_flag, int ping_timeout)
|
static int _dns_server_process_answer_AAAA(struct dns_rrs *rrs, struct dns_request *request, char *domain, unsigned int result_flag, int ping_timeout)
|
||||||
{
|
{
|
||||||
unsigned char addr[16];
|
unsigned char addr[16];
|
||||||
@@ -1221,8 +1220,8 @@ static int _dns_server_process_answer_AAAA(struct dns_rrs *rrs, struct dns_reque
|
|||||||
_dns_server_request_get(request);
|
_dns_server_request_get(request);
|
||||||
dns_get_AAAA(rrs, name, DNS_MAX_CNAME_LEN, &ttl, addr);
|
dns_get_AAAA(rrs, name, DNS_MAX_CNAME_LEN, &ttl, addr);
|
||||||
|
|
||||||
tlog(TLOG_DEBUG, "domain: %s TTL: %d IP: %.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", name, ttl, addr[0], addr[1],
|
tlog(TLOG_DEBUG, "domain: %s TTL: %d IP: %.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", name, ttl, addr[0], addr[1], addr[2],
|
||||||
addr[2], addr[3], addr[4], addr[5], addr[6], addr[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
addr[3], addr[4], addr[5], addr[6], addr[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
||||||
|
|
||||||
ip_check_result = _dns_server_ip_rule_check(request, addr, 16, DNS_T_AAAA, result_flag);
|
ip_check_result = _dns_server_ip_rule_check(request, addr, 16, DNS_T_AAAA, result_flag);
|
||||||
if (ip_check_result == 0) {
|
if (ip_check_result == 0) {
|
||||||
@@ -1266,8 +1265,8 @@ static int _dns_server_process_answer_AAAA(struct dns_rrs *rrs, struct dns_reque
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(ip, "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
|
sprintf(ip, "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6],
|
||||||
addr[6], addr[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
addr[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
||||||
|
|
||||||
/* start ping */
|
/* start ping */
|
||||||
if (_dns_server_check_speed(request, ip, 0, ping_timeout) != 0) {
|
if (_dns_server_check_speed(request, ip, 0, ping_timeout) != 0) {
|
||||||
@@ -2695,7 +2694,8 @@ int dns_server_start(void)
|
|||||||
{
|
{
|
||||||
struct dns_server_conn_head *conn = NULL;
|
struct dns_server_conn_head *conn = NULL;
|
||||||
|
|
||||||
list_for_each_entry(conn, &server.conn_list, list) {
|
list_for_each_entry(conn, &server.conn_list, list)
|
||||||
|
{
|
||||||
if (conn->fd <= 0) {
|
if (conn->fd <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -2823,7 +2823,6 @@ errout:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _dns_server_socket_tcp(struct dns_bind_ip *bind_ip)
|
static int _dns_server_socket_tcp(struct dns_bind_ip *bind_ip)
|
||||||
{
|
{
|
||||||
const char *host_ip;
|
const char *host_ip;
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ static int _http_head_parse_response(struct http_head *http_head, char *key, cha
|
|||||||
http_head->code = atol(ret_code);
|
http_head->code = atol(ret_code);
|
||||||
http_head->code_msg = result;
|
http_head->code_msg = result;
|
||||||
http_head->version = key;
|
http_head->version = key;
|
||||||
http_head->head_type = HTTP_HEAD_RESPONSE;
|
http_head->head_type = HTTP_HEAD_RESPONSE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ static void _show_version(void)
|
|||||||
#else
|
#else
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
get_compiled_time(&tm);
|
get_compiled_time(&tm);
|
||||||
snprintf(str_ver, sizeof(str_ver), "1.%.4d%.2d%.2d-%.2d%.2d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
|
snprintf(str_ver, sizeof(str_ver), "1.%.4d%.2d%.2d-%.2d%.2d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min);
|
||||||
tm.tm_min);
|
|
||||||
#endif
|
#endif
|
||||||
printf("smartdns %s\n", str_ver);
|
printf("smartdns %s\n", str_ver);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user