diff --git a/app/amnezia.py b/app/amnezia.py new file mode 100644 index 0000000..5f2b44f --- /dev/null +++ b/app/amnezia.py @@ -0,0 +1,14 @@ +import sys +from PyQt5.QtCore import * + + +def enc(s): + ba = qCompress(QByteArray(s.encode())) + ba = ba.toBase64(QByteArray.Base64Option.Base64UrlEncoding | QByteArray.Base64Option.OmitTrailingEquals) + print('vpn://' + str(ba, 'utf-8')) + +s = '' +for line in sys.stdin: + s += line +s = s.strip() +enc(s) diff --git a/app/bot.php b/app/bot.php index 4eeb296..b77e5e6 100644 --- a/app/bot.php +++ b/app/bot.php @@ -2536,14 +2536,60 @@ DNS-over-HTTPS with IP: $this->menu('client', "{$k}_$page"); } + public function getAmneziaShortLink($client) + { + $dns = explode(',', $client['interface']['DNS']); + $c = json_encode([ + "containers" => [ + [ + "awg" => [ + "isThirdPartyConfig" => True, + "last_config" => json_encode([ + "H1" => "{$client['interface']['H1']}", + "H2" => "{$client['interface']['H2']}", + "H3" => "{$client['interface']['H3']}", + "H4" => "{$client['interface']['H4']}", + "Jc" => "{$client['interface']['Jc']}", + "Jmax" => "{$client['interface']['Jmax']}", + "Jmin" => "{$client['interface']['Jmin']}", + "S1" => "{$client['interface']['S1']}", + "S2" => "{$client['interface']['S2']}", + "client_ip" => explode('/', $client['interface']['Address'])[0], + "client_priv_key" => $client['interface']['PrivateKey'], + "client_pub_key" => "0", + "config" => $this->createConfig($client), + "hostName" => $this->ip, + "port" => (int) getenv('WG1PORT'), + "psk_key" => $client['peers'][0]['PresharedKey'], + "server_pub_key" => $client['peers'][0]['PublicKey'] + ]), + "port" => (int) getenv('WG1PORT'), + "transport_proto" => "udp" + ], + "container" => "amnezia-awg" + ] + ], + "defaultContainer" => "amnezia-awg", + "description" => $client['interface']['## name'], + "dns1" => $dns[0], + "dns2" => $dns[1] ?: '', + "hostName" => $this->ip + ]); + exec("echo '$c' | python amnezia.py", $o); + return $o[0]; + } + public function getClient($client, $page) { $clients = $this->readClients(); if ($clients) { $name = $this->getName($clients[$client]['interface']); $conf = $this->createConfig($clients[$client]); + if ($this->getInstanceWG(1)) { + $sl = $this->getAmneziaShortLink($clients[$client]); + } return [ - 'text' => "$conf\n\n$name ({$this->getTitleWG()})", + 'text' => "
$conf
\n\n$sl\n\n$name ({$this->getTitleWG()})", 'data' => [ [ [ diff --git a/dockerfile/php.dockerfile b/dockerfile/php.dockerfile index 0cf79eb..80078f8 100644 --- a/dockerfile/php.dockerfile +++ b/dockerfile/php.dockerfile @@ -19,6 +19,7 @@ RUN apk add --no-cache --update php81 \ openssh \ openssl \ curl \ + py3-qt5 \ && wget https://github.com/ameshkov/dnslookup/releases/download/v1.9.1/dnslookup-linux-amd64-v1.9.1.tar.gz \ && tar -xf dnslookup-linux-amd64-v1.9.1.tar.gz \ && mv linux-amd64/dnslookup /usr/bin \