@@ -1,11 +1,11 @@
#include "demo.h"
-#include "dns_server.h"
-#include "util.h"
+#include "smartdns/dns_server.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/socket.h>
-#include <tlog.h>
static int demo_server_recv(struct dns_packet *packet, unsigned char *inpacket, int inpacket_len,
struct sockaddr_storage *local, socklen_t local_len, struct sockaddr_storage *from,
@@ -2,7 +2,7 @@
#ifndef SMART_DNS_PLUGIN_DEMO_H
#define SMART_DNS_PLUGIN_DEMO_H
-#include "dns_plugin.h"
+#include "smartdns/dns_plugin.h"
#ifdef __cplusplus
extern "C" {
@@ -32,6 +32,7 @@ fn get_git_commit_version() {
fn link_smartdns_lib() {
let curr_source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let smartdns_src_dir = format!("{}/../../src", curr_source_dir);
+ let smartdns_inc_dir = format!("{}/include", smartdns_src_dir);
let smartdns_lib_file = format!("{}/libsmartdns-test.a", smartdns_src_dir);
let cc = env::var("RUSTC_LINKER")
@@ -51,7 +52,7 @@ fn link_smartdns_lib() {
let ignored_macros = IgnoreMacros(vec!["IPPORT_RESERVED".into()].into_iter().collect());
let mut bindings_builder =
- bindgen::Builder::default().header(format!("{}/smartdns.h", smartdns_src_dir));
+ bindgen::Builder::default().header(format!("{}/smartdns/smartdns.h", smartdns_inc_dir));
if let Some(sysroot) = sysroot {
bindings_builder = bindings_builder.clang_arg(format!("--sysroot={}", sysroot));
}
@@ -3,3 +3,4 @@
.DS_Store
.swp.
smartdns
+!smartdns/
@@ -17,7 +17,7 @@
BIN=smartdns
SMARTDNS_LIB=libsmartdns.a
SMARTDNS_TEST_LIB=libsmartdns-test.a
-OBJS_LIB=$(patsubst %.c,%.o,$(wildcard lib/*.c))
+OBJS_LIB=$(patsubst %.c,%.o,$(wildcard *.c)) $(patsubst %.c,%.o,$(wildcard */*.c))
OBJS_MAIN=$(filter-out main.o, $(patsubst %.c,%.o,$(wildcard *.c)))
TEST_OBJS=$(patsubst %.o,%_test.o,$(OBJS_MAIN) $(OBJS_LIB))
MAIN_OBJ = main.o
@@ -17,9 +17,9 @@
*/
#define _GNU_SOURCE
-#include "dns.h"
-#include "stringutil.h"
-#include "tlog.h"
+#include "smartdns/dns.h"
+#include "smartdns/lib/stringutil.h"
#include <fcntl.h>
#include <stdint.h>
@@ -16,12 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "dns_cache.h"
-#include "dns_stats.h"
-#include "timer.h"
+#include "smartdns/dns_cache.h"
+#include "smartdns/dns_stats.h"
+#include "smartdns/timer.h"
#include <errno.h>
#include <pthread.h>
@@ -17,19 +17,20 @@
-#include "dns_client.h"
-#include "atomic.h"
-#include "dns_conf.h"
-#include "fast_ping.h"
-#include "hashtable.h"
-#include "http_parse.h"
-#include "list.h"
-#include "proxy.h"
+#include "smartdns/dns_client.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/fast_ping.h"
+#include "smartdns/http_parse.h"
+#include "smartdns/lib/atomic.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/proxy.h"
+
#include <ctype.h>
-#include "idna.h"
-#include "rbtree.h"
+#include "smartdns/lib/idna.h"
+#include "smartdns/lib/rbtree.h"
#include <getopt.h>
#include <glob.h>
@@ -16,21 +16,20 @@
-
-#include "include/conf.h"
-#include "include/hashtable.h"
-#include "include/list.h"
+#include "smartdns/lib/conf.h"
#include <dlfcn.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
struct dns_plugin_ops {
struct list_head list;
struct smartdns_operations ops;
@@ -19,21 +19,21 @@
#ifndef _GNU_SOURCE
#endif
-#include "nftset.h"
+#include "smartdns/lib/nftset.h"
@@ -16,9 +16,9 @@
-#include "stddef.h"
-#include "string.h"
+#include <stddef.h>
+#include <string.h>
struct dns_stats dns_stats;
@@ -16,13 +16,13 @@
-#include "hash.h"
-#include "jhash.h"
-#include "qpack.h"
+#include "smartdns/lib/hash.h"
+#include "smartdns/lib/jhash.h"
+#include "smartdns/lib/qpack.h"
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * Copyright (C) 2018-2025 Ruilin Peng (Nick) <[email protected]>.
+ * Copyright (C) 2018-2024 Ruilin Peng (Nick) <[email protected]>.
* smartdns is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,13 +19,13 @@
#ifndef _SMARTDNS_CACHE_H
#define _SMARTDNS_CACHE_H
#include <time.h>
@@ -19,7 +19,7 @@
#ifndef _SMART_DNS_CLIENT_H
#define _SMART_DNS_CLIENT_H
@@ -19,16 +19,16 @@
#ifndef _DNS_CONF
#define _DNS_CONF
-#include "art.h"
-#include "conf.h"
-#include "radix.h"
+#include "smartdns/lib/art.h"
+#include "smartdns/lib/radix.h"
+ * Copyright (C) 2018-2023 Ruilin Peng (Nick) <[email protected]>.
#ifndef SMART_DNS_PLUGIN_H
#define SMART_DNS_PLUGIN_H
@@ -19,8 +19,8 @@
#ifndef _SMART_DNS_SERVER_H
#define _SMART_DNS_SERVER_H
#ifndef SMART_DNS_STATS_H
#define SMART_DNS_STATS_H
@@ -19,15 +19,14 @@
#ifndef SMART_DNS_H
#define SMART_DNS_H
#ifndef SMART_DNS_TIMER_H
#define SMART_DNS_TIMER_H
-#include "timer_wheel.h"
+#include "smartdns/lib/timer_wheel.h"
/*
* tinylog
- * Copyright (C) 2018-2025 Ruilin Peng (Nick) <[email protected]>
+ * Copyright (C) 2018-2024 Ruilin Peng (Nick) <[email protected]>
* https://github.com/pymumu/tinylog
#ifndef SMART_DNS_UTIL_H
#define SMART_DNS_UTIL_H
#include <netdb.h>
@@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <strings.h>
#include <assert.h>
// #ifdef __i386__
// #include <emmintrin.h>
@@ -16,8 +16,8 @@
-#include "bitmap.h"
-#include "bitops.h"
+#include "smartdns/lib/bitmap.h"
+#include "smartdns/lib/bitops.h"
* This is a common helper function for find_next_bit, find_next_zero_bit, and
@@ -16,7 +16,7 @@
#include <libgen.h>
@@ -18,7 +18,7 @@
static unsigned _utf8_decode_slow(const char **p, const char *pe, unsigned a)
#define _GNU_SOURCE /* See feature_test_macros(7) */
-#include "../dns_conf.h"
-#include "../tlog.h"
#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
static const uint8_t _qpack_huffman_bit[64] = {
249, 50, 115, 39, 38, 79, 147, 39, 38, 100, 249, 50, 114, 100, 242, 100, 228, 228, 206, 77, 52, 228,
@@ -60,7 +60,7 @@
/* $Id: radix.c,v 1.17 2007/10/24 06:04:31 djm Exp $ */
#include <stdbool.h>
static inline void rb_set_black(struct rb_node *rb)
@@ -25,7 +25,7 @@
#include <sys/types.h>
#include <unistd.h>
#define TVR_BITS 10
#define TVN_BITS 6
-#include "smartdns.h"
+#include "smartdns/smartdns.h"
@@ -18,15 +18,15 @@
static struct tw_base *dns_timer_base = NULL;
@@ -6,7 +6,7 @@
#include <dirent.h>
@@ -20,9 +20,9 @@
@@ -17,10 +17,10 @@
#include "client.h"
#include "include/utils.h"
#include "server.h"
#include "gtest/gtest.h"
#include <fstream>
@@ -27,7 +27,7 @@
/* clang-format off */
/* clang-format on */
class Cache : public ::testing::Test
@@ -17,11 +17,11 @@
@@ -133,7 +133,6 @@ TEST_F(HTTP, http1_1_response_serialize)
http_head_destroy(http_head);
TEST_F(HTTP, http3_0_parse)
{
struct http_head *http_head = http_head_init(1024, HTTP_VERSION_3_0);
@@ -17,8 +17,8 @@
class Ping : public ::testing::Test
#ifndef _SMARTDNS_SERVER_
#define _SMARTDNS_SERVER_
#include <functional>
#include <string>
@@ -1,5 +1,5 @@
#include <ifaddrs.h>