Browse Source

code: refactor code structure.

Nick Peng 6 months ago
parent
commit
451b3edce2
95 changed files with 223 additions and 223 deletions
  1. 3 3
      plugin/demo/demo.c
  2. 1 1
      plugin/demo/demo.h
  3. 2 1
      plugin/smartdns-ui/build.rs
  4. 1 0
      src/.gitignore
  5. 1 1
      src/Makefile
  6. 3 3
      src/dns.c
  7. 6 6
      src/dns_cache.c
  8. 14 13
      src/dns_client.c
  9. 6 6
      src/dns_conf.c
  10. 8 9
      src/dns_plugin.c
  11. 15 15
      src/dns_server.c
  12. 3 3
      src/dns_stats.c
  13. 6 6
      src/fast_ping.c
  14. 7 7
      src/http_parse.c
  15. 1 1
      src/include/smartdns/dns.h
  16. 7 7
      src/include/smartdns/dns_cache.h
  17. 2 2
      src/include/smartdns/dns_client.h
  18. 10 10
      src/include/smartdns/dns_conf.h
  19. 2 2
      src/include/smartdns/dns_plugin.h
  20. 2 2
      src/include/smartdns/dns_server.h
  21. 1 1
      src/include/smartdns/dns_stats.h
  22. 1 1
      src/include/smartdns/fast_ping.h
  23. 1 1
      src/include/smartdns/http_parse.h
  24. 0 0
      src/include/smartdns/lib/art.h
  25. 1 1
      src/include/smartdns/lib/atomic.h
  26. 1 1
      src/include/smartdns/lib/bitmap.h
  27. 1 1
      src/include/smartdns/lib/bitops.h
  28. 1 1
      src/include/smartdns/lib/conf.h
  29. 1 1
      src/include/smartdns/lib/findbit.h
  30. 1 1
      src/include/smartdns/lib/gcc_builtin.h
  31. 1 1
      src/include/smartdns/lib/hash.h
  32. 1 1
      src/include/smartdns/lib/hashtable.h
  33. 1 1
      src/include/smartdns/lib/idna.h
  34. 1 1
      src/include/smartdns/lib/jhash.h
  35. 1 1
      src/include/smartdns/lib/list.h
  36. 0 0
      src/include/smartdns/lib/nftset.h
  37. 0 0
      src/include/smartdns/lib/qpack.h
  38. 0 0
      src/include/smartdns/lib/radix.h
  39. 1 1
      src/include/smartdns/lib/rbtree.h
  40. 1 1
      src/include/smartdns/lib/stringutil.h
  41. 1 1
      src/include/smartdns/lib/timer_wheel.h
  42. 1 1
      src/include/smartdns/proxy.h
  43. 8 9
      src/include/smartdns/smartdns.h
  44. 1 1
      src/include/smartdns/timer.h
  45. 1 1
      src/include/smartdns/tlog.h
  46. 1 1
      src/include/smartdns/util.h
  47. 1 1
      src/lib/art.c
  48. 2 2
      src/lib/bitops.c
  49. 1 1
      src/lib/conf.c
  50. 1 1
      src/lib/idna.c
  51. 3 3
      src/lib/nftset.c
  52. 1 1
      src/lib/qpack.c
  53. 1 1
      src/lib/radix.c
  54. 1 1
      src/lib/rbtree.c
  55. 2 2
      src/lib/timer_wheel.c
  56. 1 1
      src/main.c
  57. 7 7
      src/proxy.c
  58. 9 9
      src/smartdns.c
  59. 2 2
      src/timer.c
  60. 1 1
      src/tlog.c
  61. 3 3
      src/util.c
  62. 2 2
      test/cases/test-address.cc
  63. 1 1
      test/cases/test-bootstrap.cc
  64. 2 2
      test/cases/test-cache.cc
  65. 1 1
      test/cases/test-client-rule.cc
  66. 1 1
      test/cases/test-cname.cc
  67. 2 2
      test/cases/test-ddns.cc
  68. 1 1
      test/cases/test-discard-block-ip.cc
  69. 2 2
      test/cases/test-dns64.cc
  70. 1 1
      test/cases/test-domain-rule.cc
  71. 2 2
      test/cases/test-domain-set.cc
  72. 2 2
      test/cases/test-dualstack.cc
  73. 2 2
      test/cases/test-edns.cc
  74. 1 1
      test/cases/test-group.cc
  75. 2 2
      test/cases/test-hosts.cc
  76. 3 4
      test/cases/test-http.cc
  77. 2 2
      test/cases/test-https.cc
  78. 2 2
      test/cases/test-idna.cc
  79. 1 1
      test/cases/test-ip-alias.cc
  80. 1 1
      test/cases/test-ip-rule.cc
  81. 2 2
      test/cases/test-mdns.cc
  82. 1 1
      test/cases/test-nameserver.cc
  83. 1 1
      test/cases/test-perf.cc
  84. 2 2
      test/cases/test-ping.cc
  85. 2 2
      test/cases/test-ptr.cc
  86. 1 1
      test/cases/test-qtype-soa.cc
  87. 2 2
      test/cases/test-rule.cc
  88. 2 2
      test/cases/test-same-pending-query.cc
  89. 1 1
      test/cases/test-server.cc
  90. 2 2
      test/cases/test-speed-check.cc
  91. 2 2
      test/cases/test-srv.cc
  92. 2 2
      test/cases/test-subnet.cc
  93. 4 4
      test/server.cc
  94. 2 2
      test/server.h
  95. 1 1
      test/utils.cc

