Browse Source

This adds tcpproxy a simple tcp connection proxy.

Signed-off-by: Christian Pointner <equinox@spreadspace.org>
Christian Pointner 10 years ago
parent
commit
2267da443a

+ 84
- 0
net/tcpproxy/Makefile View File

@@ -0,0 +1,84 @@
1
+#
2
+# Copyright (C) 2010 Christian Pointner,
3
+#                    <equinox@spreadspace.org>
4
+#
5
+# This is free software, licensed under the GNU General Public License v2.
6
+# See /LICENSE for more information.
7
+#
8
+# This Makefile builds tcpproxy Package for OpenWRT
9
+#
10
+# $Id: $
11
+
12
+include $(TOPDIR)/rules.mk
13
+
14
+PKG_NAME:=tcpproxy
15
+PKG_VERSION:=1.1
16
+PKG_RELEASE:=1
17
+
18
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
19
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
20
+PKG_SOURCE_URL:=http://www.spreadspace.org/tcpproxy/releases/
21
+PKG_MD5SUM:=55126473bcde635f9ee019c6caf19bb7
22
+
23
+include $(INCLUDE_DIR)/package.mk
24
+
25
+
26
+define Package/tcpproxy
27
+  SECTION:=net
28
+  CATEGORY:=Network
29
+  SUBMENU:=Routing and Redirection
30
+  TITLE:=IPv4/IPv6 tcp connection proxy
31
+  URL:=http://www.spreadspace.org/tcpproxy/
32
+  MAINTAINER:=Christian Pointner <equinox@spreadspace.org>
33
+endef
34
+
35
+define Package/tcpproxy/conffiles
36
+/etc/config/tcpproxy
37
+endef
38
+
39
+define Package/tcpproxy/description
40
+tcpproxy is a simple tcp connection proxy which combines the features of rinetd and 6tunnel.
41
+ tcpproxy supports IPv4 and IPv6 and also supports connections from IPv6 to IPv4 endpoints and vice versa.
42
+endef
43
+
44
+define Package/tcpproxy/configure
45
+endef
46
+
47
+define Build/Configure
48
+	(cd $(PKG_BUILD_DIR)/src; \
49
+    touch include.mk; \
50
+    echo '#ifndef TCPPROXY_config_h_INCLUDED' > config.h; \
51
+    echo '#define TCPPROXY_config_h_INCLUDED' >> config.h; \
52
+    echo '' >> config.h; \
53
+    echo '#define VERSION_STRING_0 "tcpproxy version '`cat $(PKG_BUILD_DIR)/version`'"' >> config.h; \
54
+    echo '#define VERSION_STRING_1 "built on '`hostname`', '`date +"%d.%m.%Y %H:%M:%S %Z"`'"' >> config.h; \
55
+    echo '' >> config.h; \
56
+    echo '#define TARGET "linux"' >> config.h; \
57
+    echo '#define PREFIX "/usr"' >> config.h; \
58
+    echo '#define BINDIR "/usr/bin"' >> config.h; \
59
+    echo '#define ETCDIR "/etc"' >> config.h; \
60
+    echo '#define CONFFILE "/etc/tcpproxy.conf"' >> config.h; \
61
+    echo '' >> config.h; \
62
+    echo '#endif' >> config.h \
63
+  )
64
+endef
65
+
66
+define Build/Compile
67
+	$(MAKE) -C $(PKG_BUILD_DIR)/src \
68
+    $(TARGET_CONFIGURE_OPTS) \
69
+    TARGET=Linux \
70
+    CFLAGS="$(TARGET_CFLAGS)" \
71
+    LDFLAGS="$(TARGET_LDFLAGS)"
72
+	$(STRIP) $(PKG_BUILD_DIR)/src/tcpproxy
73
+endef
74
+
75
+define Package/tcpproxy/install
76
+	$(INSTALL_DIR) $(1)/etc/config
77
+	$(INSTALL_DATA) ./files/tcpproxy.config $(1)/etc/config/tcpproxy
78
+	$(INSTALL_DIR) $(1)/usr/bin
79
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(2)/src/tcpproxy $(1)/usr/bin/tcpproxy
80
+	$(INSTALL_DIR) $(1)/etc/init.d
81
+	$(INSTALL_BIN) ./files/tcpproxy.init $(1)/etc/init.d/tcpproxy
82
+endef
83
+
84
+$(eval $(call BuildPackage,tcpproxy))

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

