2021-03-09 15:03:52 +01:00
|
|
|
#!/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,
|
|
|
|
[
|
2022-09-26 12:11:24 +02:00
|
|
|
'full_text' => pspan($name, '#ccc', '#222'),
|
2021-03-09 15:03:52 +01:00
|
|
|
'color' => color('warning'),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
|
|
$command = 'sudo wg-quick up '.escapeshellarg($iface);
|
|
|
|
shell_exec($command);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo block(
|
|
|
|
'wireguard_'.$iface,
|
|
|
|
[
|
2022-09-26 12:11:24 +02:00
|
|
|
'full_text' => pspan($name, '#333', color('normal')),
|
2021-03-09 15:03:52 +01:00
|
|
|
'color' => color('normal'),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
|
|
$command = 'sudo wg-quick down '.escapeshellarg($iface);
|
|
|
|
shell_exec($command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|