-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor tailscale-watcher settings
- Loading branch information
Showing
2 changed files
with
40 additions
and
53 deletions.
There are no files selected for viewing
45 changes: 16 additions & 29 deletions
45
src/usr/local/emhttp/plugins/tailscale/include/tailscale-watcher/apply-settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |