CluPilotCloud/app/Services/Wireguard/FakeWireguardHub.php

47 lines
972 B
PHP

<?php
namespace App\Services\Wireguard;
class FakeWireguardHub implements WireguardHub
{
/** @var array<string, string> pubkey => ip */
private array $peers = [];
private int $next = 2;
public string $endpointValue = 'vpn.clupilot.test:51820';
public string $publicKeyValue = 'HUBPUBLICKEY0000000000000000000000000000000=';
public function allocateIp(): string
{
return '10.66.0.'.$this->next++;
}
public function addPeer(string $publicKey, string $ip): void
{
$this->peers[$publicKey] = $ip;
}
public function removePeer(string $publicKey): void
{
unset($this->peers[$publicKey]);
}
public function endpoint(): string
{
return $this->endpointValue;
}
public function publicKey(): string
{
return $this->publicKeyValue;
}
/** @return array<string, string> */
public function peers(): array
{
return $this->peers;
}
}