Browse Source

Merge pull request #42 from equinox0815/uanytun

import uanytun, upgrade to latest version
Nikos Mavrogiannopoulos 10 years ago
parent
commit
b2d942a8ef

+ 154
- 0
net/uanytun/Makefile View File

@@ -0,0 +1,154 @@
1
+#
2
+# Copyright (C) 2008-2014 Christian Pointner,
3
+#                         <equinox@anytun.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 uAnytun Package for OpenWRT
9
+#
10
+# $Id: $
11
+
12
+include $(TOPDIR)/rules.mk
13
+
14
+PKG_NAME:=uanytun
15
+PKG_VERSION:=0.3.5
16
+PKG_RELEASE:=1
17
+
18
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
19
+PKG_SOURCE_URL:=http://www.anytun.org/download/
20
+PKG_MD5SUM:=ce47ad45003ff1d84eaf5276941b9ddf
21
+
22
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
23
+
24
+include $(INCLUDE_DIR)/package.mk
25
+
26
+
27
+define Package/uanytun/template
28
+  SECTION:=net
29
+  CATEGORY:=Network
30
+  SUBMENU:=VPN
31
+  DEPENDS:=+kmod-tun
32
+  TITLE:=micro anycast tunneling daemon
33
+  URL:=http://www.anytun.org/
34
+  MAINTAINER:=Christian Pointner <equinox@spreadspace.org>
35
+endef
36
+
37
+
38
+define Package/uanytun
39
+  $(call Package/uanytun/template)
40
+  TITLE+= (nettle)
41
+  VARIANT:=nettle
42
+  DEPENDS+=+libnettle
43
+endef
44
+
45
+define Package/uanytun/conffiles
46
+/etc/config/uanytun
47
+endef
48
+
49
+define Package/uanytun/description
50
+uAnytun is a tiny implementation of SATP the secure anycast tunneling protocol.
51
+  SATP defines a protocol used for communication between any combination of
52
+  unicast and anycast tunnel endpoints.  It has less protocol overhead than
53
+  IPSec in Tunnel mode and allows tunneling of every ETHER TYPE protocol (e.g.
54
+  ethernet, ip, arp ...). SATP directly includes cryptography and message
55
+  authentication based on the methods used by SRTP.  It is intended to deliver
56
+  a generic, scaleable and secure solution for tunneling and relaying of packets
57
+  of any protocol.
58
+  Unlike Anytun which is a full featured implementation uAnytun has no support
59
+  for multiple connections or synchronisation. It is a small single threaded
60
+  implementation intended to act as a client on small platforms.
61
+endef
62
+
63
+
64
+define Package/uanytun-sslcrypt
65
+  $(call Package/uanytun/template)
66
+  TITLE+= (openssl)
67
+  VARIANT:=sslcrypt
68
+  DEPENDS+=+libopenssl
69
+endef
70
+
71
+Package/uanytun-sslcrypt/conffiles=$(Package/uanytun/conffiles)
72
+Package/uanytun-sslcrypt/description=$(Package/uanytun/description)
73
+
74
+
75
+define Package/uanytun-nocrypt
76
+  $(call Package/uanytun/template)
77
+  TITLE+= (no crypt)
78
+  VARIANT:=nocrypt
79
+endef
80
+
81
+Package/uanytun-nocrypt/conffiles=$(Package/uanytun/conffiles)
82
+Package/uanytun-nocrypt/description=$(Package/uanytun/description)
83
+
84
+
85
+
86
+define Build/Configure
87
+	(cd $(PKG_BUILD_DIR)/src; \
88
+    touch include.mk; \
89
+    ln -s linux/tun.c .; \
90
+    echo '#ifndef UANYTUN_version_h_INCLUDED' > version.h; \
91
+    echo '#define UANYTUN_version_h_INCLUDED' >> version.h; \
92
+    echo '' >> version.h; \
93
+    echo '#define VERSION_STRING_0 "uanytun version '`cat $(PKG_BUILD_DIR)/version`'"' >> version.h; \
94
+    echo '#define VERSION_STRING_1 "built on '`hostname`', '`date +"%d.%m.%Y %H:%M:%S %Z"`'"' >> version.h; \
95
+    echo '' >> version.h; \
96
+    echo '#endif' >> version.h \
97
+  )
98
+endef
99
+
100
+VARIANT_CFLAGS:=
101
+VARIANT_LDFLAGS:=-ldl
102
+VARIANT_MAKE_OPTS:=
103
+
104
+ifeq ($(BUILD_VARIANT),nettle)
105
+VARIANT_CFLAGS+=-DUSE_NETTLE
106
+VARIANT_LDFLAGS+=-lnettle
107
+endif
108
+
109
+ifeq ($(BUILD_VARIANT),sslcrypt)
110
+VARIANT_CFLAGS+=-DUSE_SSL_CRYPTO
111
+VARIANT_LDFLAGS+=-lcrypto
112
+endif
113
+
114
+ifeq ($(BUILD_VARIANT),nocrypt)
115
+VARIANT_CFLAGS+=-DNO_CRYPT
116
+VARIANT_MAKE_OPTS+=NO_CRYPT_OBJ=1
117
+endif
118
+
119
+define Build/Compile
120
+	$(MAKE) -C $(PKG_BUILD_DIR)/src \
121
+    $(TARGET_CONFIGURE_OPTS) \
122
+    $(VARIANT_MAKE_OPTS) \
123
+    TARGET=Linux \
124
+    CFLAGS="$(TARGET_CFLAGS) $(VARIANT_CFLAGS)" \
125
+    LDFLAGS="$(TARGET_LDFLAGS) $(VARIANT_LDFLAGS)"
126
+	$(STRIP) $(PKG_BUILD_DIR)/src/uanytun
127
+endef
128
+
129
+
130
+define Package/uanytun/install-generic
131
+	$(INSTALL_DIR) $(1)/etc/config
132
+	$(INSTALL_DATA) ./files/$(2) $(1)/etc/config/$(PKG_NAME)
133
+	$(INSTALL_DIR) $(1)/usr/sbin
134
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/uanytun $(1)/usr/sbin/$(PKG_NAME)
135
+	$(INSTALL_DIR) $(1)/etc/init.d
136
+	$(INSTALL_BIN) ./files/uanytun.init $(1)/etc/init.d/$(PKG_NAME)
137
+endef
138
+
139
+define Package/uanytun/install
140
+  $(call Package/uanytun/install-generic,$(1),uanytun.config)
141
+endef
142
+
143
+define Package/uanytun-sslcrypt/install
144
+  $(call Package/uanytun/install-generic,$(1),uanytun.config)
145
+endef
146
+
147
+define Package/uanytun-nocrypt/install
148
+  $(call Package/uanytun/install-generic,$(1),uanytun-nocrypt.config)
149
+endef
150
+
151
+
152
+$(eval $(call BuildPackage,uanytun))
153
+$(eval $(call BuildPackage,uanytun-sslcrypt))
154
+$(eval $(call BuildPackage,uanytun-nocrypt))

