[packages] new package: rinetd - internet redirection server

git-svn-id: svn://svn.openwrt.org/openwrt/packages@18418 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2009-11-14 13:58:02 +00:00
parent b74431e7d8
commit dfea94ccdf
4 changed files with 172 additions and 0 deletions

59
net/rinetd/Makefile Executable file
View File

@ -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))

View File

@ -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"

68
net/rinetd/files/rinetd.init Executable file
View File

@ -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
}

View File

@ -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