aboutsummaryrefslogtreecommitdiffstats
path: root/config/tinc
diff options
context:
space:
mode:
authorapnar <jlukens@botch.com>2012-09-04 00:14:37 +0000
committerapnar <jlukens@botch.com>2012-09-04 00:14:37 +0000
commite732b03ead7f7e57b82738fb432f2f4b5dc8254a (patch)
treecb93e6727a2defeaaaa45649b248854bb9bfe373 /config/tinc
parent4126868d030416f81720259b60c2b5cf5e8cb945 (diff)
downloadpfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.tar.gz
pfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.tar.bz2
pfsense-packages-e732b03ead7f7e57b82738fb432f2f4b5dc8254a.zip
Add interface group on install, remove it on uninstall, and add interfaces to it.
Diffstat (limited to 'config/tinc')
-rw-r--r--config/tinc/tinc.inc46
-rw-r--r--config/tinc/tinc_config.xml2
2 files changed, 47 insertions, 1 deletions
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 @@
<field>
<fielddescr>Interface Up Script</fielddescr>
<fieldname>tinc_up</fieldname>
- <description>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.</description>
+ <description>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.</description>
<type>textarea</type>
<encoding>base64</encoding>
<rows>8</rows>