Skip to content

Commit

Permalink
Merge pull request #64 from thetoster/dev
Browse files Browse the repository at this point in the history
add totd deamon
  • Loading branch information
Abhijit A. Mahajani authored Aug 25, 2016
2 parents 08cea48 + 36be2f8 commit 426b117
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
61 changes: 61 additions & 0 deletions totd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=totd
PKG_VERSION:=1.5.3
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/fwdillema/totd.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=$(PKG_VERSION)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk

define Package/totd
SECTION:=ipv6
CATEGORY:=IPv6
DEPENDS:=@IPV6 +tayga
TITLE:=Small DNS proxy that supports IPv6/IPv4 record translation
URL:=http://www.dillema.net/software/totd.html
endef

define Package/totd/description
totd is a small DNS proxy nameserver which supports IPv6 and enable IPv6
only sites to access IPv4 sites by using some translation mechanism such
as NAT-PT, KAME faith, etc...
endef

define Package/totd/conffiles
/etc/totd.conf
endef

# uses GNU configure

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
DESTDIR="$(PKG_INSTALL_DIR)" \
CC="$(TARGET_CC)" \
all
endef

define Package/totd/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/
$(INSTALL_CONF) ./files/totd.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/totd.init $(1)/etc/init.d/totd
$(INSTALL_BIN) ./files/totd_configure_dhcp $(1)/etc/init.d/
endef

$(eval $(call BuildPackage,totd))

21 changes: 21 additions & 0 deletions totd/files/totd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; Totd sample configuration file
; you can have multiple forwarders, totd will always prefer
; forwarders listed early and only use forwarders listed later
; if the first ones are unresponsive.
forwarder 8.8.8.8 port 53

; you can have multiple prefixes or even no prefixes at all
; totd uses them in round-robin fashion
prefix 2001:1418:0200:0::

; the port totd listens on for incoming requests
port 5353

; the pidfile to use (default: /var/run/totd.pid)
pidfile /var/run/totd.pid

; interfaces totd listens on (UDP only for now and not on Linux)
; If left out totd will only open wildcard sockets.
; interfaces lo br0
; 6to4 reverse lookup
; stf
23 changes: 23 additions & 0 deletions totd/files/totd.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=60
BIN=totd
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pid


start() {
mkdir -p $RUN_D
$BIN -c /etc/totd.conf -no6
}

stop() {
[ -f $PID_F ] && kill $(cat $PID_F)
}

restart() {
stop
sleep 1
start
}
32 changes: 32 additions & 0 deletions totd/files/totd_configure_dhcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh /etc/rc.common

START=19
STOP=10

SERVICE_DAEMONIZE=0
SERVICE_WRITE_PID=0

start()
{
uci set dhcp.@dnsmasq[0].noresolv=1
SERVERS="$(uci get dhcp.@dnsmasq[0].server)"
INTERFACES="$(uci get dhcp.@dnsmasq[0].interface)"
if [ "${SERVERS}" != "127.0.0.1#5353" ]; then
echo "adding servers"
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#5353
fi
if [ "${INTERFACES}" != "lowpan0 eth0" ]; then
echo "adding interfaces"
uci add_list dhcp.@dnsmasq[0].interface=lowpan0
uci add_list dhcp.@dnsmasq[0].interface=eth0
fi
uci commit

grep -q -F 'cache-size=0' /etc/dnsmasq.conf || echo 'cache-size=0' >> /etc/dnsmasq.conf
grep -q -F 'log-queries=extra' /etc/dnsmasq.conf || echo 'log-queries=extra' >> /etc/dnsmasq.conf
}

stop()
{
echo "Stop"
}

0 comments on commit 426b117

Please sign in to comment.