diff --git a/html/network.php b/html/network.php index c419d31..b8de5fc 100755 --- a/html/network.php +++ b/html/network.php @@ -9,203 +9,92 @@ License text: https://github.com/shreebhattji/Urmi/blob/main/licence.md */ include 'header.php' ?> - '', - '443' => '', -]; - -$data = $defaults; - -if (is_file($jsonFile)) { - $stored = json_decode(file_get_contents($jsonFile), true); - if (is_array($stored)) { - $data = $stored; - } -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - - exec("echo y | sudo ufw reset"); - exec("sudo ufw default allow outgoing"); - exec("sudo ufw default deny incoming"); - exec("sudo ufw allow proto udp to 224.0.0.0/4"); - exec("sudo ufw route allow proto udp to 224.0.0.0/4"); - exec("sudo ufw deny out to 239.255.254.254 port 39000 proto udp"); - - foreach ($defaults as $port => $_) { - $data[$port] = trim($_POST["port_$port"] ?? ''); - } - - $tmp = $jsonFile . '.tmp'; - file_put_contents( - $tmp, - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) - ); - rename($tmp, $jsonFile); - - foreach ($data as $port => $value) { - $tmp = array_filter( - array_map('trim', explode(',', (string)$value)), - 'strlen' - ); - if (count($tmp) > 0) { - foreach ($tmp as $ip) { - exec("sudo ufw allow from " . $ip . " to any port " . $port . " proto tcp"); +
+

Network Interfaces

+ + + + + + + + + + + $current_interface, + 'ip' => '', + 'mac' => '', + 'status' => 'down' + ]; + } + + // Extract IP address + if ($current_interface && preg_match('/inet\s+(\d+\.\d+\.\d+\.\d+)/', $line, $matches)) { + $interface_data[$current_interface]['ip'] = $matches[1]; + } + + // Extract MAC address + if ($current_interface && preg_match('/link\/ether\s+([a-f0-9:]+)/', $line, $matches)) { + $interface_data[$current_interface]['mac'] = $matches[1]; + } + + // Check if interface is up + if ($current_interface && strpos($line, 'state UP') !== false) { + $interface_data[$current_interface]['status'] = 'up'; + } } - } else { - exec("sudo ufw allow " . $port); - } - } - - exec("sudo ufw allow from 172.16.111.112 to 172.16.111.111 port 80"); - exec("sudo ufw allow from 172.16.111.112 to 172.16.111.111 port 443"); - exec("sudo ufw --force enable"); - exec("sudo ufw reload"); -} -?> - -?> - - - - -
-
-
-

Limit Access

- -
- $value): ?> -
- - - - Example: 192.168.1.10/24, 2001:db8::1 -
- - - -
-
-
-
- -
-
+ ?> +
+
Interface NameIP AddressMAC AddressStatus
+ \ No newline at end of file