+ 3 - 3
plugin/demo/demo.c

@@ -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,

+ 1 - 1
plugin/demo/demo.h

@@ -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" {

+ 2 - 1
plugin/smartdns-ui/build.rs

@@ -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));
     }

+ 1 - 0
src/.gitignore

@@ -3,3 +3,4 @@
 .DS_Store
 .swp.
 smartdns
+!smartdns/

+ 1 - 1
src/Makefile

@@ -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

+ 3 - 3
src/dns.c

@@ -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 "smartdns/tlog.h"
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <stdint.h>

+ 6 - 6
src/dns_cache.c

@@ -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 "stringutil.h"
-#include "timer.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/dns_cache.h"
+#include "smartdns/dns_stats.h"
+#include "smartdns/lib/stringutil.h"
+#include "smartdns/timer.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>

+ 14 - 13
src/dns_client.c

@@ -17,19 +17,20 @@
  */
 
 #define _GNU_SOURCE
-#include "dns_client.h"
-#include "atomic.h"
-#include "dns.h"
-#include "dns_conf.h"
-#include "dns_server.h"
-#include "dns_stats.h"
-#include "fast_ping.h"
-#include "hashtable.h"
-#include "http_parse.h"
-#include "list.h"
-#include "proxy.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/dns_client.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/dns_server.h"
+#include "smartdns/dns_stats.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 "smartdns/tlog.h"
+#include "smartdns/util.h"
+
 #include <arpa/inet.h>
 #include <ctype.h>
 #include <errno.h>

+ 6 - 6
src/dns_conf.c

@@ -16,12 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "dns_conf.h"
-#include "idna.h"
-#include "list.h"
-#include "rbtree.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/lib/idna.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/lib/rbtree.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <errno.h>
 #include <getopt.h>
 #include <glob.h>

+ 8 - 9
src/dns_plugin.c