+ 88
- 0
net/uanytun/files/uanytun-nocrypt.config View File

@@ -0,0 +1,88 @@
1
+config "client1"
2
+  option disabled 0
3
+  option username 'nobody'
4
+  option groupname 'nogroup'
5
+#  option chroot "/var/run/uanytun"
6
+
7
+#  option interface '<ip-address>'
8
+#  option port '4444'
9
+#  option sender_id '1'
10
+
11
+#  option dev 'anytun0'
12
+  option type 'tun'
13
+  option ifconfig '192.168.123.1/24'
14
+#  option post-up-script '/etc/uanytun/client1-post-up.sh'
15
+
16
+  option remote_host 'example.com'
17
+  option remote_port '4444'
18
+
19
+  option window_size 0
20
+  option mux 1
21
+
22
+  option log 'syslog:3,anytun-client1,daemon'
23
+
24
+
25
+config "client2"
26
+  option disabled 1
27
+  option username 'nobody'
28
+  option groupname 'nogroup'
29
+
30
+  option type 'tun'
31
+  option ifconfig '192.168.123.2/24'
32
+
33
+  option remote_host 'example.com'
34
+  option remote_port '4444'
35
+
36
+  option window_size 0
37
+  option mux 2
38
+
39
+  option log 'syslog:3,anytun-client2,daemon'
40
+
41
+
42
+config "client3"
43
+  option disabled 1
44
+  option username 'nobody'
45
+  option groupname 'nogroup'
46
+
47
+  option type 'tun'
48
+  option ifconfig '192.168.123.3/24'
49
+
50
+  option remote_host 'example.com'
51
+  option remote_port '4444'
52
+
53
+  option window_size 0
54
+  option mux 3
55
+
56
+  option log 'syslog:3,anytun-client3,daemon'
57
+
58
+
59
+config "p2p-a"
60
+  option disabled 1
61
+  option username 'nobody'
62
+  option groupname 'nogroup'
63
+
64
+  option type 'tun'
65
+  option ifconfig '192.168.223.1/24'
66
+
67
+  option remote_host 'p2p-b.example.com'
68
+  option remote_port '4444'
69
+
70
+  option window_size 0
71
+
72
+  option log 'syslog:3,anytun-p2p-a,daemon'
73
+
74
+
75
+config "p2p-b"
76
+  option disabled 1
77
+  option username 'nobody'
78
+  option groupname 'nogroup'
79
+
80
+  option type 'tun'
81
+  option ifconfig '192.168.223.2/24'
82
+
83
+  option remote_host 'p2p-a.example.com'
84
+  option remote_port '4444'
85
+
86
+  option window_size 0
87
+
88
+  option log 'syslog:3,anytun-p2p-b,daemon'

+ 116
- 0
net/uanytun/files/uanytun.config View File

@@ -0,0 +1,116 @@
1
+config "client1"
2
+  option disabled 0
3
+#  option username 'nobody'
4
+#  option groupname 'nogroup'
5
+#  option chroot "/var/run/uanytun"
6
+
7
+#  option interface '<ip-address>'
8
+#  option port '4444'
9
+#  option sender_id '1'
10
+
11
+  option cipher 'aes-ctr'
12
+#  option cipher 'null'
13
+#  option cipher 'aes-ctr-128'
14
+#  option cipher 'aes-ctr-192'
15
+#  option cipher 'aes-ctr-256'
16
+  option auth_algo 'sha1'
17
+#  option auth_algo 'null'
18
+#  option auth_tag_length 10
19
+
20
+#  option dev 'anytun0'
21
+  option type 'tun'
22
+  option ifconfig '192.168.123.1/24'
23
+#  option post-up-script '/etc/uanytun/client1-post-up.sh'
24
+
25
+  option remote_host 'example.com'
26
+  option remote_port '4444'
27
+
28
+  option window_size 0
29
+  option mux 1
30
+
31
+  option role 'client'
32
+#  option kd_prf 'null'
33
+#  option kd_prf 'aes-ctr'
34
+#  option kd_prf 'aes-ctr-128'
35
+#  option kd_prf 'aes-ctr-192'
36
+#  option kd_prf 'aes-ctr-256'
37
+#  option ld_kdr '0'
38
+#  option key '0123456789ABCDEF0123456789ABCDEF'
39
+#  option salt '0123456789ABCD0123456789ABCD'
40
+  option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
41
+
42
+  option log 'syslog:3,anytun-client1,daemon'
43
+
44
+
45
+config "client2"
46
+  option disabled 1
47
+
48
+  option cipher 'aes-ctr'
49
+  option auth_algo 'sha1'
50
+  option type 'tun'
51
+  option ifconfig '192.168.123.2/24'
52
+
53
+  option remote_host 'example.com'
54
+  option remote_port '4444'
55
+
56
+  option window_size 0
57
+  option mux 2
58
+  option role 'client'
59
+  option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
60
+
61
+  option log 'syslog:3,anytun-client2,daemon'
62
+
63
+
64
+config "client3"
65
+  option disabled 1
66
+
67
+  option cipher 'aes-ctr'
68
+  option auth_algo 'sha1'
69
+  option type 'tun'
70
+  option ifconfig '192.168.123.3/24'
71
+
72
+  option remote_host 'example.com'
73
+  option remote_port '4444'
74
+
75
+  option window_size 0
76
+  option mux 3
77
+  option role 'client'
78
+  option passphrase 'Creating_VPN_Tunnels_With_Anytun_Is_Easy'
79
+
80
+  option log 'syslog:3,anytun-client3,daemon'
81
+
82
+
83
+config "p2p-a"
84
+  option disabled 1
85
+
86
+  option cipher 'aes-ctr'
87
+  option auth_algo 'sha1'
88
+  option type 'tun'
89
+  option ifconfig '192.168.223.1/24'
90
+
91
+  option remote_host 'p2p-b.example.com'
92
+  option remote_port '4444'
93
+
94
+  option window_size 0
95
+  option role 'alice'
96
+  option passphrase 'Creating_P2P_VPN_Tunnels_With_Anytun_Is_Easy'
97
+
98
+  option log 'syslog:3,anytun-p2p-a,daemon'
99
+
100
+
101
+config "p2p-b"
102
+  option disabled 1
103
+
104
+  option cipher 'aes-ctr'
105
+  option auth_algo 'sha1'
106
+  option type 'tun'
107
+  option ifconfig '192.168.223.2/24'
108
+
109
+  option remote_host 'p2p-a.example.com'
110
+  option remote_port '4444'
111
+
112
+  option window_size 0
113
+  option role 'bob'
114
+  option passphrase 'Creating_P2P_VPN_Tunnels_With_Anytun_Is_Easy'
115
+
116
+  option log 'syslog:3,anytun-p2p-b,daemon'