@@ -0,0 +1,26 @@
1
+config tcpproxy
2
+  option username 'nobody'
3
+  option groupname 'nogroup'
4
+#  option chroot "/var/run/tcpproxy"
5
+#  option log 'syslog:3,tcpproxy,daemon'
6
+
7
+config listen
8
+  option disabled 1
9
+
10
+  option local_port '8000'
11
+  option resolv 'ipv4'
12
+
13
+  option remote_addr 'www.google.at'
14
+  option remote_port '80'
15
+  option remote_resolv 'ipv6'
16
+  option source_addr '2a02:3e0:2002:1:215:58ff:fe31:2ce7'
17
+
18
+config listen
19
+  option disabled 1
20
+
21
+  option local_addr '2a02:3e0:2002:1:215:58ff:fe31:2ce7'
22
+  option local_port '1234'
23
+
24
+  option remote_addr 'www.google.at'
25
+  option remote_port '80'
26
+  option remote_resolv 'ipv4'

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

@@ -0,0 +1,96 @@
1
+#!/bin/sh /etc/rc.common
2
+START=50
3
+
4
+BIN=tcpproxy
5
+DAEMON=/usr/bin/$BIN
6
+DAEMON_ARGS=""
7
+DESC=$BIN
8
+RUN_D=/var/run
9
+CONFIG_DIR=/var/etc
10
+CONFIG_FILE=$CONFIG_DIR/$BIN.conf
11
+
12
+tcpproxy_write_config() {
13
+  local cfg="$1"
14
+
15
+  config_get_bool value "$cfg" disabled 0
16
+  [ "$value" -ne 0 ] && return
17
+
18
+  local local_addr=""
19
+  local resolv=""
20
+  local local_port=""
21
+  local remote_addr=""
22
+  local remote_resolv=""
23
+  local remote_port=""
24
+  local source_addr=""
25
+
26
+  config_get local_addr "$cfg" local_addr
27
+  config_get local_port "$cfg" local_port
28
+  config_get resolv "$cfg" resolv
29
+  config_get remote_addr "$cfg" remote_addr
30
+  config_get remote_port "$cfg" remote_port
31
+  config_get remote_resolv "$cfg" remote_resolv
32
+  config_get source_addr "$cfg" source_addr
33
+
34
+  if [ -z "$local_addr" ]; then
35
+    local_addr="*"
36
+  fi
37
+
38
+  echo "listen $local_addr $local_port" >> $CONFIG_FILE
39
+  echo "{" >> $CONFIG_FILE
40
+  if [ -n "$resolv" ]; then
41
+    echo "  resolv: $resolv;" >> $CONFIG_FILE
42
+  fi
43
+  echo "  remote: $remote_addr $remote_port;" >> $CONFIG_FILE
44
+  if [ -n "$remote_resolv" ]; then
45
+    echo "  remote-resolv: $remote_resolv;" >> $CONFIG_FILE
46
+  fi
47
+  if [ -n "$source_addr" ]; then
48
+    echo "  source: $source_addr;" >> $CONFIG_FILE
49
+  fi
50
+  echo "};" >> $CONFIG_FILE
51
+  echo "" >> $CONFIG_FILE
52
+}
53
+
54
+tcpproxy_generate_args() {
55
+  local cfg="$1"
56
+  local option
57
+  local value
58
+
59
+  for option in username groupname chroot log
60
+  do
61
+    config_get value "$cfg" "$option"
62
+    option=`echo $option | tr '_' '-'`
63
+    if [ -n "$value" ]; then
64
+      DAEMON_ARGS="$DAEMON_ARGS --$option $value"
65
+    fi
66
+  done
67
+}
68
+
69
+tcpproxy_rebuild_config() {
70
+  mkdir -p $CONFIG_DIR
71
+  rm -f $CONFIG_FILE
72
+  touch $CONFIG_FILE
73
+  config_load $BIN
74
+  config_foreach tcpproxy_write_config listen
75
+}
76
+
77
+start() {
78
+  echo -n "Starting $DESC "
79
+  tcpproxy_rebuild_config
80
+  config_foreach tcpproxy_generate_args $BIN
81
+  $DAEMON  $DAEMON_ARGS --config $CONFIG_FILE --write-pid "$RUN_D/$BIN.pid"
82
+  echo "."
83
+}
84
+
85
+reload() {
86
+  echo -n "Reloading $DESC "
87
+  tcpproxy_rebuild_config
88
+  kill -SIGHUP `cat "$RUN_D/$BIN.pid"`
89
+  echo "."
90
+}
91
+
92
+stop() {
93
+  echo -n "Stopping $DESC "
94
+  kill `cat $RUN_D/$BIN.pid` > /dev/null 2>&1
95
+  echo "."
96
+}

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