@@ -16,21 +16,20 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "dns_plugin.h"
-
-#include "dns_conf.h"
-#include "include/conf.h"
-#include "include/hashtable.h"
-#include "include/list.h"
-#include "util.h"
+#include "smartdns/dns_plugin.h"
+
+#include "smartdns/dns_conf.h"
+#include "smartdns/lib/conf.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <dlfcn.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "tlog.h"
-
 struct dns_plugin_ops {
 	struct list_head list;
 	struct smartdns_operations ops;

+ 15 - 15
src/dns_server.c

@@ -19,21 +19,21 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "dns_server.h"
-#include "atomic.h"
-#include "dns.h"
-#include "dns_cache.h"
-#include "dns_client.h"
-#include "dns_conf.h"
-#include "dns_plugin.h"
-#include "dns_stats.h"
-#include "fast_ping.h"
-#include "hashtable.h"
-#include "http_parse.h"
-#include "list.h"
-#include "nftset.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/dns_server.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_cache.h"
+#include "smartdns/dns_client.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/dns_plugin.h"
+#include "smartdns/dns_stats.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/lib/nftset.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>

+ 3 - 3
src/dns_stats.c

@@ -16,9 +16,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "dns_stats.h"
-#include "stddef.h"
-#include "string.h"
+#include "smartdns/dns_stats.h"
+#include <stddef.h>
+#include <string.h>
 
 struct dns_stats dns_stats;
 

+ 6 - 6
src/fast_ping.c

@@ -16,12 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "fast_ping.h"
-#include "atomic.h"
-#include "hashtable.h"
-#include "list.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/fast_ping.h"
+#include "smartdns/lib/atomic.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>

+ 7 - 7
src/http_parse.c

@@ -16,13 +16,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "http_parse.h"
-#include "hash.h"
-#include "hashtable.h"
-#include "jhash.h"
-#include "list.h"
-#include "qpack.h"
-#include "util.h"
+#include "smartdns/http_parse.h"
+#include "smartdns/lib/hash.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/jhash.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/lib/qpack.h"
+#include "smartdns/util.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 1 - 1
src/dns.h → src/include/smartdns/dns.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

+ 7 - 7
src/dns_cache.h → src/include/smartdns/dns_cache.h

@@ -19,13 +19,13 @@
 #ifndef _SMARTDNS_CACHE_H
 #define _SMARTDNS_CACHE_H
 
-#include "atomic.h"
-#include "dns.h"
-#include "dns_conf.h"
-#include "hash.h"
-#include "hashtable.h"
-#include "list.h"
-#include "timer.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/lib/atomic.h"
+#include "smartdns/lib/hash.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/timer.h"
 #include <stdlib.h>
 #include <time.h>
 

+ 2 - 2
src/dns_client.h → src/include/smartdns/dns_client.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,7 +19,7 @@
 #ifndef _SMART_DNS_CLIENT_H
 #define _SMART_DNS_CLIENT_H
 
-#include "dns.h"
+#include "smartdns/dns.h"
 
 #ifdef __cplusplus
 extern "C" {

+ 10 - 10
src/dns_conf.h → src/include/smartdns/dns_conf.h

@@ -19,16 +19,16 @@
 #ifndef _DNS_CONF
 #define _DNS_CONF
 
-#include "art.h"
-#include "atomic.h"
-#include "conf.h"
-#include "dns.h"
-#include "dns_client.h"
-#include "hash.h"
-#include "hashtable.h"
-#include "list.h"
-#include "proxy.h"
-#include "radix.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_client.h"
+#include "smartdns/lib/art.h"
+#include "smartdns/lib/atomic.h"
+#include "smartdns/lib/conf.h"
+#include "smartdns/lib/hash.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/lib/radix.h"
+#include "smartdns/proxy.h"
 
 #ifdef __cplusplus
 extern "C" {

+ 2 - 2
src/dns_plugin.h → src/include/smartdns/dns_plugin.h

@@ -1,6 +1,6 @@
 /*************************************************************************
  *
- * Copyright (C) 2018-2025 Ruilin Peng (Nick) <[email protected]>.
+ * Copyright (C) 2018-2023 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,7 +19,7 @@
 #ifndef SMART_DNS_PLUGIN_H
 #define SMART_DNS_PLUGIN_H
 
-#include "dns.h"
+#include "smartdns/dns.h"
 #include <sys/socket.h>
 
 #ifdef __cplusplus

+ 2 - 2
src/dns_server.h → src/include/smartdns/dns_server.h

@@ -19,8 +19,8 @@
 #ifndef _SMART_DNS_SERVER_H
 #define _SMART_DNS_SERVER_H
 
-#include "dns.h"
-#include "dns_client.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_client.h"
 #include <stdint.h>
 
 #ifdef __cplusplus

+ 1 - 1
src/dns_stats.h → src/include/smartdns/dns_stats.h

@@ -19,7 +19,7 @@
 #ifndef SMART_DNS_STATS_H
 #define SMART_DNS_STATS_H
 
-#include "atomic.h"
+#include "smartdns/lib/atomic.h"
 #include <stdint.h>
 
 #ifdef __cplusplus

+ 1 - 1
src/fast_ping.h → src/include/smartdns/fast_ping.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

+ 1 - 1
src/http_parse.h → src/include/smartdns/http_parse.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

+ 0 - 0
src/include/art.h → src/include/smartdns/lib/art.h


+ 1 - 1
src/include/atomic.h → src/include/smartdns/lib/atomic.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

+ 1 - 1
src/include/bitmap.h → src/include/smartdns/lib/bitmap.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

+ 1 - 1
src/include/bitops.h → src/include/smartdns/lib/bitops.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

+ 1 - 1
src/include/conf.h → src/include/smartdns/lib/conf.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

+ 1 - 1
src/include/findbit.h → src/include/smartdns/lib/findbit.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

+ 1 - 1
src/include/gcc_builtin.h → src/include/smartdns/lib/gcc_builtin.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

+ 1 - 1
src/include/hash.h → src/include/smartdns/lib/hash.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

+ 1 - 1
src/include/hashtable.h → src/include/smartdns/lib/hashtable.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

+ 1 - 1
src/include/idna.h → src/include/smartdns/lib/idna.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

+ 1 - 1
src/include/jhash.h → src/include/smartdns/lib/jhash.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

+ 1 - 1
src/include/list.h → src/include/smartdns/lib/list.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

+ 0 - 0
src/include/nftset.h → src/include/smartdns/lib/nftset.h


+ 0 - 0
src/include/qpack.h → src/include/smartdns/lib/qpack.h


+ 0 - 0
src/include/radix.h → src/include/smartdns/lib/radix.h


+ 1 - 1
src/include/rbtree.h → src/include/smartdns/lib/rbtree.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

+ 1 - 1
src/include/stringutil.h → src/include/smartdns/lib/stringutil.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

+ 1 - 1
src/include/timer_wheel.h → src/include/smartdns/lib/timer_wheel.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

+ 1 - 1
src/proxy.h → src/include/smartdns/proxy.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

+ 8 - 9
src/smartdns.h → src/include/smartdns/smartdns.h

@@ -19,15 +19,14 @@
 #ifndef SMART_DNS_H
 #define SMART_DNS_H
 
-
-#include "dns_cache.h"
-#include "dns_client.h"
-#include "dns_conf.h"
-#include "dns_plugin.h"
-#include "dns_server.h"
-#include "fast_ping.h"
-#include "dns_stats.h"
-#include "util.h"
+#include "smartdns/dns_cache.h"
+#include "smartdns/dns_client.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/dns_plugin.h"
+#include "smartdns/dns_server.h"
+#include "smartdns/dns_stats.h"
+#include "smartdns/fast_ping.h"
+#include "smartdns/util.h"
 
 #ifdef __cplusplus
 extern "C" {

+ 1 - 1
src/timer.h → src/include/smartdns/timer.h

@@ -19,7 +19,7 @@
 #ifndef SMART_DNS_TIMER_H
 #define SMART_DNS_TIMER_H
 
-#include "timer_wheel.h"
+#include "smartdns/lib/timer_wheel.h"
 
 #ifdef __cplusplus
 extern "C" {

+ 1 - 1
src/tlog.h → src/include/smartdns/tlog.h

@@ -1,6 +1,6 @@
 /*
  * tinylog
- * Copyright (C) 2018-2025 Ruilin Peng (Nick) <[email protected]>
+ * Copyright (C) 2018-2024 Ruilin Peng (Nick) <[email protected]>
  * https://github.com/pymumu/tinylog
  */
 

+ 1 - 1
src/util.h → src/include/smartdns/util.h

@@ -19,7 +19,7 @@
 #ifndef SMART_DNS_UTIL_H
 #define SMART_DNS_UTIL_H
 
-#include "stringutil.h"
+#include "smartdns/lib/stringutil.h"
 #include <netdb.h>
 #include <time.h>
 

+ 1 - 1
src/lib/art.c

@@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <strings.h>
 #include <stdio.h>
 #include <assert.h>
-#include "art.h"
+#include "smartdns/lib/art.h"
 
 // #ifdef __i386__
 //     #include <emmintrin.h>

+ 2 - 2
src/lib/bitops.c

@@ -16,8 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#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

+ 1 - 1
src/lib/conf.c

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "conf.h"
+#include "smartdns/lib/conf.h"
 #include <errno.h>
 #include <getopt.h>
 #include <libgen.h>

+ 1 - 1
src/lib/idna.c

@@ -18,7 +18,7 @@
  */
 
 #define _GNU_SOURCE
-#include "idna.h"
+#include "smartdns/lib/idna.h"
 #include <limits.h>
 
 static unsigned _utf8_decode_slow(const char **p, const char *pe, unsigned a)

+ 3 - 3
src/lib/nftset.c

@@ -17,9 +17,9 @@
  */
 
 #define _GNU_SOURCE /* See feature_test_macros(7) */
-#include "nftset.h"
-#include "../dns_conf.h"
-#include "../tlog.h"
+#include "smartdns/lib/nftset.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/tlog.h"
 #include <errno.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter/nfnetlink.h>

+ 1 - 1
src/lib/qpack.c

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "qpack.h"
+#include "smartdns/lib/qpack.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,

+ 1 - 1
src/lib/radix.c

@@ -60,7 +60,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "radix.h"
+#include "smartdns/lib/radix.h"
 
 /* $Id: radix.c,v 1.17 2007/10/24 06:04:31 djm Exp $ */
 

+ 1 - 1
src/lib/rbtree.c

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "rbtree.h"
+#include "smartdns/lib/rbtree.h"
 #include <stdbool.h>
 
 static inline void rb_set_black(struct rb_node *rb)

+ 2 - 2
src/lib/timer_wheel.c

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "bitops.h"
+#include "smartdns/lib/bitops.h"
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -25,7 +25,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "timer_wheel.h"
+#include "smartdns/lib/timer_wheel.h"
 
 #define TVR_BITS 10
 #define TVN_BITS 6

+ 1 - 1
src/main.c

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "smartdns.h"
+#include "smartdns/smartdns.h"
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>

+ 7 - 7
src/proxy.c

@@ -19,13 +19,13 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "proxy.h"
-#include "dns_conf.h"
-#include "hashtable.h"
-#include "http_parse.h"
-#include "list.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/proxy.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/http_parse.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <errno.h>
 #include <pthread.h>

+ 9 - 9
src/smartdns.c

@@ -18,15 +18,15 @@
 
 #define _GNU_SOURCE
 
-#include "smartdns.h"
-
-#include "art.h"
-#include "atomic.h"
-#include "hashtable.h"
-#include "list.h"
-#include "rbtree.h"
-#include "timer.h"
-#include "tlog.h"
+#include "smartdns/smartdns.h"
+
+#include "smartdns/lib/art.h"
+#include "smartdns/lib/atomic.h"
+#include "smartdns/lib/hashtable.h"
+#include "smartdns/lib/list.h"
+#include "smartdns/lib/rbtree.h"
+#include "smartdns/timer.h"
+#include "smartdns/tlog.h"
 
 #include <errno.h>
 #include <fcntl.h>

+ 2 - 2
src/timer.c

@@ -16,8 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "timer.h"
-#include "timer_wheel.h"
+#include "smartdns/timer.h"
+#include "smartdns/lib/timer_wheel.h"
 
 static struct tw_base *dns_timer_base = NULL;
 

+ 1 - 1
src/tlog.c

@@ -6,7 +6,7 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "tlog.h"
+#include "smartdns/tlog.h"
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>

+ 3 - 3
src/util.c

@@ -20,9 +20,9 @@
 #define _GNU_SOURCE
 #include <stdio.h>
 #endif
-#include "dns_conf.h"
-#include "tlog.h"
-#include "util.h"
+#include "smartdns/dns_conf.h"
+#include "smartdns/tlog.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <ctype.h>
 #include <dirent.h>

+ 2 - 2
test/cases/test-address.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-bootstrap.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-cache.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"
@@ -27,7 +27,7 @@
 #include <sys/types.h>
 
 /* clang-format off */
-#include "dns_cache.h"
+#include "smartdns/dns_cache.h"
 /* clang-format on */
 
 class Cache : public ::testing::Test

+ 1 - 1
test/cases/test-client-rule.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 1 - 1
test/cases/test-cname.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-ddns.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-discard-block-ip.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-dns64.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-domain-rule.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-domain-set.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-dualstack.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-edns.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-group.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-hosts.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 3 - 4
test/cases/test-http.cc

@@ -17,11 +17,11 @@
  */
 
 #include "client.h"
-#include "dns.h"
-#include "http_parse.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/dns.h"
+#include "smartdns/http_parse.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 
@@ -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);

+ 2 - 2
test/cases/test-https.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-idna.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-ip-alias.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 1 - 1
test/cases/test-ip-rule.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-mdns.cc

@@ -17,8 +17,8 @@
  */
 
 #include "client.h"
-#include "dns.h"
-#include "dns_client.h"
+#include "smartdns/dns.h"
+#include "smartdns/dns_client.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 1 - 1
test/cases/test-nameserver.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 1 - 1
test/cases/test-perf.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-ping.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "fast_ping.h"
+#include "smartdns/fast_ping.h"
 #include "include/utils.h"
 #include "server.h"
-#include "tlog.h"
+#include "smartdns/tlog.h"
 #include "gtest/gtest.h"
 
 class Ping : public ::testing::Test

+ 2 - 2
test/cases/test-ptr.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-qtype-soa.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-rule.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-same-pending-query.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 1 - 1
test/cases/test-server.cc

@@ -17,7 +17,7 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
 #include "gtest/gtest.h"

+ 2 - 2
test/cases/test-speed-check.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-srv.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 2 - 2
test/cases/test-subnet.cc

@@ -17,10 +17,10 @@
  */
 
 #include "client.h"
-#include "dns.h"
+#include "smartdns/dns.h"
 #include "include/utils.h"
 #include "server.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include "gtest/gtest.h"
 #include <fstream>
 

+ 4 - 4
test/server.cc

@@ -17,11 +17,11 @@
  */
 
 #include "server.h"
-#include "dns_server.h"
-#include "fast_ping.h"
+#include "smartdns/dns_server.h"
+#include "smartdns/fast_ping.h"
 #include "include/utils.h"
-#include "smartdns.h"
-#include "util.h"
+#include "smartdns/smartdns.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <fstream>

+ 2 - 2
test/server.h

@@ -19,8 +19,8 @@
 #ifndef _SMARTDNS_SERVER_
 #define _SMARTDNS_SERVER_
 
-#include "dns.h"
-#include "fast_ping.h"
+#include "smartdns/dns.h"
+#include "smartdns/fast_ping.h"
 #include "include/utils.h"
 #include <functional>
 #include <string>

+ 1 - 1
test/utils.cc

@@ -1,5 +1,5 @@
 #include "include/utils.h"
-#include "util.h"
+#include "smartdns/util.h"
 #include <arpa/inet.h>
 #include <ifaddrs.h>
 #include <netinet/in.h>