From 3554c264f5af144aa7911d17fc61c720f8c2b025 Mon Sep 17 00:00:00 2001 From: Vladimir Ermakov Date: Sat, 5 Jul 2025 16:38:38 +0200 Subject: [PATCH] coredns: replace wgsd-coredns to full 1.13.2 - Add coredns package 1.13.2 - Make wgsd-coredns package transitional to coredns with wgsd plugin enabled - Make coredns plugin list configurable, disable heavy plugins by default and add wgsd plugin - Place the service into ujail - Add netbox plugin Co-authored-by: Tianling Shen Signed-off-by: Vladimir Ermakov --- net/coredns/Config.in | 79 ++++++++++++++++++++++ net/coredns/Makefile | 110 +++++++++++++++++++++++++++++++ net/coredns/files/Corefile | 5 ++ net/coredns/files/coredns.conf | 3 + net/coredns/files/coredns.init | 29 ++++++++ net/wgsd/Makefile | 22 ++----- net/wgsd/files/Corefile | 5 -- net/wgsd/files/wgsd-coredns.init | 12 ---- 8 files changed, 230 insertions(+), 35 deletions(-) create mode 100644 net/coredns/Config.in create mode 100644 net/coredns/Makefile create mode 100644 net/coredns/files/Corefile create mode 100644 net/coredns/files/coredns.conf create mode 100644 net/coredns/files/coredns.init delete mode 100644 net/wgsd/files/Corefile delete mode 100644 net/wgsd/files/wgsd-coredns.init diff --git a/net/coredns/Config.in b/net/coredns/Config.in new file mode 100644 index 0000000000..c37e66cee8 --- /dev/null +++ b/net/coredns/Config.in @@ -0,0 +1,79 @@ +if PACKAGE_coredns + +config COREDNS_PLUGIN_GEOIP + bool "GeoIP plugin" + default n + +config COREDNS_PLUGIN_TLS + bool "TLS plugin" + default y + +config COREDNS_PLUGIN_QUIC + bool "QUIC plugin" + default n + +config COREDNS_PLUGIN_ROUTE53 + bool "Route53 plugin" + default n + +config COREDNS_PLUGIN_AZURE + bool "Azure plugin" + default n + +config COREDNS_PLUGIN_CLOUDDNS + bool "CloudDNS plugin" + default n + +config COREDNS_PLUGIN_K8S_EXTERNAL + bool "k8s_external plugin" + default n + +config COREDNS_PLUGIN_KUBERNETES + bool "Kubernetes plugin" + default n + +config COREDNS_PLUGIN_ETCD + bool "Etcd plugin" + default n + +config COREDNS_PLUGIN_GRPC + bool "gRPC plugin" + default n + +config COREDNS_PLUGIN_ON + bool "On event plugin" + default n + +config COREDNS_PLUGIN_NOMAD + bool "Nomad plugin" + default n + +config COREDNS_PLUGIN_WGSD + bool "WireGuard Service Discovery plugin" + default y if PACKAGE_wgsd-coredns + select COREDNS_REQUIRE_GO_GET + help + wgsd is a CoreDNS plugin that serves WireGuard peer information via DNS-SD (RFC6763) semantics. + This enables use cases such as: + + - Building a mesh of WireGuard peers from a central registry + - Dynamic discovery of WireGuard Endpoint addressing (both IP address and port number) + - NAT-to-NAT WireGuard connectivity where UDP hole punching is supported. + +config COREDNS_PLUGIN_NETBOX + bool "Netbox plugin" + default n + select COREDNS_REQUIRE_GO_GET + +config COREDNS_PLUGIN_FANOUT + bool "Fanout plugin" + default n + select COREDNS_REQUIRE_GO_GET + +config COREDNS_REQUIRE_GO_GET + bool + default n + help + Custom plugins require `go get ./...` to pull dependencies. + +endif diff --git a/net/coredns/Makefile b/net/coredns/Makefile new file mode 100644 index 0000000000..573d320a71 --- /dev/null +++ b/net/coredns/Makefile @@ -0,0 +1,110 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=coredns +PKG_VERSION:=1.13.2 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/coredns/coredns.git +PKG_MIRROR_HASH:=096918cf04ed344d7c8e8763d82d01684a5cb647566a21608d0b034de565eec6 +PKG_SOURCE_VERSION:=v$(PKG_VERSION) + +PKG_LICENSE:=Apache-2.0 +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=Vladimir Ermakov + +PKG_BUILD_DEPENDS:=golang/host +PKG_BUILD_PARALLEL:=1 +PKG_BUILD_FLAGS:=no-mips16 + +GO_PKG:=github.com/coredns/coredns +GO_PKG_EXCLUDES:=test +GO_PKG_LDFLAGS_X:= \ + github.com/coredns/coredns/coremain.GitCommit=v$(PKG_VERSION) \ + github.com/coredns/coredns/coremain.gitTag=v$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk +include ../../lang/golang/golang-package.mk + +define Package/coredns + SECTION:=net + CATEGORY:=Network + SUBMENU:=IP Addresses and Names + TITLE:=CoreDNS + URL:=https://coredns.io + DEPENDS:=$(GO_ARCH_DEPENDS) +COREDNS_PLUGIN_WGSD:kmod-wireguard + MENU:=1 +endef + +define Package/coredns/description + CoreDNS is a fast and flexible DNS server. + The key word here is flexible: with CoreDNS you are able to do what you want + with your DNS data by utilizing plugins. +endef + +define Package/coredns/config + source "$(SOURCE)/Config.in" +endef + +define Package/coredns/conffiles +/etc/config/coredns +/etc/Corefile +/etc/coredns/ +endef + +define configure-plugin + $(SED) '/^$(2):/d' "$(PKG_BUILD_DIR)/plugin.cfg" +ifeq ($(1),y) + echo "$(2):$(3)" >> "$(PKG_BUILD_DIR)/plugin.cfg" +endif +endef + +define Build/Configure + $(call GoPackage/Build/Configure,$(1)) + + # NOTE: allow to disable unneded heavy plugin + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_GEOIP),geoip,geoip) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_TLS),tls,tls) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_QUIC),quic,quic) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ROUTE53),route53,route53) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_AZURE),azure,azure) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_CLOUDDNS),clouddns,clouddns) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_K8S_EXTERNAL),k8s_external,k8s_external) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_KUBERNETES),kubernetes,kubernetes) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ETCD),etcd,etcd) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_GRPC),grpc,grpc) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ON),on,github.com/coredns/caddy/onevent) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_NOMAD),nomad,nomad) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_WGSD),wgsd,github.com/jwhited/wgsd) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_NETBOX),netbox,github.com/oz123/coredns-netbox-plugin) + $(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_FANOUT),fanout,github.com/networkservicemesh/fanout) + + cd $(PKG_BUILD_DIR); \ + $(GO_GENERAL_BUILD_CONFIG_VARS) \ + $(GO_PKG_BUILD_CONFIG_VARS) \ + go generate coredns.go + + # NOTE: custom plugins needs go get to pull new dependencies +ifeq ($(CONFIG_COREDNS_REQUIRE_GO_GET),y) + cd $(PKG_BUILD_DIR); \ + $(GO_GENERAL_BUILD_CONFIG_VARS) \ + $(GO_PKG_BUILD_CONFIG_VARS) \ + go get ./... +endif + +endef + +define Package/coredns/install + $(call GoPackage/Package/Install/Bin,$(1)) + + $(INSTALL_DIR) $(1)/etc/ + $(INSTALL_CONF) $(CURDIR)/files/Corefile $(1)/etc/Corefile + $(INSTALL_DIR) $(1)/etc/config/ + $(INSTALL_CONF) $(CURDIR)/files/coredns.conf $(1)/etc/config/coredns + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_BIN) $(CURDIR)/files/coredns.init $(1)/etc/init.d/coredns + + $(INSTALL_DIR) $(1)/etc/coredns/zones/ +endef + +$(eval $(call BuildPackage,coredns)) diff --git a/net/coredns/files/Corefile b/net/coredns/files/Corefile new file mode 100644 index 0000000000..103e4d1db8 --- /dev/null +++ b/net/coredns/files/Corefile @@ -0,0 +1,5 @@ +.:5353 { + log + #whoami + #wgsd coredns.lan. vpn_wg +} diff --git a/net/coredns/files/coredns.conf b/net/coredns/files/coredns.conf new file mode 100644 index 0000000000..d35948790d --- /dev/null +++ b/net/coredns/files/coredns.conf @@ -0,0 +1,3 @@ +config daemon 'daemon' + option config /etc/Corefile + list ro_mount /etc/coredns/zones diff --git a/net/coredns/files/coredns.init b/net/coredns/files/coredns.init new file mode 100644 index 0000000000..1c4256d264 --- /dev/null +++ b/net/coredns/files/coredns.init @@ -0,0 +1,29 @@ +#!/bin/sh /etc/rc.common + +START=99 + +USE_PROCD=1 +PROG=/usr/bin/coredns +CONF=coredns + +start_service() { + local corefile + + config_load "$CONF" + config_get corefile daemon config /etc/Corefile + + procd_open_instance + + procd_add_jail coredns log procfs sysfs + procd_add_jail_mount /etc/TZ + procd_add_jail_mount /etc/ssl/certs + procd_add_jail_mount "$corefile" + config_list_foreach daemon ro_mount procd_add_jail_mount + + procd_set_param command "$PROG" -conf "$corefile" + procd_set_param respawn + procd_set_param stdout 1 + procd_set_param stderr 1 + + procd_close_instance +} diff --git a/net/wgsd/Makefile b/net/wgsd/Makefile index d6d49fecec..75d1a6f931 100644 --- a/net/wgsd/Makefile +++ b/net/wgsd/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wgsd PKG_VERSION:=0.3.6 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/jwhited/wgsd/tar.gz/v$(PKG_VERSION)? @@ -17,7 +17,7 @@ PKG_BUILD_PARALLEL:=1 PKG_BUILD_FLAGS:=no-mips16 GO_PKG:=github.com/jwhited/wgsd -GO_PKG_EXCLUDES:=test +GO_PKG_EXCLUDES:=cmd/coredns include $(INCLUDE_DIR)/package.mk include ../../lang/golang/golang-package.mk @@ -34,6 +34,7 @@ endef define Package/wgsd-coredns $(call Package/wgsd/Default) TITLE+= DNS-SD server + DEPENDS:=+coredns +@COREDNS_PLUGIN_WGSD endef define Package/wgsd-client @@ -53,7 +54,7 @@ endef define Package/wgsd-coredns/description $(call Package/wgsd/Default/description) - CoreDNS binary. + Transitional package to CoreDNS with wgsd plugin enabled. endef define Package/wgsd-client/description @@ -62,21 +63,6 @@ define Package/wgsd-client/description Client binary. endef -define Package/wgsd-coredns/conffiles -/etc/Corefile -endef - -define Package/wgsd-coredns/install - $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/coredns $(1)/usr/bin/wgsd-coredns - - $(INSTALL_DIR) $(1)/etc/ - $(INSTALL_CONF) $(CURDIR)/files/Corefile $(1)/etc/Corefile - $(INSTALL_DIR) $(1)/etc/init.d/ - $(INSTALL_BIN) $(CURDIR)/files/wgsd-coredns.init $(1)/etc/init.d/wgsd-coredns -endef - define Package/wgsd-client/install $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) $(INSTALL_DIR) $(1)/usr/bin diff --git a/net/wgsd/files/Corefile b/net/wgsd/files/Corefile deleted file mode 100644 index 0dee396ab6..0000000000 --- a/net/wgsd/files/Corefile +++ /dev/null @@ -1,5 +0,0 @@ -.:5353 { - log - #whoami - wgsd coredns.lan. vpn_wg -} diff --git a/net/wgsd/files/wgsd-coredns.init b/net/wgsd/files/wgsd-coredns.init deleted file mode 100644 index 59421444df..0000000000 --- a/net/wgsd/files/wgsd-coredns.init +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=99 - -USE_PROCD=1 -PROG=/usr/bin/wgsd-coredns - -start_service() { - procd_open_instance - procd_set_param command "$PROG" -conf /etc/Corefile - procd_close_instance -} -- 2.30.2