-
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.
- Loading branch information
Showing
10 changed files
with
155 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
$finder = PhpCsFixer\Finder::create() | ||
->files() | ||
->name('*.page') | ||
->in(__DIR__) | ||
; | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
src/usr/local/emhttp/plugins/tailscale/Tailscale-2-Lock.page
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,49 @@ | ||
Menu="Tailscale" | ||
Icon="tailscale.png" | ||
Title="Lock" | ||
Type="xmenu" | ||
Tag="lock" | ||
--- | ||
<?php | ||
$signingNode = false; | ||
|
||
switch (true) { | ||
case $tailscale_output['lock_signing']: | ||
$signingNode = true; | ||
break; | ||
case $tailscale_output['lock_signed']: | ||
echo "Your tailnet has lock enabled and the current node is signed. This is not currently a signing node.<br />"; | ||
echo "If you wish to make this a signing node, you will need to trust the following key from a signing node:<br /><br />"; | ||
echo $tailscale_output['lock_pubkey']; | ||
break; | ||
case $tailscale_output['lock_enabled']: | ||
echo "Your tailnet has lock enabled and the current node is not signed. This node will not be able to communicate with the tailnet.<br />"; | ||
echo "To enable this node, trust the following key from a signing node:<br /><br />"; | ||
echo $tailscale_output['lock_nodekey']; | ||
break; | ||
default: | ||
echo "Your tailnet does not have lock enabled."; | ||
break; | ||
} | ||
|
||
if ($signingNode) { | ||
?> | ||
|
||
<form markdown="1" method="POST" action="/update.php" target="progressFrame"> | ||
<input type="hidden" name="#command" value="/usr/local/emhttp/plugins/tailscale/approve-nodes.php" /> | ||
|
||
### Tailscale Lock: Approve Nodes | ||
|
||
<table style="margin-top: 5px;"> | ||
<?php | ||
foreach ($tailscale_output['lock_pending'] as $lockHost => $lockKey) { | ||
echo "<tr><td><input type='checkbox' name='#arg[]' value='{$lockKey}' /></td><td>{$lockHost}<br />{$lockKey}</td></tr>"; | ||
} | ||
?> | ||
</table> | ||
|
||
<input type="submit" name="#apply" value="Approve"> | ||
</form> | ||
|
||
|
||
<?php } ?> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
#!/usr/bin/php -q | ||
<?php | ||
|
||
require "include/common.php"; | ||
|
||
foreach (array_slice($argv, 1) as $key => $value) { | ||
logmsg("Tailnet lock: signing {$value}"); | ||
exec("tailscale lock sign {$value}"); | ||
} |
66 changes: 66 additions & 0 deletions
66
src/usr/local/emhttp/plugins/tailscale/include/tailscale-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,66 @@ | ||
<?php | ||
|
||
function getTailscaleLockEnabled($lock) | ||
{ | ||
return $lock->Enabled; | ||
} | ||
|
||
function getTailscaleLockSigned($lock) | ||
{ | ||
if ( ! getTailscaleLockEnabled($lock)) { | ||
return false; | ||
} | ||
|
||
return $lock->NodeKeySigned; | ||
} | ||
|
||
function getTailscaleLockNodekey($lock) | ||
{ | ||
if ( ! getTailscaleLockEnabled($lock)) { | ||
return false; | ||
} | ||
|
||
return $lock->NodeKey; | ||
} | ||
|
||
function getTailscaleLockPubkey($lock) | ||
{ | ||
if ( ! getTailscaleLockEnabled($lock)) { | ||
return false; | ||
} | ||
|
||
return $lock->PublicKey; | ||
} | ||
|
||
function getTailscaleLockSigning($lock) | ||
{ | ||
if ( ! getTailscaleLockSigned($lock)) { | ||
return false; | ||
} | ||
|
||
$isTrusted = false; | ||
$myKey = getTailscaleLockPubkey($lock); | ||
|
||
foreach ($lock->TrustedKeys as $item) { | ||
if ($item->Key == $myKey) { | ||
$isTrusted = true; | ||
} | ||
} | ||
|
||
return $isTrusted; | ||
} | ||
|
||
function getTailscaleLockPending($lock) | ||
{ | ||
if ( ! getTailscaleLockSigning($lock)) { | ||
return array(); | ||
} | ||
|
||
$pending = array(); | ||
|
||
foreach ($lock->FilteredPeers as $item) { | ||
$pending[$item->Name] = $item->NodeKey; | ||
} | ||
|
||
return $pending; | ||
} |
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
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