Skip to content

Commit

Permalink
chore: refactor tailscale-watcher settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaser committed Jul 19, 2023
1 parent 332a248 commit 53a1e9d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
<?php

switch ($tailscale_config['ACCEPT_ROUTES']) {
case "0":
run_command("/usr/local/sbin/tailscale set --accept-routes=false");
break;
case "1":
run_command("/usr/local/sbin/tailscale set --accept-routes=true");
break;
default:
logmsg("Ignoring accept-routes");
}
function apply_flag($setting, $flag)
{
global $tailscale_config;

switch ($tailscale_config['ACCEPT_DNS']) {
case "0":
run_command("/usr/local/sbin/tailscale set --accept-dns=false");
break;
case "1":
run_command("/usr/local/sbin/tailscale set --accept-dns=true");
break;
default:
logmsg("Ignoring accept-dns");
switch ($tailscale_config[$setting]) {
case "0":
run_command("/usr/local/sbin/tailscale set {$flag}=false");
break;
case "1":
run_command("/usr/local/sbin/tailscale set {$flag}=true");
break;
default:
logmsg("Ignoring {$flag}");
}
}

switch ($tailscale_config['SSH']) {
case "0":
run_command("/usr/local/sbin/tailscale set --ssh=false");
break;
case "1":
run_command("/usr/local/sbin/tailscale set --ssh=true");
break;
default:
logmsg("Ignoring ssh");
}
apply_flag('ACCEPT_ROUTES', '--accept-routes');
apply_flag('ACCEPT_DNS', '--accept-dns');
apply_flag('SSH', '--ssh');
48 changes: 24 additions & 24 deletions src/usr/local/emhttp/plugins/tailscale/settings.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"INCLUDE_INTERFACE": {
"default": "1",
"description": "Adds tailscale interface to Unraid services"
},
"USAGE": {
"default": "1",
"description": "Allow collection of usage data"
},
"ACCEPT_DNS": {
"default": "0",
"description": "Use MagicDNS"
},
"ACCEPT_ROUTES": {
"default": "0",
"description": "Use routes from the tailnet"
},
"SSH": {
"default": "0",
"description": "Enable SSH in Tailscale Admin Console"
},
"SYSCTL_IP_FORWARD": {
"default": "0",
"description": "Enable IP forwarding in sysctl"
}
"INCLUDE_INTERFACE": {
"default": "1",
"description": "Adds tailscale interface to Unraid services"
},
"USAGE": {
"default": "1",
"description": "Allow collection of usage data"
},
"ACCEPT_DNS": {
"default": "0",
"description": "Use MagicDNS"
},
"ACCEPT_ROUTES": {
"default": "0",
"description": "Use routes from the tailnet"
},
"SSH": {
"default": "0",
"description": "Enable SSH in Tailscale Admin Console"
},
"SYSCTL_IP_FORWARD": {
"default": "0",
"description": "Enable IP forwarding in sysctl"
}
}

0 comments on commit 53a1e9d

Please sign in to comment.