From 48f1cd3a5b674345085ff6ecf3968893b92dcb98 Mon Sep 17 00:00:00 2001 From: apnar Date: Tue, 4 Sep 2012 00:00:51 +0000 Subject: Add shortcuts file --- config/tinc/pkg_tinc.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/tinc/pkg_tinc.inc (limited to 'config') diff --git a/config/tinc/pkg_tinc.inc b/config/tinc/pkg_tinc.inc new file mode 100644 index 00000000..b5b223b0 --- /dev/null +++ b/config/tinc/pkg_tinc.inc @@ -0,0 +1,11 @@ + -- cgit v1.2.3 From 4126868d030416f81720259b60c2b5cf5e8cb945 Mon Sep 17 00:00:00 2001 From: apnar Date: Tue, 4 Sep 2012 00:05:25 +0000 Subject: add service desc and tweak status perms --- config/tinc/tinc.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/tinc/tinc.xml b/config/tinc/tinc.xml index 7fb756f1..de4fd78d 100644 --- a/config/tinc/tinc.xml +++ b/config/tinc/tinc.xml @@ -76,14 +76,20 @@ /usr/local/www/ - 0644 + 0755 http://www.pfsense.com/packages/config/tinc/status_tinc.php + + /usr/local/www/shortcuts/ + 0644 + http://www.pfsense.com/packages/config/tinc/pkg_tinc.inc + tinc tinc.sh tincd + tinc mesh VPN /usr/local/pkg/tinc.inc -- cgit v1.2.3 From e732b03ead7f7e57b82738fb432f2f4b5dc8254a Mon Sep 17 00:00:00 2001 From: apnar Date: Tue, 4 Sep 2012 00:14:37 +0000 Subject: Add interface group on install, remove it on uninstall, and add interfaces to it. --- config/tinc/tinc.inc | 46 +++++++++++++++++++++++++++++++++++++++++++++ config/tinc/tinc_config.xml | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index c191de5a..0881eeac 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -68,6 +68,7 @@ function tinc_save() { else { $_output = "ifconfig \$INTERFACE " . $tincconf['localip'] . " netmask " . $tincconf['vpnnetmask'] . "\n"; + $_output .= "ifconfig \$INTERFACE group tinc\n"; } file_put_contents('/usr/local/etc/tinc/tinc-up',$_output); chmod("/usr/local/etc/tinc/tinc-up", 0744); @@ -155,6 +156,17 @@ function tinc_install() { $GLOBALS['config']['interfaces'][$newifname]['if'] = "tun0"; */ + /* Create Interface Group */ + if (!is_array($GLOBALS['config']['ifgroups']['ifgroupentry'])) + $GLOBALS['config']['ifgroups']['ifgroupentry'] = array(); + + $a_ifgroups = &$GLOBALS['config']['ifgroups']['ifgroupentry']; + $ifgroupentry = array(); + $ifgroupentry['members'] = ''; + $ifgroupentry['descr'] = 'tinc mesh VPN interface group'; + $ifgroupentry['ifname'] = 'tinc'; + $a_ifgroups[] = $ifgroupentry; + /* XXX: Do not remove this. */ mwexec("/bin/rm -f /tmp/config.cache"); @@ -165,6 +177,40 @@ function tinc_install() { } function tinc_deinstall() { + /* Remove Interface Group */ + conf_mount_rw(); + config_lock(); + if (!is_array($GLOBALS['config']['ifgroups']['ifgroupentry'])) + $GLOBALS['config']['ifgroups']['ifgroupentry'] = array(); + + $a_ifgroups = &$GLOBALS['config']['ifgroups']['ifgroupentry']; + + $myid=-1; + $i = 0; + foreach ($a_ifgroups as $ifgroupentry) + { + if($ifgroupentry['ifname']=='tinc') + { + $myid=$i; + break; + } + $i++; + } + + if ($myid >= 0 && $a_ifgroups[$myid]) + { + $members = explode(" ", $a_ifgroups[$_GET['id']]['members']); + foreach ($members as $ifs) + { + $realif = get_real_interface($ifs); + if ($realif) + mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET['id']]['ifname']); + } + unset($a_ifgroups[$myid]); + mwexec("/bin/rm -f /tmp/config.cache"); + write_config(); + } + rmdir_recursive("/var/tmp/tinc"); rmdir_recursive("/usr/local/etc/tinc*"); unlink_if_exists("/usr/local/etc/rc.d/tinc.sh"); diff --git a/config/tinc/tinc_config.xml b/config/tinc/tinc_config.xml index 6c3cce71..3878450f 100644 --- a/config/tinc/tinc_config.xml +++ b/config/tinc/tinc_config.xml @@ -144,7 +144,7 @@ Interface Up Script tinc_up - This script is executed right after the tinc daemon has connected to the virtual network device. By default a tinc-up file is created that brings up the tinc interface with the IP Address and Netmask specified above. Entering a value here complely replaces the default script so be sure to bring up the interface in this script. + This script is executed right after the tinc daemon has connected to the virtual network device. By default a tinc-up file is created that brings up the tinc interface with the IP Address and Netmask specified above and adds it to the tinc interface group. Entering a value here complely replaces the default script so be sure to bring up the interface in this script. textarea base64 8 -- cgit v1.2.3 From 2e7df9eeebad6ad70e18024feb2354fd8f400372 Mon Sep 17 00:00:00 2001 From: apnar Date: Tue, 4 Sep 2012 00:18:37 +0000 Subject: try to manually force a larger syslog file --- config/tinc/tinc.inc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 0881eeac..34deaedb 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -137,6 +137,8 @@ function tinc_install() { $_rcfile['stop'].="/usr/local/sbin/tincd --kill \n\t"; write_rcfile($_rcfile); unlink_if_exists("/usr/local/etc/rc.d/tincd"); + unlink_if_exists("/var/log/tinc.log"); + exec("/usr/sbin/clog -i -s 512144 /var/log/tinc.log"); conf_mount_rw(); config_lock(); -- cgit v1.2.3 From a6b55f4d1bf635a36c1d65d3f3e3488ed9cd135b Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 01:28:05 +0000 Subject: try to manually force bigger log a better way --- config/tinc/tinc.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 34deaedb..a17fad27 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -137,8 +137,7 @@ function tinc_install() { $_rcfile['stop'].="/usr/local/sbin/tincd --kill \n\t"; write_rcfile($_rcfile); unlink_if_exists("/usr/local/etc/rc.d/tincd"); - unlink_if_exists("/var/log/tinc.log"); - exec("/usr/sbin/clog -i -s 512144 /var/log/tinc.log"); + clear_log_file("/var/log/tinc.log"); conf_mount_rw(); config_lock(); -- cgit v1.2.3 From 3e9357fb33891ef939594561153abba49f161043 Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 01:29:43 +0000 Subject: remove some unused code --- config/tinc/tinc.inc | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index a17fad27..33e550dd 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -130,8 +130,6 @@ function tinc_status_2() { function tinc_install() { safe_mkdir("/usr/local/etc/tinc"); safe_mkdir("/usr/local/etc/tinc/hosts"); -# make_dirs("/var/tmp/tinc/var/tmp/run/tinc"); -# system("/usr/sbin/chown -R tinc:tinc /var/tmp/tinc"); $_rcfile['file']='tinc.sh'; $_rcfile['start'].="/usr/local/sbin/tincd --config=/usr/local/etc/tinc\n\t"; $_rcfile['stop'].="/usr/local/sbin/tincd --kill \n\t"; @@ -141,21 +139,6 @@ function tinc_install() { conf_mount_rw(); config_lock(); -/* - # find next free optional interface number - for ($i = 1; $i <= count($GLOBALS['config']['interfaces']); $i++) { - if (!$GLOBALS['config']['interfaces']["opt{$i}"]) - break; - } - $newifname = 'opt' . $i; - $descr = "TINC"; - $GLOBALS['config']['interfaces'][$newifname] = array(); - $GLOBALS['config']['interfaces'][$newifname]['descr'] = $descr; - - uksort($GLOBALS['config']['interfaces'], "compare_interface_friendly_names"); - - $GLOBALS['config']['interfaces'][$newifname]['if'] = "tun0"; -*/ /* Create Interface Group */ if (!is_array($GLOBALS['config']['ifgroups']['ifgroupentry'])) -- cgit v1.2.3 From 28b367b2a8803c07a89937b5c54dc5cf24cac2f1 Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 01:41:38 +0000 Subject: update status page and move status functions into that page --- config/tinc/status_tinc.php | 56 +++++++++++++++++++++++++++++++++++++++++---- config/tinc/tinc.inc | 24 ------------------- 2 files changed, 51 insertions(+), 29 deletions(-) (limited to 'config') diff --git a/config/tinc/status_tinc.php b/config/tinc/status_tinc.php index 17b8e48c..725ccce6 100644 --- a/config/tinc/status_tinc.php +++ b/config/tinc/status_tinc.php @@ -2,23 +2,69 @@ $pgtitle = array(gettext("Status"), "tinc"); require("guiconfig.inc"); -require_once("tinc.inc"); +function tinc_status_1() { + exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR1"); + usleep(500000); + exec("/usr/sbin/clog /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); + $i=0; + foreach($result as $line) + { + if(preg_match("/Connections:/",$line)) + $begin=$i; + if(preg_match("/End of connections./",$line)) + $end=$i; + $i++; + } + $output=""; + $i=0; + foreach($result as $line) + { + if($i >= $begin && $i<= $end) + $output .= $line . "\n"; + $i++; + } + return $output; +} + +function tinc_status_2() { + exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR2"); + usleep(500000); + exec("/usr/sbin/clog /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); + $i=0; + foreach($result as $line) + { + if(preg_match("/Statistics for Generic BSD tun device/",$line)) + $begin=$i; + if(preg_match("/End of subnet list./",$line)) + $end=$i; + $i++; + } + $output=""; + $i=0; + foreach($result as $line) + { + if($i >= $begin && $i<= $end) + $output .= $line . "\n"; + $i++; + } + return $output; +} + +$shortcut_section = "tinc"; include("head.inc"); ?> "> - -1:
+Connection list:
 
 

