adaptation of wireguard configuration after import for ip and port

This commit is contained in:
mercury
2023-06-06 23:50:34 +04:00
parent e60628552e
commit 02d385a555
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -2738,10 +2738,14 @@ DNS-over-HTTPS with IP:
foreach ($data['interface'] as $k => $v) {
$conf[] = "$k = $v";
}
$domain = ($this->getPacConf()['domain'] ?: $this->ip) . ":" . getenv('WGPORT');
if (!empty($data['peers'])) {
foreach ($data['peers'] as $peer) {
$conf[] = '';
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
if (!empty($peer['Endpoint'])) {
$peer['Endpoint'] = $domain;
}
foreach ($peer as $k => $v) {
$conf[] = "$k = $v";
}
@@ -2828,6 +2832,10 @@ DNS-over-HTTPS with IP:
public function saveClients(array $clients)
{
$domain = ($this->getPacConf()['domain'] ?: $this->ip) . ":" . getenv('WGPORT');
foreach ($clients as $k => $v) {
$clients[$k]['peers'][0]['Endpoint'] = $domain;
}
file_put_contents($this->clients, json_encode($clients, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
+2
View File
@@ -1,3 +1,5 @@
07.06.2023 адаптация конфига wg под текущий домен/айпи/порт
<code>git pull</code>
06.06.2023 отображение времени жизни пира в виде счетчика
<code>git pull</code>
06.06.2023 изменена логика запуска MTProto и кнопки генерации секрета