From 159dfe60b375e4c6871249c235eacabc78af4e65 Mon Sep 17 00:00:00 2001 From: mercury Date: Tue, 14 Feb 2023 16:06:43 +0400 Subject: [PATCH] Revert "proxy works directly with the server without v2ray" This reverts commit 1b6a95e398f822e21fcd695bd7f55407afec5952. --- app/bot.php | 13 +++++++++++++ scripts/start_proxy.sh | 9 +++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/bot.php b/app/bot.php index 258feeb..fb39a7e 100644 --- a/app/bot.php +++ b/app/bot.php @@ -300,18 +300,31 @@ class Bot public function v2ray() { + $this->ssh('pkill sslocal', 'proxy'); $this->ssh('pkill ssserver', 'ss'); $c = $this->getSSConfig(); + $l = $this->getSSLocalConfig(); $domain = $this->getPacConf()['domain']; if ($c['plugin']) { unset($c['plugin']); unset($c['plugin_opts']); + unset($l['plugin']); + unset($l['plugin_opts']); + $l['server'] = 'ss'; + $l['server_port'] = (int) getenv('SSPORT'); + $c['server_port'] = (int) getenv('SSPORT'); } else { $c['plugin'] = 'v2ray-plugin'; $c['plugin_opts'] = 'server;loglevel=none'; + $l['server'] = 'ng'; + $l['server_port'] = 443; + $l['plugin'] = 'v2ray-plugin'; + $l['plugin_opts'] = "tls;fast-open;path=/v2ray;host=$domain"; } file_put_contents('/config/ssserver.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + file_put_contents('/config/sslocal.json', json_encode($l, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); $this->ssh('/ssserver -v -d -c /config.json', 'ss'); + $this->ssh('/sslocal -v -d -c /config.json', 'proxy'); $this->menu('ss'); } diff --git a/scripts/start_proxy.sh b/scripts/start_proxy.sh index 6829ef0..36bea11 100644 --- a/scripts/start_proxy.sh +++ b/scripts/start_proxy.sh @@ -1,6 +1,11 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys service ssh start -sed "s/\"server_port\": [0-9]\+/\"server_port\": $SSPORT/" /config.json > change_port -cat change_port > /config.json +sed -n "s/\"server_port\": \([0-9]\+\),/\1/p" /config.json > current_port +CURRENT_PORT=$(cat current_port | tr -d " ") +if [ "$CURRENT_PORT" -ne "443" ] +then + sed "s/\"server_port\": [0-9]\+/\"server_port\": $SSPORT/" /config.json > change_port + cat change_port > /config.json +fi /sslocal -v -d -c /config.json tail -f /dev/null