Skip to content

Commit 3554c26

Browse files
vooon1715173329
authored andcommitted
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 <cnsztl@gmail.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
1 parent 6b370bd commit 3554c26

File tree

8 files changed

+230
-35
lines changed

8 files changed

+230
-35
lines changed

net/coredns/Config.in

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
if PACKAGE_coredns
2+
3+
config COREDNS_PLUGIN_GEOIP
4+
bool "GeoIP plugin"
5+
default n
6+
7+
config COREDNS_PLUGIN_TLS
8+
bool "TLS plugin"
9+
default y
10+
11+
config COREDNS_PLUGIN_QUIC
12+
bool "QUIC plugin"
13+
default n
14+
15+
config COREDNS_PLUGIN_ROUTE53
16+
bool "Route53 plugin"
17+
default n
18+
19+
config COREDNS_PLUGIN_AZURE
20+
bool "Azure plugin"
21+
default n
22+
23+
config COREDNS_PLUGIN_CLOUDDNS
24+
bool "CloudDNS plugin"
25+
default n
26+
27+
config COREDNS_PLUGIN_K8S_EXTERNAL
28+
bool "k8s_external plugin"
29+
default n
30+
31+
config COREDNS_PLUGIN_KUBERNETES
32+
bool "Kubernetes plugin"
33+
default n
34+
35+
config COREDNS_PLUGIN_ETCD
36+
bool "Etcd plugin"
37+
default n
38+
39+
config COREDNS_PLUGIN_GRPC
40+
bool "gRPC plugin"
41+
default n
42+
43+
config COREDNS_PLUGIN_ON
44+
bool "On event plugin"
45+
default n
46+
47+
config COREDNS_PLUGIN_NOMAD
48+
bool "Nomad plugin"
49+
default n
50+
51+
config COREDNS_PLUGIN_WGSD
52+
bool "WireGuard Service Discovery plugin"
53+
default y if PACKAGE_wgsd-coredns
54+
select COREDNS_REQUIRE_GO_GET
55+
help
56+
wgsd is a CoreDNS plugin that serves WireGuard peer information via DNS-SD (RFC6763) semantics.
57+
This enables use cases such as:
58+
59+
- Building a mesh of WireGuard peers from a central registry
60+
- Dynamic discovery of WireGuard Endpoint addressing (both IP address and port number)
61+
- NAT-to-NAT WireGuard connectivity where UDP hole punching is supported.
62+
63+
config COREDNS_PLUGIN_NETBOX
64+
bool "Netbox plugin"
65+
default n
66+
select COREDNS_REQUIRE_GO_GET
67+
68+
config COREDNS_PLUGIN_FANOUT
69+
bool "Fanout plugin"
70+
default n
71+
select COREDNS_REQUIRE_GO_GET
72+
73+
config COREDNS_REQUIRE_GO_GET
74+
bool
75+
default n
76+
help
77+
Custom plugins require `go get ./...` to pull dependencies.
78+
79+
endif

