Skip to content

Commit

Permalink
tinc support for CARP
Browse files Browse the repository at this point in the history
Quick and dirty tinc support for CARP:
- make tinc a carp plugin
- when we get a rc.carpmaster event, start tinc if not already running
- when we get a rc.backup event, stop tinc if running

TODO: disable the option to launch tinc on a CARP BACKUP node
  • Loading branch information
Andrea Mistrali committed Nov 1, 2017
1 parent f2f6ef7 commit 382c2d0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions security/pfSense-pkg-tinc/files/usr/local/pkg/tinc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ require_once('service-utils.inc');
require_once('util.inc');
require_once('system.inc');

function tinc_plugin_carp($pluginparams) {
// $pluginparams['type'] = 'carp';
// $pluginparams['event'] = 'rc.carpmaster';
// $pluginparams['interface'] = $argument;
log_error("[tinc] got carp event ");
if ($pluginparams['type'] == 'carp') {
if ($pluginparams['event'] == 'rc.carpmaster') {
// start
log_error("[tinc] got CARP:MASTER -> starting");
if (is_service_running('tinc')) {
log_error("[tinc] already running");
} else {
start_service("tinc");
}
}
if ($pluginparams['event'] == 'rc.carpbackup') {
// stop
log_error("[tinc] got CARP:BACKUP -> stopping");
if (!is_service_running('tinc')) {
log_error("[tinc] already stopped");
} else {
stop_service("tinc");
}
}
}
}


function tinc_save() {
global $config, $configpath;
$configpath = '/usr/local/etc/tinc';
Expand Down
5 changes: 5 additions & 0 deletions security/pfSense-pkg-tinc/files/usr/local/pkg/tinc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<executable>tincd</executable>
<description>Tinc Mesh VPN</description>
</service>
<plugins>
<item>
<type>plugin_carp</type>
</item>
</plugins>
<tabs>
<tab>
<text>Settings</text>
Expand Down

0 comments on commit 382c2d0

Please sign in to comment.