Compare commits

...

11 Commits

Author SHA1 Message Date
mercury 24aaa8756c update version 2025-02-02 00:05:02 +04:00
mercury 07e2beff9b xray stats improve 2025-01-31 18:15:48 +04:00
mercury 86261e6b76 fix singbox template 2025-01-31 12:30:45 +04:00
Konstantin d816582e6f Merge pull request #34 from legiz-ru/dev
Migrate to sing-box 1.11
2025-01-30 19:04:30 +04:00
legiz-ru 6d1ab0cb3a Migrate to sing-box 1.11 2025-01-30 17:55:27 +03:00
legiz-ru 284b025881 update singbox 1.11 windows x64 2025-01-30 17:51:19 +03:00
mercury 0ca93b56a3 vless: ~email~ tag in subscription 2025-01-29 18:18:28 +04:00
mercury 7bcd8de007 vless: reset stats user 2025-01-29 11:04:06 +04:00
mercury 34eb950852 ip-cidr route 2025-01-24 22:09:05 +04:00
mercury 46021855a5 improve wg client menu 2025-01-23 00:55:44 +04:00
mercury 29c18ceb9d update readme 2025-01-20 01:04:24 +04:00
8 changed files with 154 additions and 38 deletions
+94 -19
View File
@@ -378,6 +378,9 @@ class Bot
case preg_match('~^/renameXrUser (\d+)$~', $this->input['callback'], $m): case preg_match('~^/renameXrUser (\d+)$~', $this->input['callback'], $m):
$this->renameXrUser($m[1]); $this->renameXrUser($m[1]);
break; break;
case preg_match('~^/resetXrUser (\d+)$~', $this->input['callback'], $m):
$this->resetXrUser($m[1]);
break;
case preg_match('~^/v2ray$~', $this->input['callback'], $m): case preg_match('~^/v2ray$~', $this->input['callback'], $m):
$this->v2ray(); $this->v2ray();
break; break;
@@ -541,6 +544,9 @@ class Bot
case preg_match('~^/xtlsprocess(?: (\d+))?$~', $this->input['callback'], $m): case preg_match('~^/xtlsprocess(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsprocess($m[1] ?: 0); $this->xtlsprocess($m[1] ?: 0);
break; break;
case preg_match('~^/xtlssubnet(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlssubnet($m[1] ?: 0);
break;
case preg_match('~^/xtlsrulesset(?: (\d+))?$~', $this->input['callback'], $m): case preg_match('~^/xtlsrulesset(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsrulesset($m[1] ?: 0); $this->xtlsrulesset($m[1] ?: 0);
break; break;
@@ -732,7 +738,9 @@ class Bot
public function collectSession($c) { public function collectSession($c) {
foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) { foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) {
$c['inbounds'][0]['settings']['clients'][$k]['global']['download'] += $v['session']['download']; $c['inbounds'][0]['settings']['clients'][$k]['global']['download'] += $v['session']['download'];
$c['inbounds'][0]['settings']['clients'][$k]['session']['download'] = 0;
$c['inbounds'][0]['settings']['clients'][$k]['global']['upload'] += $v['session']['upload']; $c['inbounds'][0]['settings']['clients'][$k]['global']['upload'] += $v['session']['upload'];
$c['inbounds'][0]['settings']['clients'][$k]['session']['upload'] = 0;
} }
return $c; return $c;
} }
@@ -2693,15 +2701,15 @@ DNS-over-HTTPS with IP:
$this->xtlswarp(); $this->xtlswarp();
break; break;
case 'processlist': case 'processlist':
$this->xrayUpdateRules();
$this->xtlsprocess(); $this->xtlsprocess();
break; break;
case 'packagelist': case 'packagelist':
$this->xrayUpdateRules();
$this->xtlsapp(); $this->xtlsapp();
break; break;
case 'subnetlist':
$this->xtlssubnet();
break;
case 'rulessetlist': case 'rulessetlist':
$this->xrayUpdateRules();
$this->xtlsrulesset(); $this->xtlsrulesset();
break; break;
case 'white': case 'white':
@@ -3516,8 +3524,6 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('delete'), 'text' => $this->i18n('delete'),
'callback_data' => "/delete {$client}_$page", 'callback_data' => "/delete {$client}_$page",
], ],
],
[
[ [
'text' => $this->i18n('back'), 'text' => $this->i18n('back'),
'callback_data' => "/menu wg $page", 'callback_data' => "/menu wg $page",
@@ -3751,6 +3757,12 @@ DNS-over-HTTPS with IP:
case 'packagelist': case 'packagelist':
$dir = 'PACKAGE'; $dir = 'PACKAGE';
break; break;
case 'processlist':
$dir = 'PROCESS';
break;
case 'subnetlist':
$dir = 'SUBNET';
break;
case 'rulessetlist': case 'rulessetlist':
$dir = 'rulesset'; $dir = 'rulesset';
break; break;
@@ -3797,6 +3809,22 @@ DNS-over-HTTPS with IP:
], ],
]; ];
break; break;
case 'processlist':
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/xtlsprocess",
],
];
break;
case 'subnetlist':
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/xtlssubnet",
],
];
break;
case 'rulessetlist': case 'rulessetlist':
$data[] = [ $data[] = [
[ [
@@ -3944,7 +3972,25 @@ DNS-over-HTTPS with IP:
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> process list'; $text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> process list';
[$data] = $this->listPac('processlist', $page, 'xtlsprocess'); [$data] = $this->listPac('processlist', $page, 'xtlsprocess');
$p = $this->getPacConf(); $data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/routes",
],
];
$this->update(
$this->input['chat'],
$this->input['message_id'],
implode("\n", $text ?: ['...']),
$data ?: false,
);
}
public function xtlssubnet($page = 0)
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> subnet';
[$data] = $this->listPac('subnetlist', $page, 'xtlssubnet');
$data[] = [ $data[] = [
[ [
'text' => $this->i18n('back'), 'text' => $this->i18n('back'),
@@ -4000,7 +4046,7 @@ DNS-over-HTTPS with IP:
} }
$data[] = [ $data[] = [
[ [
'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . (in_array($type, ['rulessetlist', 'packagelist', 'processlist']) ? $k : idn_to_utf8($k)), 'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . (in_array($type, ['rulessetlist', 'packagelist', 'processlist', 'subnetlist']) ? $k : idn_to_utf8($k)),
'callback_data' => "/change$type " . ($i + $page * $this->limit), 'callback_data' => "/change$type " . ($i + $page * $this->limit),
], ],
[ [
@@ -4200,12 +4246,6 @@ DNS-over-HTTPS with IP:
'main' => [ 'main' => [
'text' => implode("\n", $main ?: []), 'text' => implode("\n", $main ?: []),
'data' => [ 'data' => [
[
[
'text' => $this->i18n('config'),
'callback_data' => "/menu config",
],
],
[ [
[ [
'text' => $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'), 'text' => $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'),
@@ -4256,10 +4296,16 @@ DNS-over-HTTPS with IP:
'callback_data' => "/pacMenu 0", 'callback_data' => "/pacMenu 0",
], ],
], ],
[
[
'text' => $this->i18n('config'),
'callback_data' => "/menu config",
],
],
[ [
[ [
'text' => $this->i18n('chat'), 'text' => $this->i18n('chat'),
'url' => "https://t.me/+Wfxg6-nrokBlMmYy", 'url' => base64_decode('aHR0cHM6Ly90Lm1lLytXZnhnNi1ucm9rQmxNbVl5'),
], ],
[ [
'text' => $this->i18n('donate'), 'text' => $this->i18n('donate'),
@@ -5271,6 +5317,17 @@ DNS-over-HTTPS with IP:
$this->userXr($i); $this->userXr($i);
} }
public function resetXrUser($i)
{
$c = $this->getXray();
$c['inbounds'][0]['settings']['clients'][$i]['global'] = [
'download' => 0,
'upload' => 0,
];
$this->restartXray($c);
$this->userXr($i);
}
public function listXr($i) public function listXr($i)
{ {
$c = $this->getPacConf(); $c = $this->getPacConf();
@@ -5437,6 +5494,7 @@ DNS-over-HTTPS with IP:
<code>~pac~</code> <code>~pac~</code>
<code>~package~</code> <code>~package~</code>
<code>~process~</code> <code>~process~</code>
<code>~subnet~</code>
<code>~block~</code> <code>~block~</code>
<code>~warp~</code> <code>~warp~</code>
<code>~dns~</code> <code>~dns~</code>
@@ -5445,6 +5503,7 @@ DNS-over-HTTPS with IP:
<code>~directdomain~</code> <code>~directdomain~</code>
<code>~cdndomain~</code> <code>~cdndomain~</code>
<code>~short_id~</code> <code>~short_id~</code>
<code>~email~</code>
<code>~public_key~</code> <code>~public_key~</code>
<code>~server_name~</code> <code>~server_name~</code>
<code>~ip~</code> <code>~ip~</code>
@@ -5694,9 +5753,6 @@ DNS-over-HTTPS with IP:
{ {
$text[] = "Menu -> " . $this->i18n('xray') . ' -> routes'; $text[] = "Menu -> " . $this->i18n('xray') . ' -> routes';
$p = $this->getPacConf();
$outbound = $p['outbound'] ?: 'proxy';
$data = [ $data = [
[[ [[
'text' => $this->i18n('block'), 'text' => $this->i18n('block'),
@@ -5710,6 +5766,10 @@ DNS-over-HTTPS with IP:
'text' => 'domains', 'text' => 'domains',
'callback_data' => "/xtlsproxy", 'callback_data' => "/xtlsproxy",
]], ]],
[[
'text' => "subnet",
'callback_data' => "/xtlssubnet",
]],
[[ [[
'text' => 'process', 'text' => 'process',
'callback_data' => "/xtlsprocess", 'callback_data' => "/xtlsprocess",
@@ -5988,6 +6048,14 @@ DNS-over-HTTPS with IP:
'callback_data' => "/qrXray {$i}_2", 'callback_data' => "/qrXray {$i}_2",
], ],
]; ];
$download = $this->getBytes($c['global']['download'] + $c['session']['download']);
$upload = $this->getBytes($c['global']['upload'] + $c['session']['upload']);
$data[] = [
[
'text' => $this->i18n('reset stats') . ": ↓$download$upload",
'callback_data' => "/resetXrUser $i",
],
];
$data[] = [ $data[] = [
[ [
'text' => $this->i18n('rename'), 'text' => $this->i18n('rename'),
@@ -6228,12 +6296,14 @@ DNS-over-HTTPS with IP:
'"~warp~"' => json_encode(array_keys(array_filter($pac['warplist'] ?: []))), '"~warp~"' => json_encode(array_keys(array_filter($pac['warplist'] ?: []))),
'"~process~"' => json_encode(array_keys(array_filter($pac['processlist'] ?: []))), '"~process~"' => json_encode(array_keys(array_filter($pac['processlist'] ?: []))),
'"~package~"' => json_encode(array_keys(array_filter($pac['packagelist'] ?: []))), '"~package~"' => json_encode(array_keys(array_filter($pac['packagelist'] ?: []))),
'"~subnet~"' => json_encode(array_keys(array_filter($pac['subnetlist'] ?: []))),
'~dns~' => "https://$domain/dns-query$hash/$uid", '~dns~' => "https://$domain/dns-query$hash/$uid",
'~uid~' => $uid, '~uid~' => $uid,
'~domain~' => $domain, '~domain~' => $domain,
'~directdomain~' => $pac['domain'], '~directdomain~' => $pac['domain'],
'~cdndomain~' => $pac['linkdomain'], '~cdndomain~' => $pac['linkdomain'],
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0], '~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
'~email~' => $email,
'~public_key~' => $pac['xray'], '~public_key~' => $pac['xray'],
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0], '~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
'~ip~' => $this->ip, '~ip~' => $this->ip,
@@ -6254,11 +6324,11 @@ DNS-over-HTTPS with IP:
$c['route'] = $this->addRuleSet($c['route']); $c['route'] = $this->addRuleSet($c['route']);
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain); $c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
if (!empty($c['route']['rules'])) { if (!empty($c['route']['rules'])) {
foreach ($c['route']['rules'] as $k => $v) { /* foreach ($c['route']['rules'] as $k => $v) {
if (count($v) < 2) { if (count($v) < 2) {
unset($c['route']['rules'][$k]); unset($c['route']['rules'][$k]);
} }
} } */
$c['route']['rules'] = array_values($c['route']['rules']); $c['route']['rules'] = array_values($c['route']['rules']);
} }
break; break;
@@ -6337,6 +6407,9 @@ DNS-over-HTTPS with IP:
case 'domain': case 'domain':
echo yaml_emit(['payload' => array_map(fn($e) => "+.$e", $v['list'])]); echo yaml_emit(['payload' => array_map(fn($e) => "+.$e", $v['list'])]);
break; break;
case 'ipcidr':
echo yaml_emit(['payload' => array_map(fn($e) => $e, $v['list'])]);
break;
default: default:
echo yaml_emit(['payload' => array_map(fn($e) => "PROCESS-NAME,$e", $v['list'])]); echo yaml_emit(['payload' => array_map(fn($e) => "PROCESS-NAME,$e", $v['list'])]);
@@ -6932,6 +7005,8 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('Ports'), 'text' => $this->i18n('Ports'),
'callback_data' => "/ports", 'callback_data' => "/ports",
], ],
];
$data[] = [
[ [
'text' => $this->i18n('IP ban & Logs'), 'text' => $this->i18n('IP ban & Logs'),
'callback_data' => "/ipMenu", 'callback_data' => "/ipMenu",
+1 -1
View File
@@ -30,7 +30,7 @@ $i = [
'ru' => 'PAC', 'ru' => 'PAC',
], ],
'chat' => [ 'chat' => [
'en' => 'discussion group', 'en' => 'chat',
'ru' => 'чат поддержки', 'ru' => 'чат поддержки',
], ],
'back' => [ 'back' => [
+8
View File
@@ -133,6 +133,14 @@
"behavior": "domain", "behavior": "domain",
"name": "pac" "name": "pac"
}, },
{
"type": "RULE-SET",
"list": "~subnet~",
"action": "PROXY",
"interval": 30,
"behavior": "ipcidr",
"name": "subnet"
},
{ {
"type": "MATCH", "type": "MATCH",
"action": "DIRECT" "action": "DIRECT"
+27 -16
View File
@@ -9,9 +9,10 @@
"tag": "tun-in", "tag": "tun-in",
"domain_strategy": "prefer_ipv4", "domain_strategy": "prefer_ipv4",
"interface_name": "sing-tun", "interface_name": "sing-tun",
"address": ["172.19.0.1\/30"], "address": [
"172.19.0.1/30"
],
"mtu": 1400, "mtu": 1400,
"gso": true,
"auto_route": true, "auto_route": true,
"strict_route": true, "strict_route": true,
"sniff": true, "sniff": true,
@@ -48,7 +49,7 @@
}, },
{ {
"tag": "dns-remote", "tag": "dns-remote",
"address": "tcp:\/\/8.8.8.8", "address": "tcp://8.8.8.8",
"address_strategy": "prefer_ipv4", "address_strategy": "prefer_ipv4",
"strategy": "prefer_ipv4", "strategy": "prefer_ipv4",
"detour": "direct" "detour": "direct"
@@ -92,28 +93,23 @@
{ {
"type": "direct", "type": "direct",
"tag": "direct" "tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
} }
], ],
"route": { "route": {
"auto_detect_interface": true, "auto_detect_interface": true,
"override_android_vpn": true, "override_android_vpn": true,
"rules": [ "rules": [
{
"protocol": "dns",
"outbound": "dns-out"
},
{ {
"addruleset": true, "addruleset": true,
"outbound": "direct" "outbound": "direct"
}, },
{
"action": "sniff"
},
{
"protocol": "dns",
"action": "hijack-dns"
},
{ {
"addruleset": true, "addruleset": true,
"createruleset": [ "createruleset": [
@@ -129,6 +125,21 @@
], ],
"outbound": "~outbound~" "outbound": "~outbound~"
}, },
{
"addruleset": true,
"createruleset": [
{
"name": "subnet",
"interval": "30s",
"rules": [
{
"ip_cidr": "~subnet~"
}
]
}
],
"outbound": "~outbound~"
},
{ {
"addruleset": true, "addruleset": true,
"createruleset": [ "createruleset": [
@@ -172,7 +183,7 @@
] ]
} }
], ],
"outbound": "block" "action": "reject"
}, },
{ {
"addruleset": true, "addruleset": true,
+5
View File
@@ -110,6 +110,11 @@
"outboundTag": "~outbound~", "outboundTag": "~outbound~",
"domain": "~pac~" "domain": "~pac~"
}, },
{
"type": "field",
"outboundTag": "~outbound~",
"ip": "~subnet~"
},
{ {
"type": "field", "type": "field",
"outboundTag": "~outbound~", "outboundTag": "~outbound~",
+10 -1
View File
@@ -13,8 +13,17 @@ telegram bot to manage servers (inside the bot)
--- ---
environment: ubuntu 22.04/24.04, debian 11/12 environment: ubuntu 22.04/24.04, debian 11/12
### Install: ## Install:
```shell ```shell
wget -O- https://raw.githubusercontent.com/mercurykd/vpnbot/master/scripts/init.sh | sh -s YOUR_TELEGRAM_BOT_KEY master wget -O- https://raw.githubusercontent.com/mercurykd/vpnbot/master/scripts/init.sh | sh -s YOUR_TELEGRAM_BOT_KEY master
``` ```
#### Restart:
```shell
make r
```
#### autoload:
```shell
crontab -e
```
add `@reboot cd /root/vpnbot && make r` and save
Binary file not shown.
+8
View File
@@ -1,3 +1,11 @@
02.02.2025 v2.8
- vless: корректировка статы юзера
- sing-box 1.11
29.01.2025 v2.7
- vless: сброс статистики юзера
24.01.2025 v2.6
- правки меню
- vless:добавлена возможность маршрутизировать список ip-сетей
18.01.2025 v2.5 18.01.2025 v2.5
- фикс скачивания шаблона михомо - фикс скачивания шаблона михомо
- обновлен singbox.exe - обновлен singbox.exe