diff --git a/app/bot.php b/app/bot.php index 4d61299..6545e1a 100644 --- a/app/bot.php +++ b/app/bot.php @@ -3764,7 +3764,7 @@ DNS-over-HTTPS with IP: ); } - public function userXr($i, $fs = 0, $fv = 0) + public function userXr($i, $fs = 0, $fv = 0, $a = 0) { $c = $this->getXray(); $pac = $this->getPacConf() ?: $this->ip; @@ -3781,12 +3781,16 @@ DNS-over-HTTPS with IP: if (!empty($fv)) { return $fullv2ray; } + if (!empty($a)) { + return "$scheme://{$domain}/pac?h=$hash&t=si&s={$c['inbounds'][0]['settings']['clients'][$i]['id']}"; + } $text[] = "Menu -> " . $this->i18n('xray') . " -> {$c['inbounds'][0]['settings']['clients'][$i]['email']}\n"; $text[] = "{$this->linkXray($i)}\n"; $text[] = "v2ray import: v2rayng://install-config"; $text[] = "v2ray config: $scheme://{$domain}/pac?h=$hash&t=s&s={$c['inbounds'][0]['settings']['clients'][$i]['id']}\n"; - $text[] = "sing-box import: sing-box://import-remote-profile"; + $text[] = "sing-box import (Android, IOS): sing-box://import-remote-profile"; + $text[] = "sing-box windows: windows service"; $text[] = "sing-box config: $scheme://{$domain}/pac?h=$hash&t=si&s={$c['inbounds'][0]['settings']['clients'][$i]['id']}"; $data[] = [ @@ -3885,7 +3889,7 @@ DNS-over-HTTPS with IP: echo json_encode($c); } - public function singboxSubscription($key, $fs = 0) + public function singboxSubscription($key, $fs = 0, $a = 0) { $pac = $this->getPacConf(); $domain = $pac['domain'] ?: $this->ip; @@ -3897,6 +3901,9 @@ DNS-over-HTTPS with IP: if (!empty($fs)) { return $this->userXr($k, 1); } + if (!empty($a)) { + return $this->userXr($k, a: 1); + } if (empty($v['off'])) { $flag = false; } diff --git a/app/index.php b/app/index.php index dc3f193..a1519b0 100644 --- a/app/index.php +++ b/app/index.php @@ -49,9 +49,28 @@ if ($hash == substr(md5($c['key']), 0, 8)) { require __DIR__ . '/i18n.php'; $bot = new Bot($c['key'], $i); if (!empty($_GET['b'])) { - $fs = $bot->singboxSubscription($_GET['s'], 1); - header("Location: $fs"); - exit; + switch ($_GET['b']) { + case '1': + $fs = $bot->singboxSubscription($_GET['s'], 1); + header("Location: $fs"); + exit; + case '2': + $link = htmlspecialchars($bot->singboxSubscription($_GET['s'], a: 1), ENT_XML1, 'UTF-8'); + file_put_contents('/singbox/winsw.xml', preg_replace('#~url~#', $link, file_get_contents('/singbox/winsw.xml'))); + $zip = new ZipArchive(); + $n = "singbox_$v.zip"; + $zip->open($n, ZipArchive::CREATE | ZipArchive::OVERWRITE); + foreach (scandir('/singbox') as $k => $v) { + if (!empty(!in_array($v, ['.', '..']))) { + $zip->addFile("/singbox/$v", $v); + } + } + $zip->close(); + header('Content-Disposition: attachment; filename="singbox.zip"'); + echo file_get_contents('singbox.zip'); + unlink($n); + break; + } } else { header('Content-Type: application/json'); echo $bot->singboxSubscription($_GET['s']); diff --git a/docker-compose.yml b/docker-compose.yml index c0d1b71..078b7ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,7 +93,7 @@ services: ipv4_address: 10.10.1.2 logging: *default-logging php: - image: mercurykd/vpnbot-php:1.3 + image: mercurykd/vpnbot-php:1.4 build: dockerfile: dockerfile/php.dockerfile args: @@ -115,6 +115,7 @@ services: - ./.env:/mirror/.env - ./update:/update - ./.git:/.git + - ./singbox_windows:/singbox environment: IP: ${IP} VER: ${VER} diff --git a/dockerfile/php.dockerfile b/dockerfile/php.dockerfile index 8c81a0a..c3e50ee 100644 --- a/dockerfile/php.dockerfile +++ b/dockerfile/php.dockerfile @@ -4,6 +4,7 @@ RUN apk add --no-cache --update php81 \ php81-mbstring \ php81-session \ php81-phar \ + php81-zip \ php81-curl \ php81-opcache \ php81-openssl \ diff --git a/singbox_windows/install.cmd b/singbox_windows/install.cmd new file mode 100644 index 0000000..6f4a0d5 --- /dev/null +++ b/singbox_windows/install.cmd @@ -0,0 +1,2 @@ +winsw.exe install +pause \ No newline at end of file diff --git a/singbox_windows/sing-box.exe b/singbox_windows/sing-box.exe new file mode 100644 index 0000000..64ecc70 Binary files /dev/null and b/singbox_windows/sing-box.exe differ diff --git a/singbox_windows/start.cmd b/singbox_windows/start.cmd new file mode 100644 index 0000000..f6035a8 --- /dev/null +++ b/singbox_windows/start.cmd @@ -0,0 +1 @@ +winsw.exe start \ No newline at end of file diff --git a/singbox_windows/status.cmd b/singbox_windows/status.cmd new file mode 100644 index 0000000..0d4850e --- /dev/null +++ b/singbox_windows/status.cmd @@ -0,0 +1,2 @@ +winsw.exe status +pause \ No newline at end of file diff --git a/singbox_windows/stop.cmd b/singbox_windows/stop.cmd new file mode 100644 index 0000000..5ca32da --- /dev/null +++ b/singbox_windows/stop.cmd @@ -0,0 +1 @@ +winsw.exe stop \ No newline at end of file diff --git a/singbox_windows/uninstall.cmd b/singbox_windows/uninstall.cmd new file mode 100644 index 0000000..df8b561 --- /dev/null +++ b/singbox_windows/uninstall.cmd @@ -0,0 +1,2 @@ +winsw.exe uninstall +pause \ No newline at end of file diff --git a/singbox_windows/winsw.exe b/singbox_windows/winsw.exe new file mode 100644 index 0000000..9eb3759 Binary files /dev/null and b/singbox_windows/winsw.exe differ diff --git a/singbox_windows/winsw.xml b/singbox_windows/winsw.xml new file mode 100644 index 0000000..d347978 --- /dev/null +++ b/singbox_windows/winsw.xml @@ -0,0 +1,19 @@ + + singbox + singbox + singbox + %BASE%\sing-box.exe + run -c %BASE%\config.json + rotate + + + + + + + + + + + + \ No newline at end of file diff --git a/version b/version index 04217ec..69200a5 100644 --- a/version +++ b/version @@ -1,3 +1,5 @@ +13.04.2024 v1.27 +- архив сингбокса для windows, работает как служба 12.04.2024 v1.26 - имя клиента xtls подтягивается по подписке из бота 11.04.2024 v1.25