net/coredns/Makefile

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=coredns
4+
PKG_VERSION:=1.13.2
5+
PKG_RELEASE:=1
6+
7+
PKG_SOURCE_PROTO:=git
8+
PKG_SOURCE_URL:=https://github.com/coredns/coredns.git
9+
PKG_MIRROR_HASH:=096918cf04ed344d7c8e8763d82d01684a5cb647566a21608d0b034de565eec6
10+
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
11+
12+
PKG_LICENSE:=Apache-2.0
13+
PKG_LICENSE_FILES:=LICENSE
14+
PKG_MAINTAINER:=Vladimir Ermakov <vooon341@gmail.com>
15+
16+
PKG_BUILD_DEPENDS:=golang/host
17+
PKG_BUILD_PARALLEL:=1
18+
PKG_BUILD_FLAGS:=no-mips16
19+
20+
GO_PKG:=github.com/coredns/coredns
21+
GO_PKG_EXCLUDES:=test
22+
GO_PKG_LDFLAGS_X:= \
23+
github.com/coredns/coredns/coremain.GitCommit=v$(PKG_VERSION) \
24+
github.com/coredns/coredns/coremain.gitTag=v$(PKG_VERSION)
25+
26+
include $(INCLUDE_DIR)/package.mk
27+
include ../../lang/golang/golang-package.mk
28+
29+
define Package/coredns
30+
SECTION:=net
31+
CATEGORY:=Network
32+
SUBMENU:=IP Addresses and Names
33+
TITLE:=CoreDNS
34+
URL:=https://coredns.io
35+
DEPENDS:=$(GO_ARCH_DEPENDS) +COREDNS_PLUGIN_WGSD:kmod-wireguard
36+
MENU:=1
37+
endef
38+
39+
define Package/coredns/description
40+
CoreDNS is a fast and flexible DNS server.
41+
The key word here is flexible: with CoreDNS you are able to do what you want
42+
with your DNS data by utilizing plugins.
43+
endef
44+
45+
define Package/coredns/config
46+
source "$(SOURCE)/Config.in"
47+
endef
48+
49+
define Package/coredns/conffiles
50+
/etc/config/coredns
51+
/etc/Corefile
52+
/etc/coredns/
53+
endef
54+
55+
define configure-plugin
56+
$(SED) '/^$(2):/d' "$(PKG_BUILD_DIR)/plugin.cfg"
57+
ifeq ($(1),y)
58+
echo "$(2):$(3)" >> "$(PKG_BUILD_DIR)/plugin.cfg"
59+
endif
60+
endef
61+
62+
define Build/Configure
63+
$(call GoPackage/Build/Configure,$(1))
64+
65+
# NOTE: allow to disable unneded heavy plugin
66+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_GEOIP),geoip,geoip)
67+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_TLS),tls,tls)
68+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_QUIC),quic,quic)
69+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ROUTE53),route53,route53)
70+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_AZURE),azure,azure)
71+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_CLOUDDNS),clouddns,clouddns)
72+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_K8S_EXTERNAL),k8s_external,k8s_external)
73+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_KUBERNETES),kubernetes,kubernetes)
74+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ETCD),etcd,etcd)
75+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_GRPC),grpc,grpc)
76+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_ON),on,github.com/coredns/caddy/onevent)
77+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_NOMAD),nomad,nomad)
78+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_WGSD),wgsd,github.com/jwhited/wgsd)
79+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_NETBOX),netbox,github.com/oz123/coredns-netbox-plugin)
80+
$(call configure-plugin,$(CONFIG_COREDNS_PLUGIN_FANOUT),fanout,github.com/networkservicemesh/fanout)
81+
82+
cd $(PKG_BUILD_DIR); \
83+
$(GO_GENERAL_BUILD_CONFIG_VARS) \
84+
$(GO_PKG_BUILD_CONFIG_VARS) \
85+
go generate coredns.go
86+
87+
# NOTE: custom plugins needs go get to pull new dependencies
88+
ifeq ($(CONFIG_COREDNS_REQUIRE_GO_GET),y)
89+
cd $(PKG_BUILD_DIR); \
90+
$(GO_GENERAL_BUILD_CONFIG_VARS) \
91+
$(GO_PKG_BUILD_CONFIG_VARS) \
92+
go get ./...
93+
endif
94+
95+
endef
96+
97+
define Package/coredns/install
98+
$(call GoPackage/Package/Install/Bin,$(1))
99+
100+
$(INSTALL_DIR) $(1)/etc/
101+
$(INSTALL_CONF) $(CURDIR)/files/Corefile $(1)/etc/Corefile
102+
$(INSTALL_DIR) $(1)/etc/config/
103+
$(INSTALL_CONF) $(CURDIR)/files/coredns.conf $(1)/etc/config/coredns
104+
$(INSTALL_DIR) $(1)/etc/init.d/
105+
$(INSTALL_BIN) $(CURDIR)/files/coredns.init $(1)/etc/init.d/coredns
106+
107+
$(INSTALL_DIR) $(1)/etc/coredns/zones/
108+
endef
109+
110+
$(eval $(call BuildPackage,coredns))

