format code sytle
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "dns_cache.h"
|
||||
#include "tlog.h"
|
||||
#include "stringutil.h"
|
||||
#include "tlog.h"
|
||||
#include <pthread.h>
|
||||
|
||||
struct dns_cache_head {
|
||||
@@ -25,7 +25,7 @@ int dns_cache_init(int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __attribute__((unused)) struct dns_cache *_dns_cache_last(void)
|
||||
static __attribute__((unused)) struct dns_cache *_dns_cache_last(void)
|
||||
{
|
||||
return list_last_entry(&dns_cache_head.cache_list, struct dns_cache, list);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ int dns_cache_replace(char *domain, char *cname, int cname_ttl, int ttl, dns_typ
|
||||
return 0;
|
||||
errout_unlock:
|
||||
pthread_mutex_unlock(&dns_cache_head.lock);
|
||||
//errout:
|
||||
// errout:
|
||||
if (dns_cache) {
|
||||
dns_cache_release(dns_cache);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ struct dns_cache {
|
||||
char domain[DNS_MAX_CNAME_LEN];
|
||||
char cname[DNS_MAX_CNAME_LEN];
|
||||
unsigned int cname_ttl;
|
||||
unsigned int ttl;;
|
||||
unsigned int ttl;
|
||||
int speed;
|
||||
atomic_t hitnum;
|
||||
int del_pending;
|
||||
|
||||
@@ -943,7 +943,8 @@ errout:
|
||||
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;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define _SMART_DNS_CLIENT_H
|
||||
|
||||
#include "dns.h"
|
||||
#define DNS_SERVER_SPKI_LEN 64
|
||||
#define DNS_SERVER_SPKI_LEN 64
|
||||
#define DNS_SERVER_GROUP_DEFAULT "default"
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "tlog.h"
|
||||
#include "util.h"
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#define DEFAULT_DNS_CACHE_SIZE 512
|
||||
|
||||
@@ -39,7 +39,7 @@ int dns_conf_server_num;
|
||||
struct dns_domain_check_order dns_conf_check_order = {
|
||||
.order = {DOMAIN_CHECK_ICMP, DOMAIN_CHECK_TCP},
|
||||
.tcp_port = 80,
|
||||
};
|
||||
};
|
||||
|
||||
/* logging */
|
||||
int dns_conf_log_level = TLOG_ERROR;
|
||||
@@ -752,7 +752,7 @@ static int _config_speed_check_mode(void *data, int argc, char *argv[])
|
||||
if (field == NULL || order >= DOMAIN_CHECK_NUM) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (ptr) {
|
||||
*ptr = 0;
|
||||
}
|
||||
@@ -765,7 +765,7 @@ static int _config_speed_check_mode(void *data, int argc, char *argv[])
|
||||
port = atoi(port_str + 1);
|
||||
if (port <= 0 || port >= 65535) {
|
||||
port = 80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dns_conf_check_order.order[order] = DOMAIN_CHECK_TCP;
|
||||
@@ -1169,7 +1169,7 @@ static int _config_log_level(void *data, int argc, char *argv[])
|
||||
dns_conf_log_level = TLOG_ERROR;
|
||||
} else if (strncmp("fatal", value, MAX_LINE_LEN) == 0) {
|
||||
dns_conf_log_level = TLOG_FATAL;
|
||||
}else {
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef enum {
|
||||
#define DOMAIN_CHECK_NONE 0
|
||||
#define DOMAIN_CHECK_ICMP 1
|
||||
#define DOMAIN_CHECK_TCP 2
|
||||
#define DOMAIN_CHECK_NUM 2
|
||||
#define DOMAIN_CHECK_NUM 2
|
||||
|
||||
#define DOMAIN_FLAG_ADDR_SOA (1 << 0)
|
||||
#define DOMAIN_FLAG_ADDR_IPV4_SOA (1 << 1)
|
||||
@@ -161,8 +161,7 @@ struct dns_conf_address_rule {
|
||||
radix_tree_t *ipv6;
|
||||
};
|
||||
|
||||
struct dns_bind_ip
|
||||
{
|
||||
struct dns_bind_ip {
|
||||
DNS_BIND_TYPE type;
|
||||
uint32_t flags;
|
||||
char ip[DNS_MAX_IPLEN];
|
||||
|
||||
@@ -814,7 +814,7 @@ errout:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void _dns_server_delete_request(struct dns_request *request)
|
||||
static void _dns_server_delete_request(struct dns_request *request)
|
||||
{
|
||||
if (request->conn) {
|
||||
_dns_server_conn_release(request->conn);
|
||||
@@ -852,7 +852,7 @@ static void _dns_server_request_release(struct dns_request *request)
|
||||
hash_del(&addr_map->node);
|
||||
free(addr_map);
|
||||
}
|
||||
|
||||
|
||||
_dns_server_delete_request(request);
|
||||
}
|
||||
|
||||
@@ -1094,7 +1094,7 @@ static int _dns_server_ip_rule_check(struct dns_request *request, unsigned char
|
||||
if (rule->ip_ignore) {
|
||||
goto skip;
|
||||
}
|
||||
|
||||
|
||||
rule_not_found:
|
||||
if (result_flag & DNSSERVER_FLAG_WHITELIST_IP) {
|
||||
if (rule == NULL) {
|
||||
@@ -1205,7 +1205,6 @@ static int _dns_server_process_answer_A(struct dns_rrs *rrs, struct dns_request
|
||||
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)
|
||||
{
|
||||
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_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],
|
||||
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]);
|
||||
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[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);
|
||||
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;
|
||||
}
|
||||
|
||||
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[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
||||
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[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]);
|
||||
|
||||
/* start ping */
|
||||
if (_dns_server_check_speed(request, ip, 0, ping_timeout) != 0) {
|
||||
@@ -1490,7 +1489,7 @@ static int dns_server_resolve_callback(char *domain, dns_result_type rtype, unsi
|
||||
ret = _dns_server_passthrough_rule_check(request, domain, packet, result_flag);
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return _dns_server_reply_passthrouth(request, packet, inpacket, inpacket_len);
|
||||
}
|
||||
@@ -1869,7 +1868,7 @@ static int _dns_server_request_set_client_addr(struct dns_request *request, stru
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _dns_server_request_set_callback(struct dns_request *request, dns_result_callback callback, void *user_ptr)
|
||||
static void _dns_server_request_set_callback(struct dns_request *request, dns_result_callback callback, void *user_ptr)
|
||||
{
|
||||
request->result_callback = callback;
|
||||
request->user_ptr = user_ptr;
|
||||
@@ -2005,7 +2004,7 @@ errout:
|
||||
|
||||
_dns_server_request_remove(request);
|
||||
request = NULL;
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _dns_server_check_set_passthrough(struct dns_request *request, struct dns_server_conn_head *conn)
|
||||
@@ -2695,7 +2694,8 @@ int dns_server_start(void)
|
||||
{
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@@ -2823,13 +2823,12 @@ errout:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int _dns_server_socket_tcp(struct dns_bind_ip *bind_ip)
|
||||
{
|
||||
const char *host_ip;
|
||||
struct dns_server_conn_tcp_server *conn = NULL;
|
||||
int fd = -1;
|
||||
|
||||
|
||||
host_ip = bind_ip->ip;
|
||||
conn = malloc(sizeof(struct dns_server_conn_tcp_server));
|
||||
if (conn == NULL) {
|
||||
|
||||
@@ -137,12 +137,12 @@ HTTP_METHOD http_head_get_method(struct http_head *http_head)
|
||||
return http_head->method;
|
||||
}
|
||||
|
||||
const char *http_head_get_url(struct http_head *http_head)
|
||||
const char *http_head_get_url(struct http_head *http_head)
|
||||
{
|
||||
return http_head->url;
|
||||
}
|
||||
|
||||
const char *http_head_get_httpversion(struct http_head *http_head)
|
||||
const char *http_head_get_httpversion(struct http_head *http_head)
|
||||
{
|
||||
return http_head->version;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ HTTP_HEAD_TYPE http_head_get_head_type(struct http_head *http_head)
|
||||
return http_head->head_type;
|
||||
}
|
||||
|
||||
char *http_head_get_data(struct http_head *http_head)
|
||||
char *http_head_get_data(struct http_head *http_head)
|
||||
{
|
||||
return http_head->data;
|
||||
}
|
||||
@@ -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_msg = result;
|
||||
http_head->version = key;
|
||||
http_head->head_type = HTTP_HEAD_RESPONSE;
|
||||
http_head->head_type = HTTP_HEAD_RESPONSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ static void _help(void)
|
||||
printf("%s", help);
|
||||
}
|
||||
|
||||
static void _show_version(void)
|
||||
static void _show_version(void)
|
||||
{
|
||||
char str_ver[256] = {0};
|
||||
#ifdef SMARTDNS_VERION
|
||||
@@ -79,8 +79,7 @@ static void _show_version(void)
|
||||
#else
|
||||
struct tm 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,
|
||||
tm.tm_min);
|
||||
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);
|
||||
#endif
|
||||
printf("smartdns %s\n", str_ver);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user