diff --git a/classes/Hardware/NetworkInterface.class.php b/classes/Hardware/NetworkInterface.class.php
new file mode 100644
index 0000000..07fccbd
--- /dev/null
+++ b/classes/Hardware/NetworkInterface.class.php
@@ -0,0 +1,99 @@
+value){
+ return $status;
+ }
+ }
+
+ throw new \ValueError("$name is not a valid backing value for enum " . self::class );
+ }
+
+ public static function tryFromName(string $name) : NetworkState | null {
+ try {
+ return self::fromName($name);
+ } catch (\ValueError $error) {
+ return null;
+ }
+ }
+ }
+
+ class NetworkInterface {
+ private ?string $id = null;
+ private bool $virtual = false;
+ private bool $tunnel = false;
+ private ?string $address = null;
+ private ?string $broadcast = null;
+ private ?string $type = null;
+ private ?NetworkState $state = null;
+
+ public function __construct(string $id) {
+ $this->id = $id;
+
+ switch($this->id) {
+ case 'sit0': // Tunnel-Device for IPv6 in IPv4
+ $this->tunnel = true;
+ $this->virtual = true;
+ break;
+ case 'teql0':
+ $this->virtual = true;
+ break;
+ }
+ }
+
+ public function getID() {
+ return $this->id;
+ }
+
+ public function isVirtual() : bool {
+ return $this->virtual;
+ }
+
+ public function isTunnel() : bool {
+ return $this->tunnel;
+ }
+
+ public function getState() : NetworkState {
+ return $this->state;
+ }
+ public function setState(NetworkState $state) {
+ $this->state = $state;
+ }
+
+ public function getType() {
+ return $this->type;
+ }
+ public function setType($type) {
+ $this->type = $type;
+ }
+ public function setAddress($address) {
+ $this->address = $address;
+ }
+ public function setBroadcast($broadcast) {
+ $this->broadcast = $broadcast;
+ }
+
+ public function enable() {
+ shell_exec(sprintf('ifup %s', $this->id));
+ }
+
+ public function disable() {
+ shell_exec(sprintf('ifdown %s', $this->id));
+ }
+ }
+?>
diff --git a/classes/Hardware/NetworkInterfaces.class.php b/classes/Hardware/NetworkInterfaces.class.php
index 712c352..fa5d36a 100644
--- a/classes/Hardware/NetworkInterfaces.class.php
+++ b/classes/Hardware/NetworkInterfaces.class.php
@@ -22,7 +22,33 @@
}
protected function __construct() {
-
+ $result = shell_exec('ls /sys/class/net | jq -R -s -c \'split("\n")[:-1]\'');
+
+ foreach(json_decode($result) AS $entry) {
+ $this->devices[$entry] = new NetworkInterface($entry);
+ }
+
+ $result = shell_exec('ip --json address show');
+
+ foreach(json_decode($result) AS $entry) {
+ $device = $this->devices[$entry->ifname];
+ $device->debug = $entry;
+
+ if(isset($entry->link_type)) {
+ $device->setType($entry->link_type);
+ }
+ if(isset($entry->operstate)) {
+ $device->setState(NetworkState::tryFromName($entry->operstate));
+ }
+
+ if(isset($entry->address)) {
+ $device->setAddress($entry->address);
+ }
+
+ if(isset($entry->broadcast)) {
+ $device->setBroadcast($entry->broadcast);
+ }
+ }
}
public function getDevices() : array {
@@ -40,6 +66,10 @@
public function getIPAddress() : string {
return trim($_SERVER['SERVER_ADDR']);
}
+
+ public function getDevice($id) : NetworkInterface | null {
+ return $this->devices[$id];
+ }
}
class NetworkInterfaces {
@@ -62,5 +92,9 @@
public static function getIPAddress() : string {
return NetworkInterfacesFactory::getInstance()->getDevices();
}
+
+ public static function getDevice($id) : NetworkInterface | null {
+ return NetworkInterfacesFactory::getInstance()->getDevice($id);
+ }
}
?>
\ No newline at end of file
diff --git a/classes/System/CoreAdmin.class.php b/classes/System/CoreAdmin.class.php
index b9c0bd2..45fc70b 100644
--- a/classes/System/CoreAdmin.class.php
+++ b/classes/System/CoreAdmin.class.php
@@ -52,13 +52,14 @@
}
});
- $this->getRouter()->addRoute('^/server(?:/([a-zA-Z0-9\-_]+))(?:/([a-zA-Z0-9\-_]+))?$', function(?string $destination = null, ?string $tab = null) {
+ $this->getRouter()->addRoute('^/server(?:/([a-zA-Z0-9\-_]+))(?:/([a-zA-Z0-9\-_]+))?(?:/([a-zA-Z0-9\-_]+))?$', function(?string $destination = null, ?string $tab = null, ?string $action = null) {
if(!Auth::isLoggedIn()) {
Response::redirect('/');
}
if($this->getTemplate()->display('server' . (!empty($destination) ? sprintf('/%s', $destination) : ''), [
- 'tab' => $tab
+ 'tab' => $tab,
+ 'action' => $action
]) == false) {
$this->getTemplate()->display('error/404');
}
diff --git a/default/server/network.php b/default/server/network.php
index 0725b21..59e084f 100644
--- a/default/server/network.php
+++ b/default/server/network.php
@@ -1,7 +1,8 @@
header();
@@ -15,42 +16,122 @@
$template->footer();
exit();
}
+ ?>
+
+ debug); + } + ?>+
capacity; ?> units; ?>
- - -%s
', $rebooting)); }