Browse Source

Merge pull request #6 from equinox0815/master

This adds tcpproxy a simple tcp connection proxy.
lilik-openwrt-22.03
Nikos Mavrogiannopoulos 11 years ago
parent
commit
a27c76ba56
4 changed files with 1584 additions and 0 deletions
  1. +84
    -0
      net/tcpproxy/Makefile
  2. +26
    -0
      net/tcpproxy/files/tcpproxy.config
  3. +96
    -0
      net/tcpproxy/files/tcpproxy.init
  4. +1378
    -0
      net/tcpproxy/patches/001-ragel_generated.patch

+ 84
- 0
net/tcpproxy/Makefile View File

@ -0,0 +1,84 @@
#
# Copyright (C) 2010 Christian Pointner,
# <equinox@spreadspace.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# This Makefile builds tcpproxy Package for OpenWRT
#
# $Id: $
include $(TOPDIR)/rules.mk
PKG_NAME:=tcpproxy
PKG_VERSION:=1.1
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.spreadspace.org/tcpproxy/releases/
PKG_MD5SUM:=55126473bcde635f9ee019c6caf19bb7
include $(INCLUDE_DIR)/package.mk
define Package/tcpproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=IPv4/IPv6 tcp connection proxy
URL:=http://www.spreadspace.org/tcpproxy/
MAINTAINER:=Christian Pointner <equinox@spreadspace.org>
endef
define Package/tcpproxy/conffiles
/etc/config/tcpproxy
endef
define Package/tcpproxy/description
tcpproxy is a simple tcp connection proxy which combines the features of rinetd and 6tunnel.
tcpproxy supports IPv4 and IPv6 and also supports connections from IPv6 to IPv4 endpoints and vice versa.
endef
define Package/tcpproxy/configure
endef
define Build/Configure
(cd $(PKG_BUILD_DIR)/src; \
touch include.mk; \
echo '#ifndef TCPPROXY_config_h_INCLUDED' > config.h; \
echo '#define TCPPROXY_config_h_INCLUDED' >> config.h; \
echo '' >> config.h; \
echo '#define VERSION_STRING_0 "tcpproxy version '`cat $(PKG_BUILD_DIR)/version`'"' >> config.h; \
echo '#define VERSION_STRING_1 "built on '`hostname`', '`date +"%d.%m.%Y %H:%M:%S %Z"`'"' >> config.h; \
echo '' >> config.h; \
echo '#define TARGET "linux"' >> config.h; \
echo '#define PREFIX "/usr"' >> config.h; \
echo '#define BINDIR "/usr/bin"' >> config.h; \
echo '#define ETCDIR "/etc"' >> config.h; \
echo '#define CONFFILE "/etc/tcpproxy.conf"' >> config.h; \
echo '' >> config.h; \
echo '#endif' >> config.h \
)
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/src \
$(TARGET_CONFIGURE_OPTS) \
TARGET=Linux \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)"
$(STRIP) $(PKG_BUILD_DIR)/src/tcpproxy
endef
define Package/tcpproxy/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/tcpproxy.config $(1)/etc/config/tcpproxy
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(2)/src/tcpproxy $(1)/usr/bin/tcpproxy
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/tcpproxy.init $(1)/etc/init.d/tcpproxy
endef
$(eval $(call BuildPackage,tcpproxy))

+ 26
- 0
net/tcpproxy/files/tcpproxy.config View File

@ -0,0 +1,26 @@
config tcpproxy
option username 'nobody'
option groupname 'nogroup'
# option chroot "/var/run/tcpproxy"
# option log 'syslog:3,tcpproxy,daemon'
config listen
option disabled 1
option local_port '8000'
option resolv 'ipv4'
option remote_addr 'www.google.at'
option remote_port '80'
option remote_resolv 'ipv6'
option source_addr '2a02:3e0:2002:1:215:58ff:fe31:2ce7'
config listen
option disabled 1
option local_addr '2a02:3e0:2002:1:215:58ff:fe31:2ce7'
option local_port '1234'
option remote_addr 'www.google.at'
option remote_port '80'
option remote_resolv 'ipv4'

+ 96
- 0
net/tcpproxy/files/tcpproxy.init View File

@ -0,0 +1,96 @@
#!/bin/sh /etc/rc.common
START=50
BIN=tcpproxy
DAEMON=/usr/bin/$BIN
DAEMON_ARGS=""
DESC=$BIN
RUN_D=/var/run
CONFIG_DIR=/var/etc
CONFIG_FILE=$CONFIG_DIR/$BIN.conf
tcpproxy_write_config() {
local cfg="$1"
config_get_bool value "$cfg" disabled 0
[ "$value" -ne 0 ] && return
local local_addr=""
local resolv=""
local local_port=""
local remote_addr=""
local remote_resolv=""
local remote_port=""
local source_addr=""
config_get local_addr "$cfg" local_addr
config_get local_port "$cfg" local_port
config_get resolv "$cfg" resolv
config_get remote_addr "$cfg" remote_addr
config_get remote_port "$cfg" remote_port
config_get remote_resolv "$cfg" remote_resolv
config_get source_addr "$cfg" source_addr
if [ -z "$local_addr" ]; then
local_addr="*"
fi
echo "listen $local_addr $local_port" >> $CONFIG_FILE
echo "{" >> $CONFIG_FILE
if [ -n "$resolv" ]; then
echo " resolv: $resolv;" >> $CONFIG_FILE
fi
echo " remote: $remote_addr $remote_port;" >> $CONFIG_FILE
if [ -n "$remote_resolv" ]; then
echo " remote-resolv: $remote_resolv;" >> $CONFIG_FILE
fi
if [ -n "$source_addr" ]; then
echo " source: $source_addr;" >> $CONFIG_FILE
fi
echo "};" >> $CONFIG_FILE
echo "" >> $CONFIG_FILE
}
tcpproxy_generate_args() {
local cfg="$1"
local option
local value
for option in username groupname chroot log
do
config_get value "$cfg" "$option"
option=`echo $option | tr '_' '-'`
if [ -n "$value" ]; then
DAEMON_ARGS="$DAEMON_ARGS --$option $value"
fi
done
}
tcpproxy_rebuild_config() {
mkdir -p $CONFIG_DIR
rm -f $CONFIG_FILE
touch $CONFIG_FILE
config_load $BIN
config_foreach tcpproxy_write_config listen
}
start() {
echo -n "Starting $DESC "
tcpproxy_rebuild_config
config_foreach tcpproxy_generate_args $BIN
$DAEMON $DAEMON_ARGS --config $CONFIG_FILE --write-pid "$RUN_D/$BIN.pid"
echo "."
}
reload() {
echo -n "Reloading $DESC "
tcpproxy_rebuild_config
kill -SIGHUP `cat "$RUN_D/$BIN.pid"`
echo "."
}
stop() {
echo -n "Stopping $DESC "
kill `cat $RUN_D/$BIN.pid` > /dev/null 2>&1
echo "."
}

+ 1378
- 0
net/tcpproxy/patches/001-ragel_generated.patch
File diff suppressed because it is too large
View File


Loading…
Cancel
Save