From 5290c9f9917e3c3765a69cafa0803ffb817eed5c Mon Sep 17 00:00:00 2001 From: mercury Date: Thu, 6 Oct 2022 23:42:55 +0400 Subject: [PATCH] improve download peer --- app/bot.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/bot.php b/app/bot.php index 164f359..0fc7049 100644 --- a/app/bot.php +++ b/app/bot.php @@ -202,17 +202,9 @@ class Bot public function downloadPeer($client) { - $conf = $this->readConfig(); - $peer = $conf['peers'][$client]; - $clients = json_decode(file_get_contents($this->clients), true); - foreach ($clients as $k => $v) { - if ($v['interface']['Address'] == $peer['AllowedIPs']) { - $client_conf = $v; - break; - } - } - $name = explode('/', $peer['AllowedIPs'])[0]; - $code = $this->createConfig($client_conf); + $client = $this->readClients()[$client]; + $name = $this->getName($client['interface']); + $code = $this->createConfig($client); $this->upload("$name.conf", $code); }