diff --git a/app/bot.php b/app/bot.php index 9978aaf..06f6467 100644 --- a/app/bot.php +++ b/app/bot.php @@ -368,6 +368,12 @@ class Bot case preg_match('~^/domain$~', $this->input['callback'], $m): $this->domain(); break; + case preg_match('~^/warp$~', $this->input['callback'], $m): + $this->warp(); + break; + case preg_match('~^/warpPlus$~', $this->input['callback'], $m): + $this->warpPlus(); + break; case preg_match('~^/xray(?: (\d+))?$~', $this->input['callback'], $m): $this->xray($m[1] ?: 0); break; @@ -3275,8 +3281,8 @@ DNS-over-HTTPS with IP: 'callback_data' => "/menu ss", ], [ - 'text' => $this->i18n('mirror'), - 'callback_data' => "/menu mirror", + 'text' => $this->i18n('warp'), + 'callback_data' => "/warp", ], ], [ @@ -3837,6 +3843,59 @@ DNS-over-HTTPS with IP: ); } + public function warpPlus() + { + $r = $this->send( + $this->input['chat'], + "@{$this->input['username']} enter key", + $this->input['message_id'], + reply: 'enter key', + ); + $_SESSION['reply'][$r['result']['message_id']] = [ + 'start_message' => $this->input['message_id'], + 'start_callback' => $this->input['callback_id'], + 'callback' => 'addWarpPlus', + 'args' => [], + ]; + } + + public function addWarpPlus($key) + { + $c = $this->getPacConf(); + $c['warp'] = $key; + $this->setPacConf($c); + $this->send($this->input['chat'], 'Warp registration license: ' . $this->ssh("warp-cli --accept-tos registration license $key", 'wp')); + sleep(1); + $this->warp(); + } + + public function warp() + { + $st = $this->ssh('curl -x socks5://127.0.0.1:40000 https://cloudflare.com/cdn-cgi/trace', 'wp'); + preg_match('~warp=(\w+)~', $st, $m); + $text[] = "Menu -> " . $this->i18n('warp'); + $text[] = "status: {$m['1']}"; + $data[] = [ + [ + 'text' => $this->i18n('set key'), + 'callback_data' => "/warpPlus", + ], + ]; + + $data[] = [ + [ + 'text' => $this->i18n('back'), + 'callback_data' => "/menu", + ], + ]; + $this->update( + $this->input['chat'], + $this->input['message_id'], + implode("\n", $text ?: ['...']), + $data ?: false, + ); + } + public function choiceTemplate($arg) { $arg = explode('_', $arg); @@ -5059,8 +5118,9 @@ DNS-over-HTTPS with IP: fclose($s); ssh2_disconnect($c); } catch (Exception | Error $e) { - $this->send($this->input['chat'], $e->getMessage(), $this->input['message_id']); - die(); + if (!empty($GLOBALS['debug'])) { + $this->send($this->input['chat'], $e->getMessage(), $this->input['message_id']); + } } return $data; } diff --git a/app/i18n.php b/app/i18n.php index 4ae1d96..f59b588 100644 --- a/app/i18n.php +++ b/app/i18n.php @@ -1,6 +1,10 @@ [ + 'en' => 'Warp', + 'ru' => 'Warp', + ], 'wg_title' => [ 'en' => 'Wireguard', 'ru' => 'Wireguard', diff --git a/app/init.php b/app/init.php index 4b19c87..ce1a671 100644 --- a/app/init.php +++ b/app/init.php @@ -2,10 +2,12 @@ require __DIR__ . '/timezone.php'; -// require __DIR__ . '/debug.php'; require __DIR__ . '/bot.php'; require __DIR__ . '/config.php'; require __DIR__ . '/i18n.php'; +if ($c['debug']) { + require __DIR__ . '/debug.php'; +} $bot = new Bot($c['key'], $i); $bot->adguardProtect(); diff --git a/app/service.php b/app/service.php index 9073210..8d1cd0f 100644 --- a/app/service.php +++ b/app/service.php @@ -2,11 +2,14 @@ require __DIR__ . '/timezone.php'; -// require __DIR__ . '/debug.php'; require __DIR__ . '/bot.php'; require __DIR__ . '/config.php'; require __DIR__ . '/i18n.php'; +if ($c['debug']) { + require __DIR__ . '/debug.php'; +} + $bot = new Bot($c['key'], $i); if (!empty($c['admin'])) { diff --git a/docker-compose.yml b/docker-compose.yml index 102c322..e17be96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -491,7 +491,7 @@ services: ipv4_address: 10.10.0.12 logging: *default-logging wp: - image: mercurykd/vpnbot-wp:1 + image: mercurykd/vpnbot-wp:1.1 build: dockerfile: dockerfile/warp.dockerfile args: diff --git a/dockerfile/warp.dockerfile b/dockerfile/warp.dockerfile index 2a13379..069d57f 100644 --- a/dockerfile/warp.dockerfile +++ b/dockerfile/warp.dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:22.04 -RUN apt update && apt install -y curl gpg socat lsb-release \ +RUN apt update && apt install -y curl gpg socat jq lsb-release openssh-server \ && curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg \ && echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list \ - && apt update && apt install -y cloudflare-warp + && apt update && apt install -y cloudflare-warp \ + && mkdir /root/.ssh diff --git a/scripts/start_wp.sh b/scripts/start_wp.sh index a129d02..e65a357 100644 --- a/scripts/start_wp.sh +++ b/scripts/start_wp.sh @@ -1,6 +1,15 @@ +cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config +service ssh start warp-svc > /dev/null & sleep 3 warp-cli --accept-tos registration new +key=$(cat /config/pac.json | jq -r .warp) +if [ ! -z "$key" ] +then + warp-cli --accept-tos registration license $key +fi warp-cli --accept-tos mode proxy warp-cli --accept-tos connect socat TCP-LISTEN:4000,fork TCP:127.0.0.1:40000 diff --git a/version b/version index daab907..f2f04f9 100644 --- a/version +++ b/version @@ -1,3 +1,5 @@ +18.04.2024 v1.30.1 +- возможность устанавливать ключ для warp 16.04.2024 v1.30.1 - улучшение сообщения об обновлениях 16.04.2024 v1.30