├── Makefile └── ReadMe.md /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018-2023 Nick Peng (pymumu@gmail.com) 3 | # This is free software, licensed under the GNU General Public License v3. 4 | # 5 | 6 | include $(TOPDIR)/rules.mk 7 | 8 | PKG_NAME:=smartdns 9 | PKG_VERSION:=1.2025.46.2 10 | PKG_RELEASE:=3 11 | 12 | PKG_SOURCE_PROTO:=git 13 | PKG_SOURCE_URL:=https://www.github.com/pymumu/smartdns.git 14 | PKG_SOURCE_VERSION:=64fc9f20fba0e14cb118fe7f145557971cafd858 15 | PKG_MIRROR_HASH:=cbe29523c543ec1bbfab25d6a5e0c10a8d34c64414d32c37b83de49e17583e01 16 | 17 | SMARTDNS_WEBUI_VERSION:=1.0.0 18 | SMAETDNS_WEBUI_SOURCE_PROTO:=git 19 | SMARTDNS_WEBUI_SOURCE_URL:=https://github.com/pymumu/smartdns-webui.git 20 | SMARTDNS_WEBUI_SOURCE_VERSION:=35cbf4a1940f5dd32670c69bd5cc02437ad073e7 21 | SMARTDNS_WEBUI_FILE:=smartdns-webui-$(SMARTDNS_WEBUI_VERSION).tar.gz 22 | 23 | PKG_MAINTAINER:=Nick Peng 24 | PKG_LICENSE:=GPL-3.0-or-later 25 | PKG_LICENSE_FILES:=LICENSE 26 | 27 | PKG_BUILD_PARALLEL:=1 28 | 29 | # node compile is slow, so do not use it, doownload node manually. 30 | # PACKAGE_smartdns-ui:node/host 31 | PKG_BUILD_DEPENDS:=PACKAGE_smartdns-ui:rust/host 32 | 33 | include ../../lang/rust/rust-package.mk 34 | include $(INCLUDE_DIR)/package.mk 35 | 36 | MAKE_VARS += VER=$(PKG_VERSION) 37 | MAKE_PATH:=src 38 | 39 | define Package/smartdns/default 40 | SECTION:=net 41 | CATEGORY:=Network 42 | SUBMENU:=IP Addresses and Names 43 | URL:=https://www.github.com/pymumu/smartdns/ 44 | endef 45 | 46 | define Package/smartdns 47 | $(Package/smartdns/default) 48 | TITLE:=smartdns server 49 | DEPENDS:=+libpthread +libopenssl +libatomic 50 | endef 51 | 52 | define Package/smartdns/description 53 | SmartDNS is a local DNS server which accepts DNS query requests from local network clients, 54 | gets DNS query results from multiple upstream DNS servers concurrently, and returns the fastest IP to clients. 55 | Unlike dnsmasq's all-servers, smartdns returns the fastest IP, and encrypt DNS queries with DoT or DoH. 56 | endef 57 | 58 | define Package/smartdns/conffiles 59 | /etc/config/smartdns 60 | /etc/smartdns/address.conf 61 | /etc/smartdns/blacklist-ip.conf 62 | /etc/smartdns/custom.conf 63 | /etc/smartdns/domain-block.list 64 | /etc/smartdns/domain-forwarding.list 65 | endef 66 | 67 | define Package/smartdns/install 68 | $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d 69 | $(INSTALL_DIR) $(1)/etc/smartdns $(1)/etc/smartdns/domain-set $(1)/etc/smartdns/conf.d/ 70 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smartdns $(1)/usr/sbin/smartdns 71 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/package/openwrt/files/etc/init.d/smartdns $(1)/etc/init.d/smartdns 72 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/address.conf $(1)/etc/smartdns/address.conf 73 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/blacklist-ip.conf $(1)/etc/smartdns/blacklist-ip.conf 74 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/custom.conf $(1)/etc/smartdns/custom.conf 75 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/files/etc/config/smartdns $(1)/etc/config/smartdns 76 | endef 77 | 78 | define Package/smartdns-ui 79 | $(Package/smartdns/default) 80 | TITLE:=smartdns dashboard 81 | DEPENDS:=+smartdns $(RUST_ARCH_DEPENDS) 82 | endef 83 | 84 | define Package/smartdns-ui/description 85 | A dashboard ui for smartdns server. 86 | endef 87 | 88 | define Package/smartdns-ui/conffiles 89 | /etc/config/smartdns 90 | endef 91 | 92 | define Package/smartdns-ui/install 93 | $(INSTALL_DIR) $(1)/usr/lib 94 | $(INSTALL_DIR) $(1)/etc/smartdns/conf.d/ 95 | $(INSTALL_DIR) $(1)/usr/share/smartdns/wwwroot 96 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/plugin/smartdns-ui/target/libsmartdns_ui.so $(1)/usr/lib/libsmartdns_ui.so 97 | $(CP) $(PKG_BUILD_DIR)/smartdns-webui/out/* $(1)/usr/share/smartdns/wwwroot 98 | endef 99 | 100 | define Build/Compile/smartdns-webui 101 | which npm || (echo "npm not found, please install npm first" && exit 1) 102 | npm install --prefix $(PKG_BUILD_DIR)/smartdns-webui/ 103 | npm run build --prefix $(PKG_BUILD_DIR)/smartdns-webui/ 104 | endef 105 | 106 | define Build/Compile/smartdns-ui 107 | cargo install --force --locked bindgen-cli 108 | CARGO_BUILD_ARGS="$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") --profile $(CARGO_PKG_PROFILE)" 109 | +$(CARGO_PKG_VARS) CARGO_BUILD_ARGS="$(CARGO_BUILD_ARGS)" CC=$(TARGET_CC) \ 110 | PATH="$$(PATH):$(CARGO_HOME)/bin" \ 111 | make -C $(PKG_BUILD_DIR)/plugin/smartdns-ui 112 | endef 113 | 114 | define Download/smartdns-webui 115 | FILE:=$(SMARTDNS_WEBUI_FILE) 116 | PROTO:=$(SMAETDNS_WEBUI_SOURCE_PROTO) 117 | URL:=$(SMARTDNS_WEBUI_SOURCE_URL) 118 | MIRROR_HASH:=b3f4f73b746ee169708f6504c52b33d9bbeb7c269b731bd7de4f61d0ad212d74 119 | VERSION:=$(SMARTDNS_WEBUI_SOURCE_VERSION) 120 | HASH:=$(SMARTDNS_WEBUI_HASH) 121 | SUBDIR:=smartdns-webui 122 | endef 123 | $(eval $(call Download,smartdns-webui)) 124 | 125 | ifdef CONFIG_PACKAGE_smartdns-ui 126 | define Build/Prepare 127 | $(call Build/Prepare/Default) 128 | $(TAR) -C $(PKG_BUILD_DIR)/ -xf $(DL_DIR)/$(SMARTDNS_WEBUI_FILE) 129 | endef 130 | endif 131 | 132 | define Build/Compile 133 | $(call Build/Compile/Default,smartdns) 134 | ifdef CONFIG_PACKAGE_smartdns-ui 135 | $(call Build/Compile/smartdns-ui) 136 | $(call Build/Compile/smartdns-webui) 137 | endif 138 | endef 139 | 140 | $(eval $(call BuildPackage,smartdns)) 141 | $(eval $(call RustBinPackage,smartdns-ui)) 142 | $(eval $(call BuildPackage,smartdns-ui)) 143 | 144 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # openwrt-smartdns 2 | 3 | 此仓库为smartdns独立仓库,为单独编译使用,可配合luci-app-smartdns一起使用。 4 | luci界面:[luci-app-smartdns](https://github.com/pymumu/luci-app-smartdns) 5 | 6 | ## 使用方式 7 | 8 | 注意:如下命令操作路径为openwrt源代码所在目录。 9 | 10 | ### 复制仓库中的文件到如下目录,并执行安装 11 | 12 | ```shell 13 | ./feeds/packages/net/smartdns/ 14 | ./scripts/feeds install package -a 15 | ``` 16 | 17 | ### 执行openwrt配置, 选中smartdns 18 | 19 | 执行编译配置: 20 | 21 | ```shell 22 | make menuconfig 23 | ``` 24 | 25 | * 选择路径: 26 | 27 | Network > smartdns 28 | Network > smartdns-ui 29 | 30 | * 编译模式: 31 | 32 | 1. 若编译独立软件包,选择编译模式为`M` 33 | 1. 若编译到固件中,选择编译模式为`*` 34 | 1. UI为单独安装包,需要选择后才能编译。 35 | 36 | ### 执行openwrt编译 37 | 38 | 仅编译软件包: 39 | 40 | ```shell 41 | make package/feeds/packages/smartdns/compile 42 | ``` 43 | 44 | 编译固件以及软件包。 45 | 46 | ```shell 47 | make -j8 48 | ``` 49 | 50 | ## 懒人脚本 51 | 52 | 也可可执行如下命令,一次性下载smartdns。 53 | 54 | 下列命令可采用复制粘贴的方式执行, 注意目录需要在openwrt源代码目录中。 55 | 56 | ```shell 57 | WORKINGDIR="`pwd`/feeds/packages/net/smartdns" 58 | mkdir $WORKINGDIR -p 59 | rm $WORKINGDIR/* -fr 60 | wget https://github.com/pymumu/openwrt-smartdns/archive/master.zip -O $WORKINGDIR/master.zip 61 | unzip $WORKINGDIR/master.zip -d $WORKINGDIR 62 | mv $WORKINGDIR/openwrt-smartdns-master/* $WORKINGDIR/ 63 | rmdir $WORKINGDIR/openwrt-smartdns-master 64 | rm $WORKINGDIR/master.zip 65 | 66 | ./scripts/feeds install -a 67 | make menuconfig 68 | 69 | ``` 70 | 71 | 上述命令完成后,可执行编译。 72 | --------------------------------------------------------------------------------