Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: Add UCI integration, better defaults #25398

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions net/dnsdist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=dnsdist
PKG_VERSION:=1.9.8
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://downloads.powerdns.com/releases/
Expand Down Expand Up @@ -35,7 +35,11 @@ define Package/dnsdist/Default
+libatomic \
+libcap \
+libstdcpp \
@HAS_LUAJIT_ARCH +luajit
+libubox-lua \
+libubus-lua \
+libuci-lua \
@HAS_LUAJIT_ARCH +luajit \
+luafilesystem
URL:=https://dnsdist.org/
VARIANT:=$(1)
PROVIDES:=dnsdist
Expand All @@ -62,11 +66,24 @@ define Package/dnsdist/install/Default
$(INSTALL_DIR) $(1)/etc/dnsdist.conf.d
$(INSTALL_CONF) ./files/dnsdist.conf $(1)/etc/dnsdist.conf
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/dnsdist.config $(1)/etc/config/dnsdist
$(INSTALL_CONF) ./files/sample.uci.conf $(1)/etc/config/dnsdist
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/dnsdist.init $(1)/etc/init.d/dnsdist
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dnsdist $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/share/acl.d
$(INSTALL_DATA) ./files/dnsdist_acl.json $(1)/usr/share/acl.d
$(INSTALL_DIR) $(1)/usr/share/lua/dnsdist
$(INSTALL_DIR) $(1)/usr/share/dnsdist
$(CP) ./files/common.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/configuration.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/local-domains.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/os.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/dnsdist-odhcpd.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/start.lua $(1)/usr/share/lua/dnsdist/
$(CP) ./files/sample.uci.conf $(1)/usr/share/dnsdist/sample.uci.conf
$(CP) ./files/dnsdist.config $(1)/usr/share/dnsdist/simple.uci.conf
$(INSTALL_BIN) ./files/diag.sh $(1)/usr/share/dnsdist/diag.sh
endef

define Package/dnsdist
Expand Down
55 changes: 55 additions & 0 deletions net/dnsdist/files/common.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
local M = {}

M.poolName = ''
M.interfaceTagName = 'itf'

local maintenanceHookRegistrations = {}
local configurationParsedHookRegistrations = {}
local configurationDoneHookRegistrations = {}

local string_find = string.find

function M.addrIsIPv6(addr)
return string_find(addr, ':')
end

local function insertIntoTableIfNotExists(tab, value)
for _, v in ipairs(tab) do
if v == value then
return
end
end
table.insert(tab, value)
end

function M.registerMaintenanceHook(callback)
insertIntoTableIfNotExists(maintenanceHookRegistrations, callback)
end

function M.registerConfigurationParsedHook(callback)
insertIntoTableIfNotExists(configurationParsedHookRegistrations, callback)
end

function M.registerConfigurationDoneHook(callback)
insertIntoTableIfNotExists(configurationDoneHookRegistrations, callback)
end

function M.runMaintenanceHooks()
for _, callback in ipairs(maintenanceHookRegistrations) do
callback()
end
end

function M.runConfigurationParsedHooks(config, cursor)
for _, callback in ipairs(configurationParsedHookRegistrations) do
callback(config, cursor)
end
end

function M.runConfigurationDoneHooks(config)
for _, callback in ipairs(configurationDoneHookRegistrations) do
callback(config)
end
end

return M
Loading
Loading