-2:
+Virtual network device statistics, all known nodes, edges and subnets:
 
 
- diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 33e550dd..674223be 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -103,30 +103,6 @@ function tinc_save() { config_unlock(); } -function tinc_status_1() { - list($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizeb,$atime,$mtimeb,$ctime,$blksize,$blocks)=stat("/var/log/tinc.log"); - exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR1"); - exec("tail -c +" . $sizeb . " /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); - $output=""; - foreach($result as $line) - { - $output .= $line . "\n"; - } - return $output; -} - -function tinc_status_2() { - list($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizeb,$atime,$mtimeb,$ctime,$blksize,$blocks)=stat("/var/log/tinc.log"); - exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -kUSR2"); - exec("tail -c +" . $sizeb . " /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result); - $output=""; - foreach($result as $line) - { - $output .= $line . "\n"; - } - return $output; -} - function tinc_install() { safe_mkdir("/usr/local/etc/tinc"); safe_mkdir("/usr/local/etc/tinc/hosts"); -- cgit v1.2.3 From 53500f4b4f87ab692e8f9c1ad69a9139d6b6afd5 Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 02:11:24 +0000 Subject: change name of status menu item to work around issue with items of same name --- config/tinc/tinc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/tinc/tinc.xml b/config/tinc/tinc.xml index de4fd78d..90581513 100644 --- a/config/tinc/tinc.xml +++ b/config/tinc/tinc.xml @@ -53,7 +53,7 @@ /pkg_edit.php?xml=tinc_config.xml - tinc + tincd Status of tinc VPN Daemon
Status
/status_tinc.php -- cgit v1.2.3 From c9a0beb5db202299150a9771e7343046b52a7b24 Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 02:40:53 +0000 Subject: removed some more unused code --- config/tinc/tinc.inc | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 674223be..4fbfcbb5 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -1,25 +1,6 @@ Date: Wed, 5 Sep 2012 02:58:14 +0000 Subject: fix uninstall --- config/tinc/tinc.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 4fbfcbb5..ea495e9f 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -148,9 +148,11 @@ function tinc_deinstall() { mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET['id']]['ifname']); } unset($a_ifgroups[$myid]); - mwexec("/bin/rm -f /tmp/config.cache"); - write_config(); } + mwexec("/bin/rm -f /tmp/config.cache"); + write_config(); + conf_mount_ro(); + config_unlock(); rmdir_recursive("/var/tmp/tinc"); rmdir_recursive("/usr/local/etc/tinc*"); -- cgit v1.2.3 From dd7f44bca1cab52627b02739c677d5d40b5c812d Mon Sep 17 00:00:00 2001 From: apnar Date: Wed, 5 Sep 2012 03:01:34 +0000 Subject: fix uninstall 2 --- config/tinc/tinc.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index ea495e9f..697e2932 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -148,9 +148,9 @@ function tinc_deinstall() { mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET['id']]['ifname']); } unset($a_ifgroups[$myid]); + mwexec("/bin/rm -f /tmp/config.cache"); + write_config(); } - mwexec("/bin/rm -f /tmp/config.cache"); - write_config(); conf_mount_ro(); config_unlock(); -- cgit v1.2.3