Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5eef9581c7 | |||
| 1d9d992361 | |||
| e1f14d85e0 | |||
| dc65e65e20 | |||
| 486a2c5959 | |||
| 39643bf681 | |||
| 5f1fc6d912 | |||
| 0538d04397 | |||
| af9933676d |
+2
-1
@@ -19,4 +19,5 @@ mirror/.env
|
||||
update/*
|
||||
!update/update.sh
|
||||
|
||||
override.env
|
||||
override.env
|
||||
override.html
|
||||
+123
-35
@@ -482,8 +482,8 @@ class Bot
|
||||
case preg_match('~^/proxy$~', $this->input['callback'], $m):
|
||||
$this->proxy();
|
||||
break;
|
||||
case preg_match('~^/showpac$~', $this->input['callback'], $m):
|
||||
$this->showpac();
|
||||
case preg_match('~^/addOverrideHtml$~', $this->input['callback'], $m):
|
||||
$this->addOverrideHtml();
|
||||
break;
|
||||
case preg_match('~^/export$~', $this->input['callback'], $m):
|
||||
$this->exportManual();
|
||||
@@ -809,6 +809,30 @@ class Bot
|
||||
];
|
||||
}
|
||||
|
||||
public function addOverrideHtml()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} attach html",
|
||||
$this->input['message_id'],
|
||||
reply: 'attach html',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'start_callback' => $this->input['callback_id'],
|
||||
'callback' => 'setOverrideHtml',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function setOverrideHtml()
|
||||
{
|
||||
$r = $this->request('getFile', ['file_id' => $this->input['file_id']]);
|
||||
if (!empty($f = file_get_contents($this->file . $r['result']['file_path']))) {
|
||||
file_put_contents('/app/webapp/override.html', $f);
|
||||
}
|
||||
}
|
||||
|
||||
public function restartOcserv($conf)
|
||||
{
|
||||
file_put_contents('/config/ocserv.conf', $conf);
|
||||
@@ -1752,7 +1776,7 @@ class Bot
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
if (empty($c['domain'])) {
|
||||
$this->addDomain(str_replace('.', '-', $this->ip) . '.sslip.io', 1);
|
||||
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io', 1);
|
||||
$this->setSSL('letsencrypt');
|
||||
} else {
|
||||
$this->menu();
|
||||
@@ -4657,14 +4681,27 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=si&s={$c['id']}#{$c['email']}'>sing-box</a>";
|
||||
$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[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=k&s={$c['id']}#{$c['email']}'>karing</a>";
|
||||
|
||||
$si = "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 'si',
|
||||
's' => $c['id'],
|
||||
]));
|
||||
$xr = "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 's',
|
||||
's' => $c['id'],
|
||||
]));
|
||||
|
||||
$text[] = "\nxray config: <pre><code>$xr</code></pre>";
|
||||
$text[] = "sing-box config: <pre><code>$si</code></pre>";
|
||||
|
||||
$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[] = [
|
||||
[
|
||||
'text' => 'v2ray',
|
||||
'text' => 'xray',
|
||||
'web_app' => ['url' => "https://{$domain}/pac?h=$hash&t=s&s={$c['id']}"],
|
||||
],
|
||||
[
|
||||
@@ -4826,17 +4863,19 @@ DNS-over-HTTPS with IP:
|
||||
case 'v':
|
||||
header("Location: v2rayng://install-config?url=$v2");
|
||||
exit;
|
||||
case 'k':
|
||||
header("Location: karing://install-config?url=$si");
|
||||
exit;
|
||||
case 'h':
|
||||
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')));
|
||||
$n = "singbox_$uid.zip";
|
||||
$n = "singbox_$uid.zip";
|
||||
copy('/singbox/singbox.zip', $n);
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($n, ZipArchive::CREATE);
|
||||
$zip->addFile('/singbox/winsw3.xml', 'winsw3.xml');
|
||||
$zip->addFromString('winsw3.xml', preg_replace('#~url~#', $link, file_get_contents('/singbox/winsw3.xml')));
|
||||
$zip->close();
|
||||
header('Content-Disposition: attachment; filename="singbox.zip"');
|
||||
echo file_get_contents($n);
|
||||
@@ -4943,6 +4982,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->addProcessRule($c['route']);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
|
||||
$c['route'] = $this->clearEmptyRules($c['route']);
|
||||
break;
|
||||
@@ -4965,12 +5005,36 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function addPackageRule($route)
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($t = array_filter($p['packagelist'] ?: []))) {
|
||||
$route['rules'][] = [
|
||||
'package_name' => array_keys($t),
|
||||
'outbound' => $p['app_outbound'] ? 'direct' : 'proxy',
|
||||
];
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
if (array_key_exists('package_name', $v)) {
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($t = array_filter($p['packagelist'] ?: []))) {
|
||||
$route['rules'][$k] = [
|
||||
'package_name' => array_keys($t),
|
||||
'outbound' => $p['app_outbound'] ? 'direct' : 'proxy',
|
||||
];
|
||||
} else {
|
||||
unset($route['rules'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
|
||||
public function addProcessRule($route)
|
||||
{
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
if (array_key_exists('process_name', $v)) {
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($t = array_filter($p['processlist'] ?: []))) {
|
||||
$route['rules'][$k] = [
|
||||
'process_name' => array_keys($t),
|
||||
'outbound' => $p['process_outbound'] ? 'direct' : 'proxy',
|
||||
];
|
||||
} else {
|
||||
unset($route['rules'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
@@ -5008,25 +5072,38 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
if (!empty($v['createruleset'])) {
|
||||
foreach ($v['createruleset'] as $i => $r) {
|
||||
foreach ($v['createruleset'] as $r) {
|
||||
foreach ($r['rules'] as $l => $n) {
|
||||
if (array_key_exists('domain_suffix', $n) && $n['domain_suffix'] == '~pac~') {
|
||||
$r['rules'][$l]['domain_suffix'] = array_keys(array_filter($pac['includelist'] ?: []));
|
||||
if (empty($r['rules'][$l]['domain_suffix'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('domain_suffix', $n) && $n['domain_suffix'] == '~warp~') {
|
||||
$r['rules'][$l]['domain_suffix'] = array_keys(array_filter($pac['warplist'] ?: []));
|
||||
if (empty($r['rules'][$l]['domain_suffix'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('domain_suffix', $n) && $n['domain_suffix'] == '~block~') {
|
||||
$r['rules'][$l]['domain_suffix'] = array_keys(array_filter($pac['blocklist'] ?: []));
|
||||
if (empty($r['rules'][$l]['domain_suffix'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
switch (true) {
|
||||
case array_key_exists('domain_suffix', $n):
|
||||
switch ($n['domain_suffix']) {
|
||||
case '~pac~':
|
||||
$t = 'includelist';
|
||||
break;
|
||||
case '~warp~':
|
||||
$t = 'warplist';
|
||||
break;
|
||||
case '~block~':
|
||||
$t = 'blocklist';
|
||||
break;
|
||||
}
|
||||
$r['rules'][$l]['domain_suffix'] = array_keys(array_filter($pac[$t] ?: []));
|
||||
if (empty($r['rules'][$l]['domain_suffix'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
break;
|
||||
case array_key_exists('package_name', $n):
|
||||
$r['rules'][$l]['package_name'] = array_keys(array_filter($pac['packagelist'] ?: []));
|
||||
if (empty($r['rules'][$l]['package_name'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
break;
|
||||
case array_key_exists('process_name', $n):
|
||||
$r['rules'][$l]['process_name'] = array_keys(array_filter($pac['processlist'] ?: []));
|
||||
if (empty($r['rules'][$l]['process_name'])) {
|
||||
unset($r['rules'][$l]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($_GET['r']) && $r['name'] == $_GET['r']) {
|
||||
@@ -5045,18 +5122,23 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
$ruleset[] = [
|
||||
"tag" => $r['name'],
|
||||
"url" => "$scheme://{$domain}/pac?" . http_build_query([
|
||||
"url" => "$scheme://{$domain}/pac/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 'si',
|
||||
's' => $uid,
|
||||
'r' => $r['name'],
|
||||
]),
|
||||
])),
|
||||
"update_interval" => $r['interval'],
|
||||
"type" => "remote",
|
||||
"format" => "binary",
|
||||
"download_detour" => "direct",
|
||||
];
|
||||
$route['rules'][$k]['rule_set'][] = $r['name'];
|
||||
switch (true) {
|
||||
case preg_match('#~(.+)~#', $route['rules'][$k]['outbound'], $m):
|
||||
$route['rules'][$k]['outbound'] = $pac[$m[1]] ? 'direct' : 'proxy';
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($route['rules'][$k]['createruleset']);
|
||||
if (empty($route['rules'][$k]['rule_set'])) {
|
||||
@@ -5502,6 +5584,12 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => "/backup",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('fake html'),
|
||||
'callback_data' => "/addOverrideHtml",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('logs'),
|
||||
|
||||
@@ -337,4 +337,8 @@ $i = [
|
||||
'en' => '🟢 have updates',
|
||||
'ru' => '🟢 есть обновления',
|
||||
],
|
||||
'fake html' => [
|
||||
'en' => 'fake html',
|
||||
'ru' => 'фейк заглушка',
|
||||
],
|
||||
];
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ http {
|
||||
|
||||
location / {
|
||||
root /app;
|
||||
index login.html;
|
||||
index override.html login.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
location /adguard/ {
|
||||
@@ -123,7 +123,7 @@ http {
|
||||
|
||||
# location / {
|
||||
# root /app;
|
||||
# index login.html;
|
||||
# index override.html login.html;
|
||||
# try_files $uri $uri/ =404;
|
||||
# }
|
||||
# location /adguard/ {
|
||||
|
||||
@@ -31,7 +31,7 @@ http {
|
||||
|
||||
location / {
|
||||
root /app;
|
||||
index login.html;
|
||||
index override.html login.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
location /adguard/ {
|
||||
@@ -123,7 +123,7 @@ http {
|
||||
|
||||
# location / {
|
||||
# root /app;
|
||||
# index login.html;
|
||||
# index override.html login.html;
|
||||
# try_files $uri $uri/ =404;
|
||||
# }
|
||||
# location /adguard/ {
|
||||
|
||||
+42
-14
@@ -110,6 +110,48 @@
|
||||
"protocol": "dns",
|
||||
"outbound": "dns-out"
|
||||
},
|
||||
{
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "package",
|
||||
"interval": "15s",
|
||||
"rules": [
|
||||
{
|
||||
"package_name": "~package~"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outbound": "~app_outbound~"
|
||||
},
|
||||
{
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "process",
|
||||
"interval": "15s",
|
||||
"rules": [
|
||||
{
|
||||
"process_name": "~process~"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outbound": "~process_outbound~"
|
||||
},
|
||||
{
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "block",
|
||||
"interval": "15s",
|
||||
"rules": [
|
||||
{
|
||||
"domain_suffix": "~block~"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outbound": "block"
|
||||
},
|
||||
{
|
||||
"createruleset": [
|
||||
{
|
||||
@@ -133,20 +175,6 @@
|
||||
],
|
||||
"outbound": "proxy"
|
||||
},
|
||||
{
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "block",
|
||||
"interval": "15s",
|
||||
"rules": [
|
||||
{
|
||||
"domain_suffix": "~block~"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outbound": "block"
|
||||
},
|
||||
{
|
||||
"outbound": "direct"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
14.10.2024 v1.68
|
||||
- singbox template: package_name -> ruleset
|
||||
13.10.2024 v1.67
|
||||
- sslip.io -> nip.io
|
||||
13.10.2024 v1.66
|
||||
- singbox template: изменен порядок правил маршрутизации для package_name
|
||||
10.10.2024 v1.65.1
|
||||
- фикс создания архива windows service singbox 2
|
||||
09.10.2024 v1.65
|
||||
- фикс создания архива windows service singbox
|
||||
06.10.2024 v1.64.1
|
||||
- добавление html заглушки через меню
|
||||
06.10.2024 v1.64
|
||||
- возможность установить свою html-заглушку
|
||||
06.10.2024 v1.63
|
||||
- приоритет правила block над остальными в стандартном шаблоне sing-box
|
||||
30.09.2024 v1.62
|
||||
- импорт профиля xray в karing
|
||||
30.09.2024 v1.61.1
|
||||
- фикс удаления ключа варпа через ноль
|
||||
29.09.2024 v1.61
|
||||
|
||||
Reference in New Issue
Block a user