forked from dkaser/unraid-tailscale-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mullvad filter to lock page (#25)
* feat: add mullvad filter to lock page * fix: make ids on status page more specific * fix: reduce debug log spam
- Loading branch information
Showing
5 changed files
with
171 additions
and
119 deletions.
There are no files selected for viewing
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
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
54 changes: 54 additions & 0 deletions
54
src/usr/local/emhttp/plugins/tailscale/include/data/Lock.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Tailscale; | ||
|
||
try { | ||
require_once "/usr/local/emhttp/plugins/tailscale/include/common.php"; | ||
|
||
$tailscaleConfig = $tailscaleConfig ?? new Config(); | ||
$tr = $tr ?? new Translator(); | ||
|
||
if ( ! $tailscaleConfig->Enable) { | ||
echo("{}"); | ||
return; | ||
} | ||
|
||
switch ($_POST['action']) { | ||
case 'get': | ||
$tailscaleInfo = $tailscaleInfo ?? new Info($tr); | ||
$rows = ""; | ||
|
||
$mullvad = filter_var($_POST['mullvad'] ?? false, FILTER_VALIDATE_BOOLEAN); | ||
|
||
foreach ($tailscaleInfo->getTailscaleLockPending() as $lockHost => $lockKey) { | ||
if ( ! $mullvad && str_contains($lockHost, 'mullvad.ts.net')) { | ||
continue; | ||
} | ||
|
||
$rows .= "<tr><td><input type='checkbox' name='#arg[]' value='{$lockKey}' /></td><td>{$lockHost}</td><td>{$lockKey}</td></tr>"; | ||
} | ||
|
||
$output = <<<EOT | ||
<table id="lockTable" class="unraid lockTable"> | ||
<thead> | ||
<tr> | ||
<th class="filter-false"> </th> | ||
<th>Name</th> | ||
<th class="filter-false">Key</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{$rows} | ||
</tbody> | ||
</table> | ||
EOT; | ||
|
||
$rtn = array(); | ||
$rtn['html'] = $output; | ||
echo json_encode($rtn); | ||
break; | ||
} | ||
} catch (\Throwable $e) { | ||
file_put_contents("/var/log/tailscale-error.log", print_r($e, true) . PHP_EOL, FILE_APPEND); | ||
echo "{}"; | ||
} |
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
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