From 404c075e59a52d34cfacf0922ad29d4c33ff0bfc Mon Sep 17 00:00:00 2001 From: lancethepants Date: Tue, 30 Sep 2014 15:45:34 +0200 Subject: [PATCH] tinc: integration and gui --- release/src/Makefile | 6 +- release/src/router/Makefile | 42 ++- release/src/router/config/config.in | 4 + release/src/router/config_base | 1 + release/src/router/httpd/tomato.c | 21 ++ release/src/router/nvram/defaults.c | 21 ++ release/src/router/rc/Makefile | 4 +- release/src/router/rc/firewall.c | 5 + release/src/router/rc/rc.h | 8 + release/src/router/rc/services.c | 8 + release/src/router/rc/tinc.c | 290 ++++++++++++++++ release/src/router/rc/wan.c | 9 + release/src/router/www/Makefile | 8 + release/src/router/www/about.asp | 3 + release/src/router/www/tomato.js | 59 +++- release/src/router/www/vpn-tinc.asp | 667 ++++++++++++++++++++++++++++++++++++ 16 files changed, 1149 insertions(+), 7 deletions(-) create mode 100644 release/src/router/rc/tinc.c create mode 100644 release/src/router/www/vpn-tinc.asp diff --git a/release/src/Makefile b/release/src/Makefile index f7a5cb562c..0c06842644 100644 --- a/release/src/Makefile +++ b/release/src/Makefile @@ -548,6 +548,10 @@ define BusyboxOptions sed -i "/CONFIG_FEATURE_LS_COLOR_IS_DEFAULT/d" $(1); \ echo "CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y" >>$(1); \ fi; \ + if [ "$(TINC)" = "y" ]; then \ + sed -i "/TCONFIG_TINC/d" $(1); \ + echo "TCONFIG_TINC=y" >>$(1); \ + fi; \ ) endef @@ -769,7 +773,7 @@ ifeq ($(CONFIG_LINUX26),y) ## All-In-One (AIO) MIPS1 - only for router with more than 8MB flash!! ZTE H618B z: - @$(MAKE) bin OPENVPN=y NTFS=y BBEXTRAS=y USBEXTRAS=y EBTABLES=y MEDIASRV=y IPV6SUPP=y B=E BUILD_DESC="AIO" USB="USB" NOCAT=y BTCLIENT=y TR_EXTRAS=y NFS=y SNMP=y HFS=y DNSCRYPT=y UPS=y PPTPD=y TOR=y IPSEC=y RAID=y NGINX=y DNSSEC=y + @$(MAKE) bin OPENVPN=y NTFS=y BBEXTRAS=y USBEXTRAS=y EBTABLES=y MEDIASRV=y IPV6SUPP=y B=E BUILD_DESC="AIO" USB="USB" NOCAT=y BTCLIENT=y TR_EXTRAS=y NFS=y SNMP=y HFS=y DNSCRYPT=y UPS=y PPTPD=y TOR=y IPSEC=y RAID=y NGINX=y DNSSEC=y TINC=y endif ################################# diff --git a/release/src/router/Makefile b/release/src/router/Makefile index c758142d6c..8a36e2b951 100644 --- a/release/src/router/Makefile +++ b/release/src/router/Makefile @@ -170,6 +170,7 @@ obj-$(TCONFIG_ZEBRA) += zebra obj-$(TCONFIG_LZO) += lzo obj-$(TCONFIG_OPENVPN) += openvpn obj-$(TCONFIG_OPENVPN) += openvpn_plugin_auth_nvram +obj-$(TCONFIG_TINC) += tinc obj-$(TCONFIG_EMF) += emf obj-$(TCONFIG_EMF) += igs @@ -220,7 +221,11 @@ else ifeq ($(TCONFIG_TOR),y) export FULL_OPENSSL := y else - FULL_OPENSSL := + ifeq ($(TCONFIG_TINC),y) + export FULL_OPENSSL := y + else + FULL_OPENSSL := + endif endif endif endif @@ -736,7 +741,7 @@ openssl/stamp-h1: shared $(OPENSSL_CIPHERS) \ no-sha0 no-smime no-camellia no-krb5 no-rmd160 no-ripemd \ no-seed no-capieng no-cms no-gms no-gmp no-rfc3779 \ - no-ec no-ecdh no-ecdsa no-err no-hw no-jpake no-threads \ + $(if $(TCONFIG_TINC),,no-ec no-ecdh no-ecdsa) no-err no-hw no-jpake no-threads \ no-zlib no-engines no-sse2 \ no-dtls1 no-store no-psk no-md2 no-mdc2 no-ts @@ -2149,6 +2154,39 @@ nfs-utils-install: nfs-utils $(STRIP) -s $(INSTALLDIR)/nfs-utils/usr/sbin/statd $(STRIP) -s $(INSTALLDIR)/nfs-utils/usr/sbin/mountd +tinc/stamp-h1: openssl zlib lzo + @cd tinc && autoreconf -fsi && \ + CC=$(CC) AR=$(AR) RANLIB=$(RANLIB) LD=$(LD) \ + CFLAGS="-Os -Wall $(EXTRACFLAGS) -fPIC -ffunction-sections -fdata-sections" \ + LDFLAGS="-ffunction-sections -fdata-sections -Wl,--gc-sections -fPIC" \ + $(CONFIGURE) \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --with-zlib-include="$(TOP)/zlib" \ + --with-zlib-lib="$(TOP)/zlib" \ + --with-lzo-include="$(TOP)/lzo/include" \ + --with-lzo-lib="$(TOP)/lzo/src/.libs" \ + --with-openssl-include="$(TOP)/openssl/include" \ + --with-openssl-lib="$(TOP)/openssl" \ + --disable-curses \ + --disable-readline + @touch tinc/stamp-h1 + +tinc: tinc/stamp-h1 + @$(SEP) + @$(MAKE) -C tinc LIBS="-lcrypto $(TOP)/zlib/libz.a -llzo2" $(PARALLEL_BUILD) + +tinc-clean: + -@$(MAKE) -C tinc clean + @rm -f tinc/stamp-h1 + +tinc-install: + install -D tinc/src/tinc $(INSTALLDIR)/tinc/usr/sbin/tinc + install -D tinc/src/tincd $(INSTALLDIR)/tinc/usr/sbin/tincd + $(STRIP) $(INSTALLDIR)/tinc/usr/sbin/tinc + $(STRIP) $(INSTALLDIR)/tinc/usr/sbin/tincd + sd-idle/stamp-h1: cd sd-idle \ CFLAGS="-Os -Wall --host=mipsel-linux --target=mipsel-linux $(EXTRACFLAGS)" \ diff --git a/release/src/router/config/config.in b/release/src/router/config/config.in index 290d4515b4..6d255f71e0 100644 --- a/release/src/router/config/config.in +++ b/release/src/router/config/config.in @@ -182,3 +182,7 @@ config TCONFIG_CTF config TCONFIG_DNSSEC bool "DNSSEC" default n + +config TCONFIG_TINC + bool "TINC" + default n diff --git a/release/src/router/config_base b/release/src/router/config_base index 515b4e52c2..e8a430c987 100644 --- a/release/src/router/config_base +++ b/release/src/router/config_base @@ -42,3 +42,4 @@ TCONFIG_SAMBASRV=y # TCONFIG_TOR is not set # TCONFIG_CTF is not set # TCONFIG_DNSSEC is not set +# TCONFIG_TINC is not set diff --git a/release/src/router/httpd/tomato.c b/release/src/router/httpd/tomato.c index fb3b91048a..46566466d1 100644 --- a/release/src/router/httpd/tomato.c +++ b/release/src/router/httpd/tomato.c @@ -1464,6 +1464,27 @@ static const nvset_t nvset_list[] = { { "pptpd_custom", V_TEXT(0, 2048) }, #endif +#ifdef TCONFIG_TINC + {"tinc_wanup", V_RANGE(0, 1) }, + {"tinc_name", V_LENGTH(0, 30) }, + {"tinc_devicetype", V_TEXT(3, 3) }, // tun, tap + {"tinc_mode", V_TEXT(3, 6) }, // switch, hub + {"tinc_vpn_netmask", V_IP }, + {"tinc_private_rsa", V_LENGTH(0, 1700) }, + {"tinc_private_ecdsa", V_LENGTH(0, 280) }, + {"tinc_custom", V_NONE }, + {"tinc_hosts", V_NONE }, + {"tinc_manual_firewall", V_RANGE(0, 1) }, + {"tinc_manual_tinc_up", V_RANGE(0, 1) }, + // scripts + {"tinc_tinc_up", V_NONE }, + {"tinc_tinc_down", V_NONE }, + {"tinc_host_up", V_NONE }, + {"tinc_host_down", V_NONE }, + {"tinc_subnet_up", V_NONE }, + {"tinc_subnet_down", V_NONE }, +#endif + #ifdef TCONFIG_TOR { "tor_enable", V_01 }, { "tor_socksport", V_RANGE(1,65535) }, diff --git a/release/src/router/nvram/defaults.c b/release/src/router/nvram/defaults.c index e336b0e357..682238eefa 100644 --- a/release/src/router/nvram/defaults.c +++ b/release/src/router/nvram/defaults.c @@ -971,6 +971,27 @@ const defaults_t defaults[] = { { "pptp_client_dfltroute","0" }, #endif +#ifdef TCONFIG_TINC + {"tinc_wanup", "0" }, + {"tinc_name", "" }, + {"tinc_devicetype", "tun" }, // tun, tap + {"tinc_mode", "switch" }, // switch, hub + {"tinc_vpn_netmask", "255.255.0.0" }, + {"tinc_private_rsa", "" }, + {"tinc_private_ecdsa", "" }, + {"tinc_custom", "" }, + {"tinc_hosts", "" }, + {"tinc_manual_firewall", "" }, + {"tinc_manual_tinc_up", "" }, + // scripts + {"tinc_tinc_up", "" }, + {"tinc_tinc_down", "" }, + {"tinc_host_up", "" }, + {"tinc_host_down", "" }, + {"tinc_subnet_up", "" }, + {"tinc_subnet_down", "" }, +#endif + #ifdef TCONFIG_BT // nas-transmission { "bt_enable", "0" }, diff --git a/release/src/router/rc/Makefile b/release/src/router/rc/Makefile index 1474e88f2d..7ff34a06a5 100644 --- a/release/src/router/rc/Makefile +++ b/release/src/router/rc/Makefile @@ -32,7 +32,9 @@ endif ifeq ($(TCONFIG_OPENVPN),y) OBJS += vpn.o endif - +ifeq ($(TCONFIG_TINC),y) +OBJS += tinc.o +endif ifeq ($(TCONFIG_PPTPD),y) OBJS += pptpd.o OBJS += pptp_client.o diff --git a/release/src/router/rc/firewall.c b/release/src/router/rc/firewall.c index 1e69ab2354..e9e86ef5d7 100644 --- a/release/src/router/rc/firewall.c +++ b/release/src/router/rc/firewall.c @@ -1872,6 +1872,11 @@ int start_firewall(void) #ifdef TCONFIG_OPENVPN run_vpn_firewall_scripts(); #endif + +#ifdef TCONFIG_TINC + run_tinc_firewall_script(); +#endif + run_nvscript("script_fire", NULL, 1); #ifdef LINUX26 diff --git a/release/src/router/rc/rc.h b/release/src/router/rc/rc.h index 0f95c5ff46..287fe0130a 100644 --- a/release/src/router/rc/rc.h +++ b/release/src/router/rc/rc.h @@ -499,6 +499,14 @@ static inline void stop_vpn_eas() { } #define write_vpn_resolv(f) (0) #endif +// tinc.c +#ifdef TCONFIG_TINC +extern void start_tinc(); +extern void start_tinc_wanup(); +extern void stop_tinc(); +extern void run_tinc_firewall_script(); +#endif + // new_qoslimit.c extern void ipt_qoslimit(int chain); extern void new_qoslimit_start(void); diff --git a/release/src/router/rc/services.c b/release/src/router/rc/services.c index 67b8b334c9..ca724330e2 100644 --- a/release/src/router/rc/services.c +++ b/release/src/router/rc/services.c @@ -2880,6 +2880,14 @@ TOP: } #endif +#ifdef TCONFIG_TINC + if (strcmp(service, "tinc") == 0) { + if (action & A_STOP) stop_tinc(); + if (action & A_START) start_tinc(); + goto CLEAR; + } +#endif + #ifdef TCONFIG_NOCAT if (strcmp(service, "splashd") == 0) { if (action & A_STOP) stop_splashd(); diff --git a/release/src/router/rc/tinc.c b/release/src/router/rc/tinc.c new file mode 100644 index 0000000000..af379ae8e4 --- /dev/null +++ b/release/src/router/rc/tinc.c @@ -0,0 +1,290 @@ +/* + + Copyright (C) 2014 Lance Fredrickson + lancethepants@gmail.com + +*/ + +#include "rc.h" + +#define BUF_SIZE 256 + +void start_tinc(void) +{ + + char *nv, *nvp, *b; + const char *connecto, *name, *address, *port, *compression, *subnet, *rsa, *ecdsa, *custom, *tinc_tmp_value; + char buffer[BUF_SIZE]; + FILE *fp, *hp; + + + // create tinc directories + mkdir("/etc/tinc", 0700); + mkdir("/etc/tinc/hosts", 0700); + + + // write private rsa key + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_private_rsa"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/rsa_key.priv", "w" ))){ + perror( "/etc/tinc/rsa_key.priv" ); + return; + } + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/rsa_key.priv", 0600); + } + + + // write private ecdsa key + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_private_ecdsa"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/ecdsa_key.priv", "w" ))){ + perror( "/etc/tinc/ecdsa_key.priv" ); + return; + } + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/ecdsa_key.priv", 0600); + } + + + // create tinc.conf + if ( !( fp = fopen( "/etc/tinc/tinc.conf", "w" ))){ + perror( "/etc/tinc/tinc.conf" ); + return; + } + + + fprintf(fp, "Name = %s\n", nvram_safe_get( "tinc_name" )); + + fprintf(fp, "Interface = tinc\n" ); + + fprintf(fp, "DeviceType = %s\n", nvram_safe_get( "tinc_devicetype" )); + + + if (nvram_match("tinc_devicetype", "tun")){ + fprintf(fp, "Mode = router\n"); + } + else if (nvram_match("tinc_devicetype", "tap")){ + fprintf(fp, "Mode = %s\n", nvram_safe_get( "tinc_mode" )); + } + + + // create tinc host files + nvp = nv = strdup(nvram_safe_get("tinc_hosts")); + if (!nv) return; + while ((b = strsep(&nvp, ">")) != NULL) { + + if (vstrsep(b, "<", &connecto, &name, &address, &port, &compression, &subnet, &rsa, &ecdsa, &custom) != 9) continue; + + sprintf(&buffer[0], "/etc/tinc/hosts/%s", name); + if ( !( hp = fopen( &buffer[0], "w" ))){ + perror( &buffer[0] ); + return; + } + + // write Connecto's to tinc.conf, excluding the host system if connecto is enabled + if ( (strcmp( connecto, "1") == 0 ) && (strcmp( nvram_safe_get("tinc_name"), name) != 0 ) ){ + fprintf(fp, "ConnectTo = %s\n", name ); + } + + if ( strcmp( rsa, "" ) != 0 ) + fprintf(hp, "%s\n", rsa ); + + if ( strcmp( ecdsa, "" ) != 0 ) + fprintf(hp, "%s\n", ecdsa ); + + if ( strcmp( address, "" ) != 0 ) + fprintf(hp, "Address = %s\n", address ); + + if ( strcmp( subnet, "" ) != 0 ) + fprintf(hp, "Subnet = %s\n", subnet ); + + if ( strcmp( compression, "" ) != 0 ) + fprintf(hp, "Compression = %s\n", compression ); + + if ( strcmp( port, "") != 0 ) + fprintf(hp, "Port = %s\n", port ); + + if ( strcmp( custom, "") != 0 ) + fprintf(hp, "%s\n", custom ); + + fclose(hp); + + // generate tinc-up and firewall scripts + if ( strcmp( nvram_safe_get("tinc_name"), name) == 0 ){ + + // create tinc-up script if this is the host system. + + if ( !( hp = fopen( "/etc/tinc/tinc-up", "w" ))){ + perror( "/etc/tinc/tinc-up" ); + return; + } + + fprintf(hp, "#!/bin/sh\n" ); + + // Determine whether automatically generate tinc-up, or use manually supplied script. + if ( !nvram_match("tinc_manual_tinc_up", "1") ){ + + if (nvram_match("tinc_devicetype", "tun")){ + fprintf(hp, "ifconfig $INTERFACE %s netmask %s\n", nvram_safe_get("lan_ipaddr"), nvram_safe_get("tinc_vpn_netmask") ); + } + else if (nvram_match("tinc_devicetype", "tap")){ + fprintf(hp, "brctl addif %s $INTERFACE\n", nvram_safe_get("lan_ifname") ); + fprintf(hp, "ifconfig $INTERFACE 0.0.0.0 promisc up\n" ); + } + } + else { + fprintf(hp, "%s\n", nvram_safe_get("tinc_tinc_up") ); + } + + fclose(hp); + chmod("/etc/tinc/tinc-up", 0744); + + // Create firewall script if manual firewall is not enabled. + if ( !nvram_match("tinc_manual_firewall", "1") ){ + + if ( !( hp = fopen( "/etc/tinc/tinc-fw.sh", "w" ))){ + perror( "/etc/tinc/tinc-fw.sh" ); + return; + } + + if ( strcmp( port, "") == 0 ) + port = "655"; + + fprintf(hp, "#!/bin/sh\n" ); + + fprintf(hp, "iptables -t nat -I PREROUTING -p udp --dport %s -j ACCEPT\n", port ); + fprintf(hp, "iptables -t nat -I PREROUTING -p tcp --dport %s -j ACCEPT\n", port ); + + + fprintf(hp, "iptables -I INPUT -p udp --dport %s -j ACCEPT\n", port ); + fprintf(hp, "iptables -I INPUT -p tcp --dport %s -j ACCEPT\n", port ); + + + fprintf(hp, "iptables -I INPUT -i tinc -j ACCEPT\n" ); + fprintf(hp, "iptables -I FORWARD -i tinc -j ACCEPT\n" ); + +#ifdef TCONFIG_IPV6 + if (ipv6_enabled()){ + + fprintf(hp, "\n" ); + fprintf(hp, "ip6tables -I INPUT -p udp --dport %s -j ACCEPT\n", port ); + fprintf(hp, "ip6tables -I INPUT -p tcp --dport %s -j ACCEPT\n", port ); + + fprintf(hp, "ip6tables -I INPUT -i tinc -j ACCEPT\n" ); + fprintf(hp, "ip6tables -I FORWARD -i tinc -j ACCEPT\n" ); + } +#endif + + fclose(hp); + chmod("/etc/tinc/tinc-fw.sh", 0744); + } + } + } + + // Write tinc.conf custom configuration + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_custom"), "") != 0 ) + fprintf(fp, "%s\n", tinc_tmp_value ); + + fclose(fp); + free(nv); + + // write tinc-down + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_tinc_down"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/tinc-down", "w" ))){ + perror( "/etc/tinc/tinc-down" ); + return; + } + fprintf(fp, "#!/bin/sh\n" ); + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/tinc-down", 0744); + } + + // write host-up + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_host_up"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/host-up", "w" ))){ + perror( "/etc/tinc/host-up" ); + return; + } + fprintf(fp, "#!/bin/sh\n" ); + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/host-up", 0744); + } + + // write host-down + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_host_down"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/host-down", "w" ))){ + perror( "/etc/tinc/host-down" ); + return; + } + fprintf(fp, "#!/bin/sh\n" ); + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/host-down", 0744); + } + + // write subnet-up + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_subnet_up"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/subnet-up", "w" ))){ + perror( "/etc/tinc/subnet-up" ); + return; + } + fprintf(fp, "#!/bin/sh\n" ); + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/subnet-up", 0744); + } + + // write subnet-down + if ( strcmp( tinc_tmp_value = nvram_safe_get("tinc_subnet_down"), "") != 0 ){ + if ( !( fp = fopen( "/etc/tinc/subnet-down", "w" ))){ + perror( "/etc/tinc/subnet-down" ); + return; + } + fprintf(fp, "#!/bin/sh\n" ); + fprintf(fp, "%s\n", tinc_tmp_value ); + fclose(fp); + chmod("/etc/tinc/subnet-down", 0744); + } + + + // Make sure module is loaded + modprobe("tun"); + f_wait_exists("/dev/net/tun", 5); + + run_tinc_firewall_script(); + xstart( "/usr/sbin/tinc", "start" ); + return; +} + +void stop_tinc(void) +{ + killall("tincd", SIGTERM); + system( "/bin/sed -i \'s/-A/-D/g;s/-I/-D/g\' /etc/tinc/tinc-fw.sh\n"); + run_tinc_firewall_script(); + system( "/bin/rm -rf /etc/tinc\n" ); + return; +} + +void run_tinc_firewall_script(void){ + + FILE *fp; + + if ((fp = fopen( "/etc/tinc/tinc-fw.sh", "r" ))){ + + fclose(fp); + system( "/etc/tinc/tinc-fw.sh" ); + } + + return; +} + +void start_tinc_wanup(void){ + + if ( nvram_match("tinc_wanup", "1") ) + start_tinc(); + + return; +} diff --git a/release/src/router/rc/wan.c b/release/src/router/rc/wan.c index 9dc0f9efee..2427106e39 100644 --- a/release/src/router/rc/wan.c +++ b/release/src/router/rc/wan.c @@ -1042,6 +1042,11 @@ void start_wan_done(char *wan_ifname) if (wanup) start_vpn_eas(); +#ifdef TCONFIG_TINC + if(wanup) + start_tinc_wanup(); +#endif + #ifdef TCONFIG_PPTPD if (wanup && nvram_get_int("pptp_client_enable")) start_pptp_client(); @@ -1061,6 +1066,10 @@ void stop_wan(void) TRACE_PT("begin\n"); +#ifdef TCONFIG_TINC + stop_tinc(); +#endif + #ifdef TCONFIG_PPTPD stop_pptp_client(); stop_dnsmasq(); diff --git a/release/src/router/www/Makefile b/release/src/router/www/Makefile index 921b1d0d16..74663b2387 100644 --- a/release/src/router/www/Makefile +++ b/release/src/router/www/Makefile @@ -250,6 +250,13 @@ ifneq ($(TCONFIG_DNSSEC),y) sed -i $(INSTALLDIR)/www/about.asp -e "/DNSSEC-BEGIN/,/DNSSEC-END/d" endif +# Only include the Tinc page if it is compiled in +ifneq ($(TCONFIG_TINC),y) + rm -f $(INSTALLDIR)/www/vpn-tinc.asp + sed -i $(INSTALLDIR)/www/tomato.js -e "/TINC-BEGIN/,/TINC-END/d" + sed -i $(INSTALLDIR)/www/about.asp -e "/TINC-BEGIN/,/TINC-END/d" +endif + # Only include the dnscrypt option if is compiled in ifeq ($(TCONFIG_DNSCRYPT),y) $(TOP)/www/dnscrypt-helper.sh $(INSTALLDIR)/../rom/rom/etc/dnscrypt-resolvers.csv $(INSTALLDIR)/www/basic-network.asp @@ -290,6 +297,7 @@ endif -e "/DNSCRYPT-BEGIN/d" -e "/DNSCRYPT-END/d"\ -e "/DNSSEC-BEGIN/d" -e "/DNSSEC-END/d"\ -e "/TOR-BEGIN/d" -e "/TOR-END/d"\ + -e "/TINC-BEGIN/d" -e "/TINC-END/d"\ || true; \ done diff --git a/release/src/router/www/about.asp b/release/src/router/www/about.asp index 36db05851c..80f716d661 100644 --- a/release/src/router/www/about.asp +++ b/release/src/router/www/about.asp @@ -206,6 +206,9 @@ Copyright (C) 2011 Augusto Bott
- DNSCrypt-Proxy selectable/manual resolver
+ +- Tinc Daemon integration and GUI
+ - Comcast DSCP Fix GUI
Copyright (C) 2014 Lance Fredrickson
lancethepants@gmail.com
diff --git a/release/src/router/www/tomato.js b/release/src/router/www/tomato.js index 8fe11efd62..b0daecd321 100644 --- a/release/src/router/www/tomato.js +++ b/release/src/router/www/tomato.js @@ -653,6 +653,37 @@ function v_iptip(e, quiet, multi) return 1; } +function _v_subnet(e, ip, quiet) +{ + var ma, oip; + oip = ip; + + // x.x.x.x/nn + if (ip.match(/^(.*)\/(.*)$/)) { + ip = RegExp.$1; + ma = RegExp.$2; + + if ((ma < 0) || (ma > 32)) { + ferror.set(e, oip + ' - invalid subnet', quiet); + return null; + } + } + else { + ferror.set(e, oip + ' - invalid subnet', quiet); + return null; + } + + ferror.clear(e); + return ip + ((ma != '') ? ('/' + ma) : ''); +} + +function v_subnet(e, quiet) +{ + if ((_v_subnet(e, e.value, quiet)) == null) return 0; + + return 1; +} + function _v_domain(e, dom, quiet) { var s; @@ -1572,6 +1603,11 @@ TomatoGrid.prototype = { if ((which == 'edit') && (values[vi])) s += ' checked'; s += '>'; break; + case 'textarea': + if (which == 'edit'){ + document.getElementById(f.proxy).value = values[vi]; + } + break; default: s += f.custom.replace(/\$which\$/g, which); } @@ -1579,9 +1615,11 @@ TomatoGrid.prototype = { ++vi; } - var c = row.insertCell(i); - c.innerHTML = s; - if (this.editorFields[i].vtop) c.vAlign = 'top'; + if(this.editorFields[i].type != 'textarea'){ + var c = row.insertCell(i); + c.innerHTML = s; + if (this.editorFields[i].vtop) c.vAlign = 'top'; + } } return row; @@ -1651,12 +1689,14 @@ TomatoGrid.prototype = { elem.remove(this.source); this.source = null; this.disableNewEditor(false); + this.clearTextarea(); }, onCancel: function() { this.removeEditor(); this.showSource(); this.disableNewEditor(false); + this.clearTextarea(); }, onOK: function() { @@ -1675,6 +1715,7 @@ TomatoGrid.prototype = { this.removeEditor(); this.showSource(); this.disableNewEditor(false); + this.clearTextarea(); }, onAdd: function() { @@ -1692,6 +1733,15 @@ TomatoGrid.prototype = { this.resetNewEditor(); }, + clearTextarea: function() { + for (var i = 0; i < this.editorFields.length; ++i){ + if(this.editorFields[i].type == 'textarea'){ + document.getElementById(this.editorFields[i].proxy).value = ''; + ferror.clear(document.getElementById(this.editorFields[i].proxy)); + } + } + }, + verifyFields: function(row, quiet) { return true; }, @@ -2461,6 +2511,9 @@ REMOVE-END */ ['PPTP Online', 'pptp-online.asp'], ['PPTP Client', 'pptp.asp'] /* PPTPD-END */ +/* TINC-BEGIN */ + ,['Tinc Daemon', 'tinc.asp'] +/* TINC-END */ ] ], /* VPN-END */ null, diff --git a/release/src/router/www/vpn-tinc.asp b/release/src/router/www/vpn-tinc.asp new file mode 100644 index 0000000000..d5af845eb2 --- /dev/null +++ b/release/src/router/www/vpn-tinc.asp @@ -0,0 +1,667 @@ + + + + + + +[<% ident(); %>] Tinc Mesh VPN + + + + + + + + + + + + + + + +
+ + + + + + +
+
<% ident(); %>
+ + + + + + +
+
Tinc Configuration
+ + + + + + +
+
+ + + -- 2.11.4.GIT