+ 104
- 0
net/uanytun/files/uanytun.init View File

@@ -0,0 +1,104 @@
1
+#!/bin/sh /etc/rc.common
2
+START=50
3
+
4
+BIN=uanytun
5
+DAEMON=/usr/sbin/$BIN
6
+DESC=$BIN
7
+RUN_D=/var/run
8
+
9
+
10
+option_cb() {
11
+  local varname="$1"
12
+  local value="$2"
13
+
14
+  if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then
15
+    CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
16
+  fi
17
+}
18
+
19
+foreach_config_forced() {
20
+  foreach_config $1 "forced"
21
+}
22
+
23
+foreach_config() {
24
+  local cfg="$1"
25
+  local name
26
+  local option
27
+  local value
28
+  local args=""
29
+  local forced=0
30
+
31
+  if [ -n "$2" ] && [ "x$2" == "xforced" ]; then
32
+    forced=1
33
+  fi
34
+
35
+  config_get name "$cfg" TYPE
36
+  for option in $CONFIG_OPTIONS
37
+  do
38
+    config_get value "$cfg" "$option"
39
+    if [ "x$option" == "xdisabled" ]; then
40
+      if [ $forced -eq 0 ] && [ $value -eq 1 ]; then
41
+        echo -n " $name(disabled)"
42
+        return
43
+      fi
44
+      continue
45
+    fi
46
+
47
+    option=`echo $option | tr '_' '-'`
48
+    if [ -n "$value" ]; then
49
+      args="$args --$option $value"
50
+    fi
51
+  done
52
+  echo -n " $name"
53
+  local status="OK"
54
+  $DAEMON --write-pid "$RUN_D/$BIN.$name.pid" $args || status="failed"
55
+  echo -n "($status)"
56
+}
57
+
58
+stop_vpn() {
59
+  local name=$1
60
+  local pidfile=$RUN_D/$BIN.$name.pid
61
+  echo -n " $name"
62
+  local status="OK"
63
+  if [ ! -f "$pidfile" ]; then
64
+    status="tunnel not active"
65
+  else
66
+    kill `cat $pidfile` > /dev/null 2>&1 || status="failed"
67
+    rm -f $pidfile
68
+  fi
69
+  echo -n "($status)"
70
+}
71
+
72
+start() {
73
+  echo -n "Starting $DESC:"
74
+  config_load $BIN
75
+  if [ $# -gt 0 ]; then
76
+    while [ $# -gt 0 ]; do
77
+      config_foreach foreach_config_forced "$1"
78
+      shift
79
+    done
80
+  else
81
+    config_foreach foreach_config ""
82
+  fi
83
+  echo "."
84
+}
85
+
86
+stop() {
87
+  echo -n "Stopping $DESC:"
88
+  local name
89
+  local pidfile
90
+
91
+  if [ $# -gt 0 ]; then
92
+    while [ $# -gt 0 ]; do
93
+      stop_vpn $1
94
+      shift
95
+    done
96
+  else
97
+    for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
98
+      name=${pidfile%%.pid}
99
+      name=${name##$RUN_D/$BIN.}
100
+      stop_vpn $name
101
+    done
102
+  fi
103
+  echo "."
104
+}