'192.168.10.100', 'user' => 'root', 'key' => $SSH_KEY]; $NORDVPNS = [ 'lxc104' => ['label' => 'YouTube', 'icon' => '๐Ÿ“บ', 'host' => '192.168.10.104', 'desc' => 'WireGuard'], 'lxc110' => ['label' => 'Torrents', 'icon' => '๐Ÿงฒ', 'host' => '192.168.10.110', 'desc' => 'Transmission'], ]; $COUNTRIES = [ 'Albania' => '๐Ÿ‡ฆ๐Ÿ‡ฑ', 'Australia' => '๐Ÿ‡ฆ๐Ÿ‡บ', 'Austria' => '๐Ÿ‡ฆ๐Ÿ‡น', 'Belgium' => '๐Ÿ‡ง๐Ÿ‡ช', 'Brazil' => '๐Ÿ‡ง๐Ÿ‡ท', 'Bulgaria' => '๐Ÿ‡ง๐Ÿ‡ฌ', 'Canada' => '๐Ÿ‡จ๐Ÿ‡ฆ', 'Chile' => '๐Ÿ‡จ๐Ÿ‡ฑ', 'Colombia' => '๐Ÿ‡จ๐Ÿ‡ด', 'Croatia' => '๐Ÿ‡ญ๐Ÿ‡ท', 'Czech Republic' => '๐Ÿ‡จ๐Ÿ‡ฟ', 'Denmark' => '๐Ÿ‡ฉ๐Ÿ‡ฐ', 'Estonia' => '๐Ÿ‡ช๐Ÿ‡ช', 'Finland' => '๐Ÿ‡ซ๐Ÿ‡ฎ', 'France' => '๐Ÿ‡ซ๐Ÿ‡ท', 'Germany' => '๐Ÿ‡ฉ๐Ÿ‡ช', 'Greece' => '๐Ÿ‡ฌ๐Ÿ‡ท', 'Hong Kong' => '๐Ÿ‡ญ๐Ÿ‡ฐ', 'Hungary' => '๐Ÿ‡ญ๐Ÿ‡บ', 'Iceland' => '๐Ÿ‡ฎ๐Ÿ‡ธ', 'India' => '๐Ÿ‡ฎ๐Ÿ‡ณ', 'Ireland' => '๐Ÿ‡ฎ๐Ÿ‡ช', 'Israel' => '๐Ÿ‡ฎ๐Ÿ‡ฑ', 'Italy' => '๐Ÿ‡ฎ๐Ÿ‡น', 'Japan' => '๐Ÿ‡ฏ๐Ÿ‡ต', 'Latvia' => '๐Ÿ‡ฑ๐Ÿ‡ป', 'Lithuania' => '๐Ÿ‡ฑ๐Ÿ‡น', 'Luxembourg' => '๐Ÿ‡ฑ๐Ÿ‡บ', 'Malaysia' => '๐Ÿ‡ฒ๐Ÿ‡พ', 'Mexico' => '๐Ÿ‡ฒ๐Ÿ‡ฝ', 'Moldova' => '๐Ÿ‡ฒ๐Ÿ‡ฉ', 'Netherlands' => '๐Ÿ‡ณ๐Ÿ‡ฑ', 'New Zealand' => '๐Ÿ‡ณ๐Ÿ‡ฟ', 'Nigeria' => '๐Ÿ‡ณ๐Ÿ‡ฌ', 'Norway' => '๐Ÿ‡ณ๐Ÿ‡ด', 'Philippines' => '๐Ÿ‡ต๐Ÿ‡ญ', 'Poland' => '๐Ÿ‡ต๐Ÿ‡ฑ', 'Portugal' => '๐Ÿ‡ต๐Ÿ‡น', 'Romania' => '๐Ÿ‡ท๐Ÿ‡ด', 'Serbia' => '๐Ÿ‡ท๐Ÿ‡ธ', 'Singapore' => '๐Ÿ‡ธ๐Ÿ‡ฌ', 'Slovakia' => '๐Ÿ‡ธ๐Ÿ‡ฐ', 'Slovenia' => '๐Ÿ‡ธ๐Ÿ‡ฎ', 'South Africa' => '๐Ÿ‡ฟ๐Ÿ‡ฆ', 'South Korea' => '๐Ÿ‡ฐ๐Ÿ‡ท', 'Spain' => '๐Ÿ‡ช๐Ÿ‡ธ', 'Sweden' => '๐Ÿ‡ธ๐Ÿ‡ช', 'Switzerland' => '๐Ÿ‡จ๐Ÿ‡ญ', 'Taiwan' => '๐Ÿ‡น๐Ÿ‡ผ', 'Thailand' => '๐Ÿ‡น๐Ÿ‡ญ', 'Turkey' => '๐Ÿ‡น๐Ÿ‡ท', 'Ukraine' => '๐Ÿ‡บ๐Ÿ‡ฆ', 'United Kingdom' => '๐Ÿ‡ฌ๐Ÿ‡ง', 'United States' => '๐Ÿ‡บ๐Ÿ‡ธ', ]; function do_ssh(string $host, string $user, string $key, string $cmd): string { $opts = "-o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=8"; $ssh = "/usr/bin/ssh -i ".escapeshellarg($key)." $opts " .escapeshellarg("$user@$host")." ".escapeshellarg($cmd)." 2>&1"; return trim((string)shell_exec($ssh)); } function parse_nordvpn_status(string $raw): array { $connected = stripos($raw, 'Connected') !== false; $country = 'โ€”'; $ip = 'โ€”'; if (preg_match('/Country:\s*(.+)/i', $raw, $m)) $country = trim($m[1]); if (preg_match('/IP:\s*(\S+)/i', $raw, $m)) $ip = trim($m[1]); return compact('connected', 'country', 'ip'); } function parse_wg_status(string $raw): array { $parts = preg_split('/=== (wg\d+) ===/i', $raw, -1, PREG_SPLIT_DELIM_CAPTURE); $ifaces = []; for ($i = 1; $i < count($parts) - 1; $i += 2) { $name = $parts[$i]; $block = $parts[$i + 1]; $peers = substr_count($block, 'peer:'); $active = preg_match_all('/latest handshake: (\d+) (second|minute|hour)/i', $block); $ip = 'โ€”'; $ext = 'โ€”'; if (preg_match('/addr:\s*(\S+)/i', $block, $m)) $ip = $m[1]; if (preg_match('/ext:\s*(\S+)/i', $block, $m)) $ext = $m[1]; $ifaces[$name] = ['peers' => $peers, 'active' => $active, 'ip' => $ip, 'ext' => $ext]; } return $ifaces; } // AJAX if (isset($_GET['ajax'])) { header('Content-Type: application/json'); $id = $_GET['ajax']; if ($id === 'wg') { $raw = do_ssh($WIREGUARD['host'], $WIREGUARD['user'], $WIREGUARD['key'], 'status'); echo json_encode(['ifaces' => parse_wg_status($raw)]); } elseif (isset($NORDVPNS[$id])) { $raw = do_ssh($NORDVPNS[$id]['host'], 'root', $SSH_KEY, 'status'); echo json_encode(parse_nordvpn_status($raw)); } exit; } $result = null; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $section = $_POST['section'] ?? ''; $action = $_POST['action'] ?? ''; if (isset($NORDVPNS[$section])) { $vpn = $NORDVPNS[$section]; if ($action === 'connect') { $country = $_POST['country'] ?? ''; if (isset($COUNTRIES[$country])) { $raw = do_ssh($vpn['host'], 'root', $SSH_KEY, "connect $country"); $result = ['id' => $section, 'ok' => stripos($raw, 'connected') !== false, 'msg' => $raw]; } } elseif ($action === 'disconnect') { $raw = do_ssh($vpn['host'], 'root', $SSH_KEY, 'disconnect'); $result = ['id' => $section, 'ok' => true, 'msg' => $raw]; } } } $title = 'VPN'; ob_start(); ?>
$vpn): ?>

โ€”
A carregarโ€ฆ

๐Ÿ”’ WireGuard

LXC 100
'Direto', 'wg1' => 'NordVPN'] as $iface => $desc): ?>
โ€”
A carregarโ€ฆ