From b8ad2090e35f67f16eab2fb36f9c348a291cb584 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 14 Nov 2009 13:58:02 +0000 Subject: [PATCH 1/1] [packages] new package: rinetd - internet redirection server SVN-Revision: 18418 --- net/rinetd/Makefile | 59 ++++++++++++++++++++ net/rinetd/files/rinetd.config | 33 +++++++++++ net/rinetd/files/rinetd.init | 68 +++++++++++++++++++++++ net/rinetd/patches/001-crosscompile.patch | 12 ++++ 4 files changed, 172 insertions(+) create mode 100755 net/rinetd/Makefile create mode 100644 net/rinetd/files/rinetd.config create mode 100755 net/rinetd/files/rinetd.init create mode 100644 net/rinetd/patches/001-crosscompile.patch diff --git a/net/rinetd/Makefile b/net/rinetd/Makefile new file mode 100755 index 0000000000..e1aa66ae38 --- /dev/null +++ b/net/rinetd/Makefile @@ -0,0 +1,59 @@ +# +# Copyright (C) 2009 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:=rinetd +PKG_VERSION:=0.62 +PKG_RELEASE:=1 + +PKG_SOURCE:=rinetd.tar.gz +PKG_SOURCE_URL:=http://www.boutell.com/rinetd/http +PKG_MD5SUM:=28c78bac648971724c46f1a921154c4f +PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE) + +include $(INCLUDE_DIR)/package.mk + +define Package/rinetd + SECTION:=net + CATEGORY:=Network + TITLE:=rinetd - Internet Redirection Server + URL:=http://www.boutell.com/rinetd/ + SUBMENU:=Proxy Servers +endef + +define Package/rinetd/conffiles +/etc/config/rinetd +endef + +define Package/rinetd/description + Rinetd redirects TCP connections from one IP address and port to another. + Rinetd is a single-process server which handles any number of connections + to the address/port pairs specified in the configuration. + Since rinetd runs as a single process using nonblocking I/O, it is able to + redirect a large number of connections without a severe impact on the + machine. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + rinetd +endef + +define Package/rinetd/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rinetd $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/rinetd.config $(1)/etc/config/rinetd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/rinetd.init $(1)/etc/init.d/rinetd + +endef + +$(eval $(call BuildPackage,rinetd)) diff --git a/net/rinetd/files/rinetd.config b/net/rinetd/files/rinetd.config new file mode 100644 index 0000000000..eb543afb08 --- /dev/null +++ b/net/rinetd/files/rinetd.config @@ -0,0 +1,33 @@ +# This section defines common settings for the rinetd process. +config common + # Remove the comment from the line below to enable logging. + #option logfile /var/log/rinetd.log + + # Enable the option below to use a web server style + # common log format. + #option logcommon 1 + + # Define allow and deny rules below, you may use "?" and "*" + # as wildcards, "?" matches exactly one and "*" matches zero + # or more characters. + # + #list deny "88.*.*.*" + #list deny "89.123.12?.*" + # + #list allow "192.168.*.*" + #list allow "172.16.*.*" + #list allow "10.*.*.*" + +# Forwarding sections define forwarding rules for rinetd, +# there may be multiple sections of this type to define +# any number of forwardings. +config forwarding + # IP and port rinetd should listen to for connections. + # Use the address "0.0.0.0" to listen on any interface. + option bindaddress "0.0.0.0" + option bindport "123" + + # IP and port to forward accepted connections to. + option connectaddress "10.0.0.1" + option connectport "123" + diff --git a/net/rinetd/files/rinetd.init b/net/rinetd/files/rinetd.init new file mode 100755 index 0000000000..0cb2bbc274 --- /dev/null +++ b/net/rinetd/files/rinetd.init @@ -0,0 +1,68 @@ +#!/bin/sh /etc/rc.common +# rinetd init script +# Copyright (C) 2009 OpenWrt.org + +START=80 + +SSD=start-stop-daemon +BIN=/usr/sbin/rinetd +CFG=/var/etc/rinetd.conf +PID=/var/run/rinetd.pid + +common_add() { + local cfg="$1" + local logfile logcommon allow deny match + + config_get logfile "$cfg" logfile + config_get_bool logcommon "$cfg" logcommon 0 + + [ -n "$logfile" ] && { + echo "logfile $logfile" >> $CFG + [ "$logcommon" -gt 0 ] && echo "logcommon" >> $CFG + } + + config_get allow "$cfg" allow + config_get deny "$cfg" deny + + for match in $allow; do + echo "allow $match" >> $CFG + done + + for match in $deny; do + echo "deny $match" >> $CFG + done +} + +forward_add() { + local cfg="$1" + local bindaddr bindport connaddr connport + + config_get bindaddr "$cfg" bindaddress + config_get bindport "$cfg" bindport + config_get connaddr "$cfg" connectaddress + config_get connport "$cfg" connectport + + [ -n "$bindaddr" ] && [ -n "$connaddr" ] && \ + [ -n "$bindport" ] && [ -n "$connport" ] && \ + echo "$bindaddr $bindport $connaddr $connport" >> $CFG +} + +start() { + mkdir -p /var/etc /var/run + + echo "# This file is autogenerated, use /etc/config/rinetd" > $CFG + config_load rinetd + config_foreach common_add common + config_foreach forward_add forwarding + + $SSD -S -q -x $BIN -- -c $CFG +} + +stop() { + $SSD -K -q -p $PID -x $BIN + rm -f $PID $CFG +} + +reload() { + $SSD -K -q -p $PID -x $BIN -s 1 +} diff --git a/net/rinetd/patches/001-crosscompile.patch b/net/rinetd/patches/001-crosscompile.patch new file mode 100644 index 0000000000..00243069c3 --- /dev/null +++ b/net/rinetd/patches/001-crosscompile.patch @@ -0,0 +1,12 @@ +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,8 @@ ++CC=gcc + CFLAGS=-DLINUX -g + + rinetd: rinetd.o match.o +- gcc rinetd.o match.o -o rinetd ++ $(CC) rinetd.o match.o -o rinetd + + install: rinetd + install -m 700 rinetd /usr/sbin -- 2.30.2