-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This package provides a secondary dnsmasq instance on port 54 which resolves everything over the WAN interface.
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=gluon-wan-dnsmasq | ||
PKG_VERSION:=1 | ||
|
||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/gluon-wan-dnsmasq | ||
SECTION:=gluon | ||
CATEGORY:=Gluon | ||
TITLE:=Support for a secondary DNS server using the WAN interface | ||
DEPENDS:=+gluon-core +dnsmasq | ||
endef | ||
|
||
define Package/gluon-wan-dnsmasq/description | ||
Gluon community wifi mesh firmware framework: Support for a secondary DNS server using the WAN interface | ||
endef | ||
|
||
define Build/Prepare | ||
mkdir -p $(PKG_BUILD_DIR) | ||
endef | ||
|
||
define Build/Configure | ||
endef | ||
|
||
define Build/Compile | ||
endef | ||
|
||
define Package/gluon-wan-dnsmasq/install | ||
$(CP) ./files/* $(1)/ | ||
endef | ||
|
||
$(eval $(call BuildPackage,gluon-wan-dnsmasq)) |
3 changes: 3 additions & 0 deletions
3
gluon/gluon-wan-dnsmasq/files/etc/hotplug.d/iface/50-gluon-wan-dnsmasq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if [ "$INTERFACE" = 'wan' -o "$INTERFACE" = 'wan6' ]; then | ||
/lib/gluon/wan-dnsmasq/update.lua | ||
fi |
26 changes: 26 additions & 0 deletions
26
gluon/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh /etc/rc.common | ||
|
||
START=60 | ||
|
||
SERVICE_NAME=gluon-wan-dnsmasq | ||
SERVICE_USE_PID=1 | ||
SERVICE_PID_FILE=/var/run/gluon-wan-dnsmasq.pid | ||
|
||
|
||
PORT=54 | ||
PACKET_MARK=1 | ||
|
||
RESOLV_CONF_DIR=/var/gluon/wan-dnsmasq | ||
RESOLV_CONF=$RESOLV_CONF_DIR/resolv.conf | ||
|
||
|
||
start() { | ||
mkdir -p $RESOLV_CONF_DIR | ||
touch $RESOLV_CONF | ||
|
||
service_start /usr/sbin/dnsmasq -x $SERVICE_PID_FILE -u root -i lo -p $PORT --packet-mark=$PACKET_MARK -h -r $RESOLV_CONF | ||
} | ||
|
||
stop() { | ||
service_stop /usr/sbin/dnsmasq | ||
} |
25 changes: 25 additions & 0 deletions
25
gluon/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/lua | ||
|
||
local RESOLV_CONF_DIR = '/var/gluon/wan-dnsmasq' | ||
local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf' | ||
|
||
|
||
local ubus = require('ubus').connect() | ||
local fs = require 'nixio.fs' | ||
|
||
|
||
local function write_servers(f, iface) | ||
local servers = ubus:call('network.interface.' .. iface, 'status', {}).inactive['dns-server'] | ||
for _, server in ipairs(servers) do | ||
f:write('nameserver ', server, '\n') | ||
end | ||
end | ||
|
||
|
||
fs.mkdirr(RESOLV_CONF_DIR) | ||
local f = io.open(RESOLV_CONF, 'w+') | ||
|
||
pcall(write_servers, f, 'wan6') | ||
pcall(write_servers, f, 'wan') | ||
|
||
f:close() |