40 lines
904 B
PHP
Executable file
40 lines
904 B
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
|
|
require __DIR__.'/base/block.php';
|
|
|
|
$iface = $argv[1] ?? 'wg0';
|
|
$name = $argv[2] ?? strtoupper($iface);
|
|
|
|
$command = 'sudo wg show '.escapeshellarg($iface).' 2>/dev/null';
|
|
$output = trim(shell_exec($command));
|
|
|
|
if (empty($output)) {
|
|
echo block(
|
|
'wireguard_'.$iface,
|
|
[
|
|
'full_text' => pspan($name, '#ccc', '#222'),
|
|
'color' => color('warning'),
|
|
]
|
|
);
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
$command = 'sudo wg-quick up '.escapeshellarg($iface);
|
|
shell_exec($command);
|
|
}
|
|
} else {
|
|
echo block(
|
|
'wireguard_'.$iface,
|
|
[
|
|
'full_text' => pspan($name, '#333', color('normal')),
|
|
'color' => color('normal'),
|
|
]
|
|
);
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
$command = 'sudo wg-quick down '.escapeshellarg($iface);
|
|
shell_exec($command);
|
|
}
|
|
}
|
|
|