net/coredns/files/Corefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.:5353 {
2+
log
3+
#whoami
4+
#wgsd coredns.lan. vpn_wg
5+
}

net/coredns/files/coredns.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config daemon 'daemon'
2+
option config /etc/Corefile
3+
list ro_mount /etc/coredns/zones

net/coredns/files/coredns.init

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh /etc/rc.common
2+
3+
START=99
4+
5+
USE_PROCD=1
6+
PROG=/usr/bin/coredns
7+
CONF=coredns
8+
9+
start_service() {
10+
local corefile
11+
12+
config_load "$CONF"
13+
config_get corefile daemon config /etc/Corefile
14+
15+
procd_open_instance
16+
17+
procd_add_jail coredns log procfs sysfs
18+
procd_add_jail_mount /etc/TZ
19+
procd_add_jail_mount /etc/ssl/certs
20+
procd_add_jail_mount "$corefile"
21+
config_list_foreach daemon ro_mount procd_add_jail_mount
22+
23+
procd_set_param command "$PROG" -conf "$corefile"
24+
procd_set_param respawn
25+
procd_set_param stdout 1
26+
procd_set_param stderr 1
27+
28+
procd_close_instance
29+
}

net/wgsd/Makefile

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=wgsd
44
PKG_VERSION:=0.3.6
5-
PKG_RELEASE:=1
5+
PKG_RELEASE:=2
66

77
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
88
PKG_SOURCE_URL:=https://codeload.github.com/jwhited/wgsd/tar.gz/v$(PKG_VERSION)?
@@ -17,7 +17,7 @@ PKG_BUILD_PARALLEL:=1
1717
PKG_BUILD_FLAGS:=no-mips16
1818

1919
GO_PKG:=github.com/jwhited/wgsd
20-
GO_PKG_EXCLUDES:=test
20+
GO_PKG_EXCLUDES:=cmd/coredns
2121

2222
include $(INCLUDE_DIR)/package.mk
2323
include ../../lang/golang/golang-package.mk
@@ -34,6 +34,7 @@ endef
3434
define Package/wgsd-coredns
3535
$(call Package/wgsd/Default)
3636
TITLE+= DNS-SD server
37+
DEPENDS:=+coredns +@COREDNS_PLUGIN_WGSD
3738
endef
3839

3940
define Package/wgsd-client
@@ -53,7 +54,7 @@ endef
5354
define Package/wgsd-coredns/description
5455
$(call Package/wgsd/Default/description)
5556

56-
CoreDNS binary.
57+
Transitional package to CoreDNS with wgsd plugin enabled.
5758
endef
5859

5960
define Package/wgsd-client/description
@@ -62,21 +63,6 @@ define Package/wgsd-client/description
6263
Client binary.
6364
endef
6465

65-
define Package/wgsd-coredns/conffiles
66-
/etc/Corefile
67-
endef
68-
69-
define Package/wgsd-coredns/install
70-
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
71-
$(INSTALL_DIR) $(1)/usr/bin
72-
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/coredns $(1)/usr/bin/wgsd-coredns
73-
74-
$(INSTALL_DIR) $(1)/etc/
75-
$(INSTALL_CONF) $(CURDIR)/files/Corefile $(1)/etc/Corefile
76-
$(INSTALL_DIR) $(1)/etc/init.d/
77-
$(INSTALL_BIN) $(CURDIR)/files/wgsd-coredns.init $(1)/etc/init.d/wgsd-coredns
78-
endef
79-
8066
define Package/wgsd-client/install
8167
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
8268
$(INSTALL_DIR) $(1)/usr/bin

net/wgsd/files/Corefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

net/wgsd/files/wgsd-coredns.init

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)