HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/files.wb-cloud.nl/public_html/apps/serverinfo/lib/Resources/NetInterface.php
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\ServerInfo\Resources;

/**
 * @psalm-api
 */
class NetInterface {
	private string $name = '';
	private bool $up = false;
	private array $ipv4 = [];
	private array $ipv6 = [];
	private string $mac = '';
	private string $speed = 'unknown';
	private string $duplex = 'unknown';
	private bool $loopback = false;

	public function __construct(string $name, bool $up) {
		$this->name = $name;
		$this->up = $up;
	}

	public function getName(): string {
		return $this->name;
	}

	public function setName(string $name): void {
		$this->name = $name;
	}

	public function isUp(): bool {
		return $this->up;
	}

	public function setUp(bool $up): void {
		$this->up = $up;
	}

	/**
	 * @return string[]
	 */
	public function getIPv4(): array {
		return $this->ipv4;
	}

	public function addIPv4(string $ipv4): void {
		$this->ipv4[] = $ipv4;
		if ($ipv4 === '127.0.0.1') {
			$this->loopback = true;
		}
	}

	/**
	 * @return string[]
	 */
	public function getIPv6(): array {
		return $this->ipv6;
	}

	public function addIPv6(string $ipv6): void {
		$this->ipv6[] = $ipv6;
		if ($ipv6 === '::1') {
			$this->loopback = true;
		}
	}

	public function getMAC(): string {
		return $this->mac;
	}

	public function setMAC(string $mac): void {
		$this->mac = $mac;
	}

	public function getSpeed(): string {
		return $this->speed;
	}

	public function setSpeed(string $speed): void {
		$this->speed = $speed;
	}

	public function getDuplex(): string {
		return $this->duplex;
	}

	public function setDuplex(string $duplex): void {
		$this->duplex = $duplex;
	}

	public function isLoopback(): bool {
		return $this->loopback;
	}
}