Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e727f6552c | |||
| cfd500d48a | |||
| ff87ee1055 | |||
| 3375293be5 | |||
| 6e5f198e23 | |||
| b10aaff459 | |||
| 3271561418 | |||
| 295ee6f2aa | |||
| 7ce7c56c1b | |||
| dca34de723 | |||
| eb1ad21c88 | |||
| a3ca7d9ed8 | |||
| 60ba3cf15c | |||
| cd8bcbe05a | |||
| 6cc05c88e7 | |||
| 795c357897 | |||
| e172868f39 | |||
| 4ef38775b0 | |||
| abdb4d791a | |||
| 6948239144 | |||
| ff0fd177c7 | |||
| 28e66d46fd | |||
| edee9c78c5 | |||
| 6ad8b3aa92 | |||
| 31f1825d37 | |||
| 10d84da53e | |||
| c7cc0f31ad | |||
| e3ddb642d7 | |||
| 589823e45d | |||
| 0364188fe8 | |||
| 72edcc4757 | |||
| 5988c4fcee | |||
| a82147eeda | |||
| 6bd21d06c0 | |||
| 3416cda826 | |||
| 2e40daf0c4 | |||
| 9c40b04392 | |||
| 1217ea7a09 | |||
| 7f6d462f22 | |||
| 47876ecdb4 | |||
| 66f03709fc | |||
| 42aafc6427 | |||
| 1674f6929e |
+452
-90
@@ -133,9 +133,24 @@ class Bot
|
||||
case preg_match('~^/changeWG (\d+)$~', $this->input['callback'], $m):
|
||||
$this->changeWG($m[1]);
|
||||
break;
|
||||
case preg_match('~^/changeTransport(?: (\d+))?$~', $this->input['callback'], $m):
|
||||
$this->changeTransport($m[1] ?: false);
|
||||
break;
|
||||
case preg_match('~^/mirror$~', $this->input['message'], $m):
|
||||
$this->menu('mirror');
|
||||
break;
|
||||
case preg_match('~^/autoupdate$~', $this->input['message'], $m):
|
||||
$this->autoupdate();
|
||||
break;
|
||||
case preg_match('~^/appOutbound$~', $this->input['callback'], $m):
|
||||
$this->appOutbound();
|
||||
break;
|
||||
case preg_match('~^/addSubdomain$~', $this->input['callback'], $m):
|
||||
$this->addSubdomain();
|
||||
break;
|
||||
case preg_match('~^/addLinkDomain$~', $this->input['callback'], $m):
|
||||
$this->addLinkDomain();
|
||||
break;
|
||||
case preg_match('~^/id$~', $this->input['message'], $m):
|
||||
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
||||
break;
|
||||
@@ -328,6 +343,9 @@ class Bot
|
||||
case preg_match('~^/switchTorrent (\d+)$~', $this->input['callback'], $m):
|
||||
$this->switchTorrent($m[1]);
|
||||
break;
|
||||
case preg_match('~^/switchEndpoint (\d+)$~', $this->input['callback'], $m):
|
||||
$this->switchEndpoint($m[1]);
|
||||
break;
|
||||
case preg_match('~^/switchAmnezia (-?\d+)$~', $this->input['callback'], $m):
|
||||
$this->switchAmnezia($m[1]);
|
||||
break;
|
||||
@@ -350,8 +368,8 @@ class Bot
|
||||
case preg_match('~^/qrSS$~', $this->input['callback'], $m):
|
||||
$this->qrSS();
|
||||
break;
|
||||
case preg_match('~^/qrXray (\d+)$~', $this->input['callback'], $m):
|
||||
$this->qrXray($m[1]);
|
||||
case preg_match('~^/qrXray (\d+)(?:_(\d+))?$~', $this->input['callback'], $m):
|
||||
$this->qrXray($m[1], $m[2] ?: false);
|
||||
break;
|
||||
case preg_match('~^/qrMtproto$~', $this->input['callback'], $m):
|
||||
$this->qrMtproto();
|
||||
@@ -960,7 +978,7 @@ class Bot
|
||||
if (!empty($s = trim($v))) {
|
||||
$t = explode(';', $s);
|
||||
if ($type == 'rulessetlist') {
|
||||
if (preg_match('~^(?:direct|block|proxy):.+:https?://.+~', $t[0])) {
|
||||
if (preg_match('~^.+:.+:https?://.+~', $t[0])) {
|
||||
$list[$t[0]] = (bool) $t[1];
|
||||
}
|
||||
} else {
|
||||
@@ -1081,6 +1099,10 @@ class Bot
|
||||
]
|
||||
]);
|
||||
}
|
||||
if ($this->getPacConf()['autoupdate']) {
|
||||
$this->input['chat'] = $this->input['from'] = $c['admin'][0];
|
||||
$this->applyupdatebot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1092,7 +1114,7 @@ class Bot
|
||||
{
|
||||
try {
|
||||
require __DIR__ . '/config.php';
|
||||
if (!empty($c['admin']) && (empty($this->time2) || ((time() - $this->time2) > 3600))) {
|
||||
if (!empty($c['admin']) && date('H') == 12 && (empty($this->time2) || ((time() - $this->time2) > 4600))) {
|
||||
$this->time2 = time();
|
||||
$cert = $this->expireCert();
|
||||
if (!empty($cert) && $cert - 60 * 60 * 24 * 14 < time()) {
|
||||
@@ -1347,7 +1369,8 @@ class Bot
|
||||
$out[] = 'update xray';
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->restartXray($json['xray']);
|
||||
$this->setUpstreamDomain($json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]);
|
||||
$this->adguardXrayClients();
|
||||
$this->setUpstreamDomain($json['pac']['transport'] == 'Websocket' ? 't' : ($json['pac']['reality']['domain'] ?: $json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
||||
}
|
||||
// ocserv
|
||||
if (!empty($json['oc'])) {
|
||||
@@ -1366,7 +1389,7 @@ class Bot
|
||||
|
||||
$t = file_get_contents('/config/nginx_default.conf');
|
||||
if (!empty($json['pac']['domain'])) {
|
||||
$t = preg_replace('/server_name ([^\n]+)?/', "server_name {$json['pac']['domain']};", $t);
|
||||
$t = preg_replace('/server_name ([^\n]+)?/', "server_name *.{$json['pac']['domain']} {$json['pac']['domain']};", $t);
|
||||
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
|
||||
foreach ($m[0] as $k => $v) {
|
||||
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
||||
@@ -1517,6 +1540,14 @@ class Bot
|
||||
$this->menu('wg', $page);
|
||||
}
|
||||
|
||||
public function switchEndpoint($page = 0)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
$c[$this->getInstanceWG(1) . 'endpoint'] = $c[$this->getInstanceWG(1) . 'endpoint'] ? 0 : 1;
|
||||
$this->setPacConf($c);
|
||||
$this->menu('wg', $page);
|
||||
}
|
||||
|
||||
public function iptablesWG()
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
@@ -1581,7 +1612,7 @@ class Bot
|
||||
{
|
||||
$conf = $this->getPacConf();
|
||||
$ip = $this->ip;
|
||||
$domain = $conf['domain'] ?: $ip;
|
||||
$domain = $this->getDomain();
|
||||
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$ss = $this->getSSConfig();
|
||||
$port = !empty($ss['plugin']) ? (!empty($ssl) ? 443 : 80) : getenv('SSPORT');
|
||||
@@ -1601,9 +1632,9 @@ class Bot
|
||||
}
|
||||
}
|
||||
|
||||
public function qrXray($i)
|
||||
public function qrXray($i, $s = false)
|
||||
{
|
||||
$link = $this->linkXray($i);
|
||||
$link = $this->linkXray($i, $s);
|
||||
$qr_file = __DIR__ . "/qr/xray.png";
|
||||
exec("qrencode -t png -o $qr_file '$link'");
|
||||
$r = $this->sendPhoto(
|
||||
@@ -1687,7 +1718,7 @@ class Bot
|
||||
$conf = $this->getPacConf();
|
||||
$conf['domain'] = idn_to_ascii($domain);
|
||||
$nginx = file_get_contents('/config/nginx.conf');
|
||||
$t = preg_replace('/server_name ([^\n]+)?/', "server_name {$conf['domain']};", $nginx);
|
||||
$t = preg_replace('/server_name ([^\n]+)?/', "server_name {$conf['domain']} *.{$conf['domain']};", $nginx);
|
||||
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
|
||||
foreach ($m[0] as $k => $v) {
|
||||
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
||||
@@ -1797,9 +1828,13 @@ class Bot
|
||||
case 'letsencrypt':
|
||||
$out[] = 'Install certificate:';
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$adguardClient = $this->getPacConf()['adguardkey'];
|
||||
$adguardClient = $adguardClient ? "-d $adguardClient.{$conf['domain']}" : '';
|
||||
exec("certbot certonly --force-renew --preferred-chain 'ISRG Root X1' -n --agree-tos --email mail@{$conf['domain']} -d {$conf['domain']} -d oc.{$conf['domain']} -d np.{$conf['domain']} $adguardClient --webroot -w /certs/ --logs-dir /logs --max-log-backups 0 2>&1", $out, $code);
|
||||
$adguardClient = $conf['adguardkey'] ? "-d {$conf['adguardkey']}.{$conf['domain']}" : '';
|
||||
if (!empty($conf['subdomain'])) {
|
||||
foreach ($conf['subdomain'] as $v) {
|
||||
$custom .= " -d $v";
|
||||
}
|
||||
}
|
||||
exec("certbot certonly --force-renew --preferred-chain 'ISRG Root X1' -n --agree-tos --email mail@{$conf['domain']} -d {$conf['domain']} -d oc.{$conf['domain']} -d np.{$conf['domain']} $adguardClient $custom --webroot -w /certs/ --logs-dir /logs --max-log-backups 0 2>&1", $out, $code);
|
||||
if ($code > 0) {
|
||||
$this->send($this->input['chat'], "ERROR\n" . implode("\n", $out));
|
||||
break;
|
||||
@@ -2048,6 +2083,61 @@ class Bot
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function addSubdomain()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter subdomain",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter subdomain',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'callback' => 'setSubdomain',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function addLinkDomain()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter domain for link",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter domain for link',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'callback' => 'setLinkDomain',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function setLinkDomain($text)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
if (empty($text)) {
|
||||
unset($c['linkdomain']);
|
||||
} else {
|
||||
$c['linkdomain'] = trim($text);
|
||||
}
|
||||
$this->setPacConf($c);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function setSubdomain($text)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
if (empty($text)) {
|
||||
unset($c['subdomain']);
|
||||
} else {
|
||||
$c['subdomain'] = array_filter(explode(',', $text), fn($e) => !empty(trim($e)));
|
||||
}
|
||||
$this->setPacConf($c);
|
||||
$this->menu('config');
|
||||
}
|
||||
|
||||
public function enterPage()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -2115,6 +2205,61 @@ class Bot
|
||||
$this->menu('adguard');
|
||||
}
|
||||
|
||||
public function guidv4($data = null) {
|
||||
// Generate 16 bytes (128 bits) of random data or use the data passed into the function.
|
||||
$data = $data ?? random_bytes(16);
|
||||
assert(strlen($data) == 16);
|
||||
|
||||
// Set version to 0100
|
||||
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
|
||||
// Set bits 6-7 to 10
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
|
||||
|
||||
// Output the 36 character UUID.
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
|
||||
public function adguardXrayClients()
|
||||
{
|
||||
$xr = $this->getXray();
|
||||
$ad = yaml_parse_file($this->adguard);
|
||||
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
$tmp[] = [
|
||||
'safe_search' => [
|
||||
'enabled' => true,
|
||||
'bing' => true,
|
||||
'duckduckgo' => true,
|
||||
'google' => true,
|
||||
'pixabay' => true,
|
||||
'yandex' => true,
|
||||
'youtube' => true,
|
||||
],
|
||||
'blocked_services' => [
|
||||
'schedule' => ['time_zone' => date_default_timezone_get()],
|
||||
'ids' => [],
|
||||
],
|
||||
'name' => $v['email'],
|
||||
'ids' => [$v['id']],
|
||||
'tags' => [],
|
||||
'upstreams' => [],
|
||||
'uid' => $v['id'],
|
||||
'upstreams_cache_size' => 0,
|
||||
'upstreams_cache_enabled' => false,
|
||||
'use_global_settings' => true,
|
||||
'filtering_enabled' => false,
|
||||
'parental_enabled' => false,
|
||||
'safebrowsing_enabled' => false,
|
||||
'use_global_blocked_services' => true,
|
||||
'ignore_querylog' => false,
|
||||
'ignore_statistics' => false,
|
||||
];
|
||||
}
|
||||
$ad['clients']['persistent'] = $tmp;
|
||||
yaml_emit_file($this->adguard, $ad);
|
||||
$this->stopAd();
|
||||
$this->startAd();
|
||||
}
|
||||
|
||||
public function checkdns()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -2241,8 +2386,8 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function addInclude(string $domains, $type)
|
||||
{
|
||||
if ($type == 'rulessetlist' && !preg_match('~^(?:direct|block|proxy):.+:https?://.+~', $domains)) {
|
||||
$this->send($this->input['from'], 'wrong pattern, enter [direct|block|proxy]:time:URL');
|
||||
if ($type == 'rulessetlist' && !preg_match('~^.+:.+:https?://.+~', $domains)) {
|
||||
$this->send($this->input['from'], 'wrong pattern, enter [direct|block|proxy|custom outbound]:time:URL');
|
||||
return;
|
||||
}
|
||||
$domains = explode(',', $domains);
|
||||
@@ -2250,7 +2395,7 @@ DNS-over-HTTPS with IP:
|
||||
if (!empty($domains)) {
|
||||
$conf = $this->getPacConf();
|
||||
foreach ($domains as $k => $v) {
|
||||
$conf[$type][idn_to_ascii(trim($v))] = true;
|
||||
$conf[$type][$type == 'rulessetlist' ? trim($v) : idn_to_ascii(trim($v))] = true;
|
||||
}
|
||||
ksort($conf[$type]);
|
||||
$this->setPacConf($conf);
|
||||
@@ -2541,6 +2686,7 @@ DNS-over-HTTPS with IP:
|
||||
$dns = $c[$this->getInstanceWG(1) . 'dns'];
|
||||
$mtu = $c[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu;
|
||||
$am = $c[$this->getInstanceWG(1) . 'amnezia'];
|
||||
$end = $c[$this->getInstanceWG(1) . 'endpoint'];
|
||||
$data = [
|
||||
[
|
||||
[
|
||||
@@ -2572,6 +2718,12 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => "/defaultMTU $page",
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('endpoint') . ': ' . ($end ? $this->ip : $this->getDomain()),
|
||||
'callback_data' => "/switchEndpoint $page",
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('add peer'),
|
||||
@@ -3138,7 +3290,7 @@ DNS-over-HTTPS with IP:
|
||||
$mpac = stat(__DIR__ . '/zapretlists/mpac');
|
||||
$pac = stat(__DIR__ . '/zapretlists/pac');
|
||||
$conf = $this->getPacConf();
|
||||
$ip = $conf['domain'] ?: $this->ip;
|
||||
$ip = $this->getDomain();
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$text = <<<text
|
||||
@@ -3383,11 +3535,26 @@ DNS-over-HTTPS with IP:
|
||||
);
|
||||
}
|
||||
|
||||
public function appOutbound()
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
$p['app_outbound'] = !$p['app_outbound'];
|
||||
$p = $this->setPacConf($p);
|
||||
$this->xtlsapp();
|
||||
}
|
||||
|
||||
public function xtlsapp($page = 0)
|
||||
{
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> package list';
|
||||
|
||||
$data = $this->listPac('packagelist', $page, 'xtlsapp');
|
||||
$p = $this->getPacConf();
|
||||
$data[] = [
|
||||
[
|
||||
'text' => 'set to ' . ($p['app_outbound'] ? 'proxy' : 'direct'),
|
||||
'callback_data' => "/appOutbound",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('back'),
|
||||
@@ -3440,11 +3607,11 @@ DNS-over-HTTPS with IP:
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . idn_to_utf8($k),
|
||||
'callback_data' => "/change$type $i",
|
||||
'callback_data' => "/change$type " . ($i + $page * $this->limit),
|
||||
],
|
||||
[
|
||||
'text' => 'delete',
|
||||
'callback_data' => "/delete$type $i",
|
||||
'callback_data' => "/delete$type " . ($i + $page * $this->limit),
|
||||
],
|
||||
];
|
||||
$i++;
|
||||
@@ -3535,7 +3702,7 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$conf = $this->getPacConf();
|
||||
$ip = $this->ip;
|
||||
$domain = $conf['domain'] ?: $ip;
|
||||
$domain = $this->getDomain();
|
||||
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$ss = $this->getSSConfig();
|
||||
$v2ray = !empty($ss['plugin']) ? 'ON' : 'OFF';
|
||||
@@ -3662,7 +3829,7 @@ DNS-over-HTTPS with IP:
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('chat'),
|
||||
'url' => "https://t.me/vpnbot_group",
|
||||
'url' => "https://t.me/+BYuWVd36cZYwNTMy",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('donate'),
|
||||
@@ -3711,17 +3878,36 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
|
||||
public function geodb()
|
||||
{
|
||||
$this->answer($this->input['callback_id'], 'in developing...');
|
||||
}
|
||||
|
||||
public function linkXray($i)
|
||||
public function linkXray($i, $s = false)
|
||||
{
|
||||
$c = $this->getXray();
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
return "vless://{$c['inbounds'][0]['settings']['clients'][$i]['id']}@$domain:443?security=reality&sni={$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}&fp=chrome&pbk={$pac['xray']}&sid={$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0]}&type=tcp&flow=xtls-rprx-vision#vpnbot";
|
||||
$domain = $this->getDomain($pac['transport'] == 'Websocket');
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
$si = "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 'si',
|
||||
's' => $c['inbounds'][0]['settings']['clients'][$i]['id'],
|
||||
]));
|
||||
$v2 = "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 's',
|
||||
's' => $c['inbounds'][0]['settings']['clients'][$i]['id'],
|
||||
]));
|
||||
|
||||
switch ($s) {
|
||||
case 1:
|
||||
return "v2rayng://install-config?url=$v2#{$c['inbounds'][0]['settings']['clients'][$i]['id']}";
|
||||
case 2:
|
||||
return "sing-box://import-remote-profile/?url={$si}#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
|
||||
|
||||
default:
|
||||
if ($pac['transport'] == 'Websocket') {
|
||||
return "vless://{$c['inbounds'][0]['settings']['clients'][$i]['id']}@$domain:443?flow=&path=%2Fws&security=tls&sni=$domain&fp=chrome&type=ws#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
|
||||
}
|
||||
return "vless://{$c['inbounds'][0]['settings']['clients'][$i]['id']}@$domain:443?security=reality&sni={$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}&fp=chrome&pbk={$pac['xray']}&sid={$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0]}&type=tcp&flow=xtls-rprx-vision#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
|
||||
}
|
||||
}
|
||||
|
||||
public function dockerApi($url, $method = 'GET', $data = [])
|
||||
@@ -3770,8 +3956,9 @@ DNS-over-HTTPS with IP:
|
||||
public function naiveMenu()
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $this->getDomain();
|
||||
$text[] = "Menu -> NaiveProxy";
|
||||
$text[] = "<code>https://{$pac['naive']['user']}:{$pac['naive']['pass']}@np.{$pac['domain']}</code>";
|
||||
$text[] = "<code>https://{$pac['naive']['user']}:{$pac['naive']['pass']}@np.$domain</code>";
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('change login'),
|
||||
@@ -3863,6 +4050,7 @@ DNS-over-HTTPS with IP:
|
||||
public function ocMenu()
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $this->getDomain();
|
||||
$ocserv = file_get_contents('/config/ocserv.conf');
|
||||
preg_match('~^camouflage_secret[^\n]+?"([^"]+)*"~sm', $ocserv, $m);
|
||||
$cs = $m[1];
|
||||
@@ -3871,7 +4059,7 @@ DNS-over-HTTPS with IP:
|
||||
$pass = htmlspecialchars($pac['ocserv']);
|
||||
$text[] = "Menu -> OpenConnect";
|
||||
if (!empty($m[1])) {
|
||||
$text[] = "<code>https://oc.{$pac['domain']}/?$cs</code>";
|
||||
$text[] = "<code>https://oc.$domain/?$cs</code>";
|
||||
}
|
||||
$text[] = "password: <span class='tg-spoiler'>$pass</span>";
|
||||
$data[] = [
|
||||
@@ -3934,6 +4122,7 @@ DNS-over-HTTPS with IP:
|
||||
if ($i == $k) {
|
||||
unset($r['inbounds'][0]['settings']['clients'][$k]);
|
||||
$this->restartXray($r);
|
||||
$this->adguardXrayClients();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3956,13 +4145,18 @@ DNS-over-HTTPS with IP:
|
||||
public function addxrus($user)
|
||||
{
|
||||
$c = $this->getXray();
|
||||
$p = $this->getPacConf();
|
||||
$uuid = trim($this->ssh('xray uuid', 'xr'));
|
||||
$c['inbounds'][0]['settings']['clients'][] = [
|
||||
'id' => $uuid,
|
||||
'flow' => 'xtls-rprx-vision',
|
||||
'email' => $user,
|
||||
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] == 'Websocket' ? [
|
||||
'id' => $uuid,
|
||||
'email' => $user,
|
||||
] : [
|
||||
'id' => $uuid,
|
||||
'flow' => 'xtls-rprx-vision',
|
||||
'email' => $user,
|
||||
];
|
||||
$this->restartXray($c);
|
||||
$this->adguardXrayClients();
|
||||
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
|
||||
}
|
||||
|
||||
@@ -4009,6 +4203,7 @@ DNS-over-HTTPS with IP:
|
||||
$c = $this->getXray();
|
||||
$c['inbounds'][0]['settings']['clients'][$i]['email'] = $name;
|
||||
$this->restartXray($c);
|
||||
$this->adguardXrayClients();
|
||||
$this->userXr($i);
|
||||
}
|
||||
|
||||
@@ -4084,7 +4279,7 @@ DNS-over-HTTPS with IP:
|
||||
public function templates($type)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
$domain = $this->getDomain();
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . " -> $type templates";
|
||||
$templates = $pac["{$type}templates"];
|
||||
@@ -4146,18 +4341,40 @@ DNS-over-HTTPS with IP:
|
||||
$this->generateSecretXray();
|
||||
}
|
||||
$c = $this->getXray();
|
||||
$p = $this->getPacConf();
|
||||
$text[] = "Menu -> " . $this->i18n('xray');
|
||||
$text[] = "fake domain: <code>{$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}</code>";
|
||||
if (!empty($fake = $c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0])) {
|
||||
$text[] = "fake domain: <code>$fake</code>";
|
||||
}
|
||||
$text[] = 'transport: ' . ($p['transport'] ?: 'Reality');
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('changeFakeDomain'),
|
||||
'callback_data' => "/changeFakeDomain",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('selfFakeDomain'),
|
||||
'callback_data' => "/selfFakeDomain",
|
||||
'text' => $p['linkdomain'] ?: $this->i18n('cdn'),
|
||||
'callback_data' => '/addLinkDomain',
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('Reality') . ' ' . ($p['transport'] != 'Websocket' ? $this->i18n('on') : $this->i18n('off')),
|
||||
'callback_data' => "/changeTransport",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('Websocket') . ' ' . ($p['transport'] == 'Websocket' ? $this->i18n('on') : $this->i18n('off')),
|
||||
'callback_data' => "/changeTransport 1",
|
||||
],
|
||||
];
|
||||
if ($p['transport'] != 'Websocket') {
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('changeFakeDomain'),
|
||||
'callback_data' => "/changeFakeDomain",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('selfFakeDomain'),
|
||||
'callback_data' => "/selfFakeDomain",
|
||||
],
|
||||
];
|
||||
}
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('v2ray templates'),
|
||||
@@ -4312,6 +4529,7 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$text[] = "Menu -> " . $this->i18n('warp');
|
||||
$text[] = "status: " . $this->warpStatus();
|
||||
$text[] = "key: " . $this->getPacConf()['warp'];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('set key'),
|
||||
@@ -4390,12 +4608,12 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$c = $this->getXray()['inbounds'][0]['settings']['clients'][$i];
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
$domain = $this->getDomain($pac['transport'] == 'Websocket');
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . " -> {$c['email']}\n";
|
||||
$text[] = "<code>{$this->linkXray($i)}</code>\n";
|
||||
$text[] = "<pre><code>{$this->linkXray($i)}</code></pre>\n";
|
||||
|
||||
$text[] = "import subscribe:";
|
||||
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=v&s={$c['id']}#{$c['email']}'>v2rayng</a>";
|
||||
@@ -4403,8 +4621,8 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=st&s={$c['id']}#{$c['email']}'>streisand</a>";
|
||||
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=h&s={$c['id']}#{$c['email']}'>hiddify</a>";
|
||||
|
||||
$text[] = "\nv2ray config: <code>$scheme://{$domain}/pac?h=$hash&t=s&s={$c['id']}</code>";
|
||||
$text[] = "sing-box config: <code>$scheme://{$domain}/pac?h=$hash&t=si&s={$c['id']}</code>";
|
||||
$text[] = "\nv2ray config: <pre><code>$scheme://{$domain}/pac?h=$hash&t=s&s={$c['id']}</code></pre>";
|
||||
$text[] = "sing-box config: <pre><code>$scheme://{$domain}/pac?h=$hash&t=si&s={$c['id']}</code></pre>";
|
||||
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac?h=$hash&t=si&r=w&s={$c['id']}'>windows service</a>";
|
||||
|
||||
$data[] = [
|
||||
@@ -4441,9 +4659,17 @@ DNS-over-HTTPS with IP:
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('show QR'),
|
||||
'text' => $this->i18n('qr short'),
|
||||
'callback_data' => "/qrXray $i",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('qr v2ray'),
|
||||
'callback_data' => "/qrXray {$i}_1",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('qr singbox'),
|
||||
'callback_data' => "/qrXray {$i}_2",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
@@ -4469,17 +4695,26 @@ DNS-over-HTTPS with IP:
|
||||
);
|
||||
}
|
||||
|
||||
public function getDomain($cdn = false)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
if ($cdn && $c['linkdomain']) {
|
||||
return $c['linkdomain'];
|
||||
}
|
||||
return $c['domain'] ?: $this->ip;
|
||||
}
|
||||
|
||||
public function v2raySubscription($key, $fs = 0)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
$domain = $this->getDomain();
|
||||
$xr = $this->getXray();
|
||||
|
||||
$flag = true;
|
||||
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
if ($v['id'] == $key) {
|
||||
if (!empty($fs)) {
|
||||
return $this->userXr($k, 0, 1);
|
||||
return $this->userXr($k);
|
||||
}
|
||||
if (empty($v['off'])) {
|
||||
$flag = false;
|
||||
@@ -4512,7 +4747,7 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$type = $_GET['t'] == 's' ? 'v2ray' : 'sing';
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
$domain = $_GET['cdn'] ?: ($_SERVER['SERVER_NAME'] ?: $this->getDomain($pac['transport'] == 'Websocket'));
|
||||
$xr = $this->getXray();
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
@@ -4525,6 +4760,7 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
$template = base64_decode($v["{$type}template"]);
|
||||
$uid = $v['id'];
|
||||
$email = $v['email'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4538,31 +4774,32 @@ DNS-over-HTTPS with IP:
|
||||
't' => 'si',
|
||||
's' => $uid,
|
||||
]));
|
||||
$v2 = "$scheme://{$domain}/pac?h=$hash&t=s&s=$uid";
|
||||
$v2 = "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 's',
|
||||
's' => $uid,
|
||||
]));
|
||||
switch ($_GET['r']) {
|
||||
case 'si':
|
||||
header("Location: sing-box://import-remote-profile/?url=" . $si);
|
||||
header("Location: sing-box://import-remote-profile/?url=$si");
|
||||
exit;
|
||||
case 'st':
|
||||
header("Location: streisand://import/$v2");
|
||||
exit;
|
||||
case 'v':
|
||||
header("Location: v2rayng://install-config?url=" . urlencode($v2));
|
||||
header("Location: v2rayng://install-config?url=$v2");
|
||||
exit;
|
||||
case 'h':
|
||||
header("Location: hiddify://install-config/?url=" . $si);
|
||||
header("Location: hiddify://install-config/?url=$si");
|
||||
exit;
|
||||
case 'w':
|
||||
$link = htmlspecialchars($si, ENT_XML1, 'UTF-8');
|
||||
file_put_contents('/singbox/winsw3.xml', preg_replace('#~url~#', $link, file_get_contents('/singbox/winsw3.xml')));
|
||||
$zip = new ZipArchive();
|
||||
$n = "singbox_$uid.zip";
|
||||
$zip->open($n, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
foreach (scandir('/singbox') as $k => $v) {
|
||||
if (!empty(!in_array($v, ['.', '..']))) {
|
||||
$zip->addFile("/singbox/$v", $v);
|
||||
}
|
||||
}
|
||||
copy('/singbox/singbox.zip', $n);
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($n, ZipArchive::CREATE);
|
||||
$zip->addFile('/singbox/winsw3.xml', 'winsw3.xml');
|
||||
$zip->close();
|
||||
header('Content-Disposition: attachment; filename="singbox.zip"');
|
||||
echo file_get_contents($n);
|
||||
@@ -4588,11 +4825,42 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
switch ($_GET['t']) {
|
||||
case 's':
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain;
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]['id'] = $uid;
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['serverName'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['publicKey'] = $pac['xray'];
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['shortId'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain;
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [
|
||||
'id' => $uid,
|
||||
'encryption' => 'none',
|
||||
];
|
||||
if ($pac['transport'] == 'Websocket') {
|
||||
$c['outbounds'][0]['streamSettings'] = [
|
||||
"network" => "ws",
|
||||
"security" => "tls",
|
||||
"wsSettings" => [
|
||||
"path" => "/ws?ed=2560"
|
||||
],
|
||||
"tlsSettings" => [
|
||||
"allowInsecure" => false,
|
||||
"serverName" => $domain,
|
||||
"fingerprint" => "chrome"
|
||||
]
|
||||
];
|
||||
unset($c['outbounds'][0]['mux']);
|
||||
} else {
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]["flow"] = "xtls-rprx-vision";
|
||||
$c['outbounds'][0]['streamSettings'] = [
|
||||
"network" => "tcp",
|
||||
"security" => "reality",
|
||||
"realitySettings" => [
|
||||
"serverName" => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
||||
"fingerprint" => "chrome",
|
||||
"publicKey" => $pac['xray'],
|
||||
"shortId" => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
||||
]
|
||||
];
|
||||
$c['outbounds'][0]['mux'] = [
|
||||
"enabled" => false,
|
||||
"concurrency" => -1
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($c['routing']['rules'] as $k => $v) {
|
||||
if (array_key_exists('domain', $v) && $v['domain'] == '~pac~') {
|
||||
@@ -4606,14 +4874,27 @@ DNS-over-HTTPS with IP:
|
||||
break;
|
||||
case 'si':
|
||||
if ($c['dns']['servers'][0]['address'] == '~dns~') {
|
||||
$c['dns']['servers'][0]['address'] = "tls://" . ($pac['adguardkey'] ? "{$pac['adguardkey']}." : '') . "$domain";
|
||||
$c['dns']['servers'][0]['address'] = "https://$domain/dns-query/$uid";
|
||||
}
|
||||
|
||||
$c['outbounds'][0]['server'] = $domain;
|
||||
$c['outbounds'][0]['uuid'] = $uid;
|
||||
if ($pac['transport'] == 'Websocket') {
|
||||
unset($c['outbounds'][0]['tls']['reality']);
|
||||
unset($c['outbounds'][0]['flow']);
|
||||
$c['outbounds'][0]["transport"] = [
|
||||
"type" => "ws",
|
||||
"path" => "/ws"
|
||||
];
|
||||
$c['outbounds'][0]['tls']['server_name'] = $domain;
|
||||
} else {
|
||||
unset($c['outbounds'][0]["transport"]);
|
||||
$c['outbounds'][0]['flow'] = 'xtls-rprx-vision';
|
||||
$c['outbounds'][0]['tls']['reality']['public_key'] = $pac['xray'];
|
||||
$c['outbounds'][0]['tls']['server_name'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
|
||||
$c['outbounds'][0]['tls']['reality']['short_id'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
|
||||
}
|
||||
|
||||
$c['outbounds'][0]['server'] = $domain;
|
||||
$c['outbounds'][0]['uuid'] = $uid;
|
||||
$c['outbounds'][0]['tls']['reality']['public_key'] = $pac['xray'];
|
||||
$c['outbounds'][0]['tls']['server_name'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
|
||||
$c['outbounds'][0]['tls']['reality']['short_id'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
|
||||
foreach ($c['route']['rules'] as $k => $v) {
|
||||
if (array_key_exists('domain_suffix', $v) && $v['domain_suffix'] == '~pac~') {
|
||||
$c['route']['rules'][$k]['domain_suffix'] = array_keys(array_filter($pac['includelist'] ?: []));
|
||||
@@ -4625,7 +4906,7 @@ DNS-over-HTTPS with IP:
|
||||
$c['route']['rules'] = array_values($c['route']['rules']);
|
||||
$c['route'] = $this->addRuleSet($c['route']);
|
||||
$c['route'] = $this->addPackageRule($c['route']);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
|
||||
$c['route'] = $this->clearEmptyRules($c['route']);
|
||||
break;
|
||||
}
|
||||
@@ -4641,21 +4922,18 @@ DNS-over-HTTPS with IP:
|
||||
unset($route['rules'][$k]);
|
||||
}
|
||||
}
|
||||
$route['rules'] = array_values($route['rules']);
|
||||
return $route;
|
||||
}
|
||||
|
||||
public function addPackageRule($route)
|
||||
{
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
$t[$v['outbound']] = $k;
|
||||
}
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($p['packagelist'])) {
|
||||
foreach ($p['packagelist'] as $k => $v) {
|
||||
if (!empty($v)) {
|
||||
$route['rules'][$t['proxy']]['package_name'][] = $k;
|
||||
}
|
||||
}
|
||||
if (!empty($t = array_filter($p['packagelist'] ?: []))) {
|
||||
$route['rules'][] = [
|
||||
'package_name' => array_keys($t),
|
||||
'outbound' => $p['app_outbound'] ? 'direct' : 'proxy',
|
||||
];
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
@@ -4685,10 +4963,9 @@ DNS-over-HTTPS with IP:
|
||||
return $route;
|
||||
}
|
||||
|
||||
public function createRuleSet($route, $uid)
|
||||
public function createRuleSet($route, $uid, $domain)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $pac['domain'] ?: $this->ip;
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
|
||||
@@ -4776,6 +5053,8 @@ DNS-over-HTTPS with IP:
|
||||
$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0] = $shortId;
|
||||
$pac = $this->getPacConf();
|
||||
$pac['xray'] = $public;
|
||||
$pac['reality']['shortId'] = $shortId;
|
||||
$pac['reality']['privateKey'] = $private;
|
||||
$this->setPacConf($pac);
|
||||
$this->restartXray($c);
|
||||
}
|
||||
@@ -4903,7 +5182,7 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$conf = $this->getPacConf();
|
||||
$ip = $this->ip;
|
||||
$domain = $conf['domain'] ?: $ip;
|
||||
$domain = $this->getDomain();
|
||||
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$text = "$scheme://$domain/adguard\nLogin: admin\nPass: <span class='tg-spoiler'>{$conf['adpswd']}</span>\n\n";
|
||||
if ($ssl) {
|
||||
@@ -5007,6 +5286,15 @@ DNS-over-HTTPS with IP:
|
||||
return openssl_x509_parse($c)["validTo_time_t"] ?: false;
|
||||
}
|
||||
|
||||
public function domainsCert()
|
||||
{
|
||||
$domains = openssl_x509_parse(openssl_x509_read(file_get_contents("/certs/cert_public")))['extensions']["subjectAltName"];
|
||||
if (empty($domains)) {
|
||||
return false;
|
||||
}
|
||||
return implode("\n", array_map(fn($e) => trim($e), explode(',', str_replace('DNS:', '', $domains))));
|
||||
}
|
||||
|
||||
public function updatebot()
|
||||
{
|
||||
$b = exec('git -C / rev-parse --abbrev-ref HEAD');
|
||||
@@ -5060,10 +5348,16 @@ DNS-over-HTTPS with IP:
|
||||
public function configMenu()
|
||||
{
|
||||
exec('git -C / fetch');
|
||||
$conf = $this->getPacConf();
|
||||
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\nnp.{$conf['domain']}\noc.{$conf['domain']}" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']}" : '') : $this->i18n('domain explain');
|
||||
$conf = $this->getPacConf();
|
||||
if (!empty($conf['subdomain'])) {
|
||||
$custom = "\ncustom:\n";
|
||||
foreach ($conf['subdomain'] as $v) {
|
||||
$custom .= "$v\n";
|
||||
}
|
||||
}
|
||||
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\nnp.{$conf['domain']} (for naiveproxy)\noc.{$conf['domain']} (for openconnect)" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']} (for adguard DoT)" : '') . $custom : $this->i18n('domain explain');
|
||||
$ssl = $this->expireCert();
|
||||
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) : 'none') : '';
|
||||
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) . "\n" . $this->domainsCert() : 'none') : '';
|
||||
|
||||
$data = [
|
||||
[
|
||||
@@ -5071,6 +5365,10 @@ DNS-over-HTTPS with IP:
|
||||
'text' => $conf['domain'] ? "{$this->i18n('delete')} {$conf['domain']}" : $this->i18n('install domain'),
|
||||
'callback_data' => $conf['domain'] ? '/deldomain' : '/domain',
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('+ subdomain'),
|
||||
'callback_data' => '/addSubdomain',
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($conf['domain']) {
|
||||
@@ -5349,8 +5647,12 @@ DNS-over-HTTPS with IP:
|
||||
public function setFakeDomain($domain, $self = false)
|
||||
{
|
||||
$c = $this->getXray();
|
||||
$p = $this->getPacConf();
|
||||
$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] = $domain;
|
||||
$c['inbounds'][0]['streamSettings']['realitySettings']['dest'] = $self ? "10.10.1.2:443" : "$domain:443";
|
||||
$p['reality']['domain'] = $domain;
|
||||
$p['reality']['destination'] = $self ? "10.10.1.2:443" : "$domain:443";
|
||||
$this->setPacConf($p);
|
||||
$this->restartXray($c);
|
||||
$this->setUpstreamDomain($domain);
|
||||
$this->xray();
|
||||
@@ -5366,6 +5668,58 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
|
||||
public function changeTransport($ws = null)
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
$x = $this->getXray();
|
||||
$p['transport'] = $ws ? 'Websocket' : 'Reality';
|
||||
if (!empty($ws)) {
|
||||
$p['reality']['domain'] = $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] ?: $p['reality']['domain'];
|
||||
$p['reality']['destination'] = $x['inbounds'][0]['streamSettings']['realitySettings']['dest'] ?: $p['reality']['destination'];
|
||||
$p['reality']['shortId'] = $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0] ?: $p['reality']['shortId'];
|
||||
foreach ($x['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
unset($x['inbounds'][0]['settings']['clients'][$k]['flow']);
|
||||
}
|
||||
$x['inbounds'][0]['streamSettings'] = [
|
||||
"network" => "ws",
|
||||
"wsSettings" => [
|
||||
"path" => "/ws"
|
||||
]
|
||||
];
|
||||
} else {
|
||||
foreach ($x['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
$x['inbounds'][0]['settings']['clients'][$k]['flow'] = 'xtls-rprx-vision';
|
||||
}
|
||||
$x['inbounds'][0]['streamSettings'] = [
|
||||
"network" => "tcp",
|
||||
"realitySettings" => [
|
||||
"dest" => $p['reality']['destination'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['dest'],
|
||||
"maxClientVer" => "",
|
||||
"maxTimeDiff" => 0,
|
||||
"minClientVer" => "",
|
||||
"privateKey" => $p['reality']['privateKey'],
|
||||
"serverNames" => [
|
||||
$p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]
|
||||
],
|
||||
"shortIds" => [$p['reality']['shortId']] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
||||
"show" => false,
|
||||
"xver" => 0
|
||||
],
|
||||
"tcpSettings" => [
|
||||
"acceptProxyProtocol" => true
|
||||
],
|
||||
"sockopt" => [
|
||||
"acceptProxyProtocol" => true
|
||||
],
|
||||
"security" => "reality"
|
||||
];
|
||||
}
|
||||
$this->setUpstreamDomain($ws ? 't' : ($p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
||||
$this->setPacConf($p);
|
||||
$this->restartXray($x);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function setBackup($text)
|
||||
{
|
||||
$text = trim($text);
|
||||
@@ -5510,7 +5864,7 @@ DNS-over-HTTPS with IP:
|
||||
$conf[] = '';
|
||||
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
|
||||
if (!empty($peer['Endpoint'])) {
|
||||
$peer['Endpoint'] = ($pac['domain'] && !$pac[$this->getInstanceWG(1) . 'amnezia'] ? $pac['domain'] : $this->ip) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
|
||||
$peer['Endpoint'] = ($this->getPacConf()[$this->getInstanceWG(1) . 'endpoint'] ? $this->ip : $this->getDomain()) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
|
||||
}
|
||||
foreach ($peer as $k => $v) {
|
||||
$conf[] = "$k = $v";
|
||||
@@ -5669,6 +6023,14 @@ DNS-over-HTTPS with IP:
|
||||
return true;
|
||||
}
|
||||
|
||||
public function autoupdate()
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
$p['autoupdate'] = !$p['autoupdate'];
|
||||
$this->setPacConf($p);
|
||||
$this->send($this->input['from'], $this->i18n('autoupdate') . ' ' . $this->i18n($p['autoupdate'] ? 'on' : 'off'));
|
||||
}
|
||||
|
||||
public function disconnect(...$args)
|
||||
{
|
||||
$this->send($this->input['chat'], "disconnect: \n" . var_export($args, true) . "\n", $this->input['message_id']);
|
||||
|
||||
+2
-2
@@ -262,8 +262,8 @@ $i = [
|
||||
'ru' => 'очистить',
|
||||
],
|
||||
'xray' => [
|
||||
'en' => 'XTLS-Reality',
|
||||
'ru' => 'XTLS-Reality',
|
||||
'en' => 'Xray',
|
||||
'ru' => 'Xray',
|
||||
],
|
||||
'geodb' => [
|
||||
'en' => 'GeoIp/GeoSite',
|
||||
|
||||
@@ -48,6 +48,7 @@ http {
|
||||
}
|
||||
location /pac {
|
||||
access_log /logs/nginx_pac_access;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_pass http://php;
|
||||
}
|
||||
location /tlgrm {
|
||||
@@ -64,6 +65,38 @@ http {
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
location /ws {
|
||||
proxy_pass http://xr:443;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 5d;
|
||||
}
|
||||
#-ssl
|
||||
# # The DoH server block
|
||||
# location /dns-query {
|
||||
# access_log /logs/nginx_doh_access;
|
||||
# # Proxy HTTP/1.1, clear the connection header to enable Keep-Alive
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Connection "";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
# proxy_set_header X-Forwarded-For $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Host $remote_addr;
|
||||
|
||||
# # Enable Cache, and set the cache_key to include the request_body
|
||||
# proxy_cache doh_cache;
|
||||
# proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body;
|
||||
|
||||
# # proxy pass to the dohloop upstream
|
||||
# proxy_pass https://ad/dns-query;
|
||||
# }
|
||||
#-ssl
|
||||
location ~\.well-known {
|
||||
access_log /logs/nginx_certbot_access;
|
||||
root /certs/;
|
||||
@@ -107,6 +140,7 @@ http {
|
||||
# }
|
||||
# location /pac {
|
||||
# access_log /logs/nginx_pac_access;
|
||||
# proxy_set_header Host $http_host;
|
||||
# proxy_pass http://php;
|
||||
# }
|
||||
# location ~\.well-known {
|
||||
@@ -124,6 +158,17 @@ http {
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# }
|
||||
# location /ws {
|
||||
# proxy_pass http://xr:443;
|
||||
# proxy_redirect off;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_read_timeout 5d;
|
||||
# }
|
||||
#-domain
|
||||
#-ssl
|
||||
# # The DoH server block
|
||||
|
||||
@@ -48,6 +48,7 @@ http {
|
||||
}
|
||||
location /pac {
|
||||
access_log /logs/nginx_pac_access;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_pass http://php;
|
||||
}
|
||||
location /tlgrm {
|
||||
@@ -64,6 +65,38 @@ http {
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
location /ws {
|
||||
proxy_pass http://xr:443;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 5d;
|
||||
}
|
||||
#-ssl
|
||||
# # The DoH server block
|
||||
# location /dns-query {
|
||||
# access_log /logs/nginx_doh_access;
|
||||
# # Proxy HTTP/1.1, clear the connection header to enable Keep-Alive
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Connection "";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
# proxy_set_header X-Forwarded-For $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Host $remote_addr;
|
||||
|
||||
# # Enable Cache, and set the cache_key to include the request_body
|
||||
# proxy_cache doh_cache;
|
||||
# proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body;
|
||||
|
||||
# # proxy pass to the dohloop upstream
|
||||
# proxy_pass https://ad/dns-query;
|
||||
# }
|
||||
#-ssl
|
||||
location ~\.well-known {
|
||||
access_log /logs/nginx_certbot_access;
|
||||
root /certs/;
|
||||
@@ -107,6 +140,7 @@ http {
|
||||
# }
|
||||
# location /pac {
|
||||
# access_log /logs/nginx_pac_access;
|
||||
# proxy_set_header Host $http_host;
|
||||
# proxy_pass http://php;
|
||||
# }
|
||||
# location ~\.well-known {
|
||||
@@ -124,6 +158,17 @@ http {
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# }
|
||||
# location /ws {
|
||||
# proxy_pass http://xr:443;
|
||||
# proxy_redirect off;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_read_timeout 5d;
|
||||
# }
|
||||
#-domain
|
||||
#-ssl
|
||||
# # The DoH server block
|
||||
|
||||
@@ -3,7 +3,7 @@ b:
|
||||
u: # запуск контейнеров
|
||||
bash ./update/update.sh &
|
||||
touch ./override.env
|
||||
IP=$(shell curl https://ipinfo.io/ip) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
IP=$(shell curl ipinfo.io/ip) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
d: # остановка контейнеров
|
||||
-kill -9 $(shell cat ./update/update_pid) > /dev/null
|
||||
docker compose down --remove-orphans
|
||||
|
||||
+5
-1
@@ -16,7 +16,11 @@ echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') \
|
||||
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt update
|
||||
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
apt install -y docker-ce docker-ce-cli containerd.io
|
||||
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
|
||||
mkdir -p $DOCKER_CONFIG/cli-plugins
|
||||
curl -SL https://github.com/docker/compose/releases/download/v2.29.6/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
|
||||
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
|
||||
git clone https://github.com/mercurykd/vpnbot.git
|
||||
cd ./vpnbot
|
||||
echo "<?php
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
winsw3.exe install
|
||||
pause
|
||||
@@ -1,2 +0,0 @@
|
||||
winsw3.exe stop
|
||||
winsw3.exe start
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
winsw3.exe start
|
||||
@@ -1,2 +0,0 @@
|
||||
winsw3.exe status
|
||||
pause
|
||||
@@ -1 +0,0 @@
|
||||
winsw3.exe stop
|
||||
@@ -1,2 +0,0 @@
|
||||
winsw3.exe uninstall
|
||||
pause
|
||||
+1
-1
@@ -24,7 +24,7 @@ do
|
||||
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "применяю обновления"/')"
|
||||
git pull > ./update/message
|
||||
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "запускаю бота"/')"
|
||||
IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose up -d --force-recreate
|
||||
IP=$(curl ipinfo.io/ip) VER=$(git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
bash $pwd/update/update.sh &
|
||||
> $pwd/update/key
|
||||
> $pwd/update/curl
|
||||
|
||||
@@ -1,3 +1,54 @@
|
||||
29.09.2024 v1.60
|
||||
- ускорение сборки архива sing-box windows
|
||||
23.09.2024 v1.59
|
||||
- docker compose v2.29.6 (при установке бота)
|
||||
22.09.2024 v1.58
|
||||
- фикс запуска бота с правильными параметрами после обновления
|
||||
22.09.2024 v1.57
|
||||
- выбор типа endpoint для wireguard/amnezia
|
||||
22.09.2024 v1.56.2
|
||||
- фикс разных доменов при указании cdn для xray
|
||||
19.09.2024 v1.56.1
|
||||
- cdn для xray
|
||||
17.09.2024 v1.55
|
||||
- возможность подменить домен в ссылках на конфиги
|
||||
16.09.2024 v1.54.2
|
||||
- фикс нэйминга клиентов в adguardHome: замена на uuid
|
||||
16.09.2024 v1.54.1
|
||||
- фикс нэйминга клиентов в adguardHome
|
||||
16.09.2024 v1.54
|
||||
- ~dns~ в шаблоне сингбокса подменяятся на https://DOMAIN/dns-query/USERNAME
|
||||
- при добавлении пользователя в XRAY, он также добавляется в AdguardHome как сохраненый клиент
|
||||
10.09.2024 v1.53
|
||||
- домен в endpoint для амнезии
|
||||
10.09.2024 v1.52
|
||||
- фикс спамящего уведомления о просрочке сертификата
|
||||
10.09.2024 v1.51
|
||||
- фикс ipinfo
|
||||
08.09.2024 v1.50
|
||||
- fix import with transport
|
||||
08.09.2024 v1.49
|
||||
- fix add user xray with transport
|
||||
08.09.2024 v1.48
|
||||
- fix change xray transport, save private key xray
|
||||
08.09.2024 v1.47
|
||||
- fix websocket -> reality
|
||||
03.09.2024 v1.46.2
|
||||
- fix link v2ray
|
||||
03.09.2024 v1.46.1
|
||||
- fix import
|
||||
- fix websocket domain
|
||||
03.09.2024 v1.46
|
||||
- возможность добавить кастомный поддомен для Letsencrypt
|
||||
03.09.2024 v1.45
|
||||
- выбор транспорта reality/websocket
|
||||
26.08.2024 v1.44
|
||||
- qr для xtls
|
||||
- фикс действий на элементом списков
|
||||
21.08.2024 v1.43
|
||||
- singbox:поддержка кастомных outbound для ruleset
|
||||
16.08.2024 v1.42.1
|
||||
- фикс добавления рулсетов с длинными урл
|
||||
16.08.2024 v1.42
|
||||
- добавлена возможность сохранять/восстанавливать список доменов/правил маршрутизации
|
||||
- изменена ссылка на сингбокс-конфиг для совместимости с клиентом сингбокса (фикс импорта в sing-box)
|
||||
|
||||
Reference in New Issue
Block a user