Compare commits

...

32 Commits

Author SHA1 Message Date
mercury ca92ca703f update version 2025-02-08 15:52:49 +04:00
mercury f527888db8 vless: singbox 1.11 migrate 2025-02-08 15:51:44 +04:00
mercury 0e47a771cc Reapply "update singbox 1.11 windows x64"
This reverts commit 414a67c10d.
2025-02-08 15:51:20 +04:00
mercury ff10cbefc8 vless: fix reset stats 2025-02-07 22:44:55 +04:00
mercury 3371ba4bae update version 2025-02-07 00:53:07 +04:00
mercury 621fb08467 vless stats fix 2025-02-07 00:47:52 +04:00
mercury 5153b2c94a vless stats fix 2025-02-07 00:36:49 +04:00
mercury 1e9461cc49 vless: global stats traffic 2025-02-06 17:34:25 +04:00
mercury 88f48a036c autoclean logs 2025-02-06 17:33:56 +04:00
mercury b40e052d3f vless: add user with uuid 2025-02-06 16:34:14 +04:00
mercury a43082ae27 vless: global stats traffic 2025-02-06 16:25:36 +04:00
mercury c2cd945991 hashbot migration with backup 2025-02-06 16:09:21 +04:00
mercury 0737327e4b vless ip limit: ability change window time 2025-02-05 21:34:01 +04:00
mercury f620bf12cd vless ip limit: improve message 2025-02-05 17:26:03 +04:00
mercury 8b3730c61f vless ip limit improve 2025-02-05 17:01:52 +04:00
mercury c6d9dcd47b vless: batch adding users 2025-02-05 16:13:55 +04:00
mercury d83ba51d81 vless ip limit 2025-02-05 16:00:32 +04:00
mercury 1a593100b7 update version 2025-02-02 14:24:05 +04:00
mercury 414a67c10d Revert "update singbox 1.11 windows x64"
This reverts commit 284b025881.
2025-02-02 13:29:51 +04:00
mercury f92b484011 Revert "fix singbox template"
This reverts commit 86261e6b76.
2025-02-02 11:52:02 +04:00
mercury 7af0276944 Revert "Migrate to sing-box 1.11"
This reverts commit 6d1ab0cb3a.
2025-02-02 01:56:15 +04:00
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
10 changed files with 438 additions and 67 deletions
+349 -43
View File
@@ -13,6 +13,7 @@ class Bot
public $mtu;
public $logs;
public $reg;
public $pool;
public function __construct($key, $i18n)
{
@@ -161,6 +162,9 @@ class Bot
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
$this->switchBanIp();
break;
case preg_match('~^/setIpLimit$~', $this->input['callback'], $m):
$this->setIpLimit();
break;
case preg_match('~^/searchLogs (.+)$~', $this->input['message'], $m):
$this->searchLogs($m[1]);
break;
@@ -378,6 +382,12 @@ class Bot
case preg_match('~^/renameXrUser (\d+)$~', $this->input['callback'], $m):
$this->renameXrUser($m[1]);
break;
case preg_match('~^/resetXrUser (\d+)$~', $this->input['callback'], $m):
$this->resetXrUser($m[1]);
break;
case preg_match('~^/resetXrStats$~', $this->input['callback'], $m):
$this->resetXrStats();
break;
case preg_match('~^/v2ray$~', $this->input['callback'], $m):
$this->v2ray();
break;
@@ -541,6 +551,9 @@ class Bot
case preg_match('~^/xtlsprocess(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsprocess($m[1] ?: 0);
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):
$this->xtlsrulesset($m[1] ?: 0);
break;
@@ -571,6 +584,9 @@ class Bot
case preg_match('~^/changeFakeDomain$~', $this->input['callback'], $m):
$this->changeFakeDomain();
break;
case preg_match('~^/autoCleanLogs$~', $this->input['callback'], $m):
$this->autoCleanLogs();
break;
case preg_match('~^/selfFakeDomain$~', $this->input['callback'], $m):
$this->selfFakeDomain();
break;
@@ -730,9 +746,21 @@ class Bot
}
public function collectSession($c) {
$p = $this->getPacConf();
$p['vlessstat']['global'] = [
'download' => $p['vlessstat']['global']['download'] + $p['vlessstat']['session']['download'],
'upload' => $p['vlessstat']['global']['upload'] + $p['vlessstat']['session']['upload'],
];
$p['vlessstat']['session'] = [
'download' => 0,
'upload' => 0,
];
$this->setPacConf($p);
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]['session']['download'] = 0;
$c['inbounds'][0]['settings']['clients'][$k]['global']['upload'] += $v['session']['upload'];
$c['inbounds'][0]['settings']['clients'][$k]['session']['upload'] = 0;
}
return $c;
}
@@ -1000,7 +1028,7 @@ class Bot
$this->input['chat'],
"@{$this->input['username']} enter name",
$this->input['message_id'],
reply: 'enter password',
reply: 'enter name:uuid [,name:uuid]',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
@@ -1310,6 +1338,7 @@ class Bot
$this->shutdownClientXr();
$this->checkVersion();
$this->checkBackup($period);
$this->checkLogs($period);
$this->checkCert();
$this->autoAnalyzeLogs();
$this->xrayStatsUser();
@@ -1320,7 +1349,13 @@ class Bot
public function xrayStatsUser()
{
try {
$x = $this->getXray();
$x = $this->getXray();
$p = $this->getPacConf();
$td = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "inbound>>>vless_tls>>>traffic>>>downlink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
$tu = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "inbound>>>vless_tls>>>traffic>>>uplink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
$p['vlessstat']['session']['download'] = $td;
$p['vlessstat']['session']['upload'] = $tu;
$this->setPacConf($p);
if (!empty($users = $x['inbounds'][0]['settings']['clients'])) {
foreach ($users as $k => $v) {
$d = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "user>>>' . $v['email'] . '>>>traffic>>>downlink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
@@ -1402,6 +1437,26 @@ class Bot
}
}
public function checkLogs($delta)
{
$c = $this->getPacConf();
if (!empty($c['autocleanlogs'])) {
$now = strtotime(date('Y-m-d H:i:s'));
[$start, $period] = explode('/', $c['autocleanlogs']);
$start = strtotime(trim($start));
$period = strtotime(trim($period), 0);
if (
!empty($start)
&& !empty($period)
&& empty($this->backup)
&& $now - $start >= 0
&& (($now - $start) % $period < $delta)
) {
$this->cleanLog();
}
}
}
public function cleanQueue(): void
{
$r = $this->request('deleteWebhook', []);
@@ -2362,6 +2417,21 @@ class Bot
];
}
public function setIpLimit()
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter seconds",
$this->input['message_id'],
reply: 'enter seconds',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'callback' => 'switchIpLimit',
'args' => [],
];
}
public function addLinkDomain()
{
$r = $this->send(
@@ -2693,15 +2763,15 @@ DNS-over-HTTPS with IP:
$this->xtlswarp();
break;
case 'processlist':
$this->xrayUpdateRules();
$this->xtlsprocess();
break;
case 'packagelist':
$this->xrayUpdateRules();
$this->xtlsapp();
break;
case 'subnetlist':
$this->xtlssubnet();
break;
case 'rulessetlist':
$this->xrayUpdateRules();
$this->xtlsrulesset();
break;
case 'white':
@@ -3516,8 +3586,6 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('delete'),
'callback_data' => "/delete {$client}_$page",
],
],
[
[
'text' => $this->i18n('back'),
'callback_data' => "/menu wg $page",
@@ -3751,6 +3819,12 @@ DNS-over-HTTPS with IP:
case 'packagelist':
$dir = 'PACKAGE';
break;
case 'processlist':
$dir = 'PROCESS';
break;
case 'subnetlist':
$dir = 'SUBNET';
break;
case 'rulessetlist':
$dir = 'rulesset';
break;
@@ -3797,6 +3871,22 @@ DNS-over-HTTPS with IP:
],
];
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':
$data[] = [
[
@@ -3944,7 +4034,25 @@ DNS-over-HTTPS with IP:
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> process list';
[$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[] = [
[
'text' => $this->i18n('back'),
@@ -4000,7 +4108,7 @@ DNS-over-HTTPS with IP:
}
$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),
],
[
@@ -4200,12 +4308,6 @@ DNS-over-HTTPS with IP:
'main' => [
'text' => implode("\n", $main ?: []),
'data' => [
[
[
'text' => $this->i18n('config'),
'callback_data' => "/menu config",
],
],
[
[
'text' => $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'),
@@ -4256,10 +4358,16 @@ DNS-over-HTTPS with IP:
'callback_data' => "/pacMenu 0",
],
],
[
[
'text' => $this->i18n('config'),
'callback_data' => "/menu config",
],
],
[
[
'text' => $this->i18n('chat'),
'url' => "https://t.me/+Wfxg6-nrokBlMmYy",
'url' => base64_decode('aHR0cHM6Ly90Lm1lLytXZnhnNi1ucm9rQmxNbVl5'),
],
[
'text' => $this->i18n('donate'),
@@ -4338,6 +4446,18 @@ DNS-over-HTTPS with IP:
$this->ipMenu();
}
public function switchIpLimit(int $limit)
{
$c = $this->getPacConf();
if ($limit <= 0) {
unset($c['ip_limit']);
} else {
$c['ip_limit'] = $limit;
}
$this->setPacConf($c);
$this->xray();
}
public function switchSilence()
{
$c = $this->getPacConf();
@@ -4352,12 +4472,6 @@ DNS-over-HTTPS with IP:
$pac = $this->getPacConf();
$d = count($pac['deny'] ?: []);
$w = count($pac['white'] ?: []);
$data[] = [
[
'text' => $this->i18n('logs'),
'callback_data' => "/logs",
],
];
$data[] = [
[
'text' => $this->i18n('autoscan') . ': ' . ($pac['autoscan'] ? $this->getTime(strtotime(($pac['autoscan_timeout'] ?: 3600) . ' seconds')) : $this->i18n('off')),
@@ -5206,22 +5320,30 @@ DNS-over-HTTPS with IP:
$this->menu('oc');
}
public function addxrus($user)
public function addxrus($users)
{
$c = $this->getXray();
$p = $this->getPacConf();
$uuid = trim($this->ssh('xray uuid', 'xr'));
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
'id' => $uuid,
'email' => $user,
] : [
'id' => $uuid,
'flow' => 'xtls-rprx-vision',
'email' => $user,
];
$c = $this->getXray();
$p = $this->getPacConf();
$users = array_map(fn ($e) => trim($e), explode(',', $users));
$users = array_map(fn ($e) => explode(':', $e), $users);
foreach ($users as $user) {
$uuid = $user[1] ?: trim($this->ssh('xray uuid', 'xr'));
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
'id' => $uuid,
'email' => $user[0],
] : [
'id' => $uuid,
'flow' => 'xtls-rprx-vision',
'email' => $user[0],
];
}
$this->restartXray($c);
$this->adguardXrayClients();
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
if (count($users) == 1) {
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
} else {
$this->xray();
}
}
public function setTimerXr($time, $i)
@@ -5271,6 +5393,31 @@ DNS-over-HTTPS with IP:
$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 resetXrStats()
{
$x = $this->getXray();
$p = $this->getPacConf();
unset($p['vlessstat']);
foreach ($x['inbounds'][0]['settings']['clients'] as $k => $v) {
unset($x['inbounds'][0]['settings']['clients'][$k]['global']);
unset($x['inbounds'][0]['settings']['clients'][$k]['session']);
}
$this->restartXray($x);
$this->setPacConf($p);
$this->xray();
}
public function listXr($i)
{
$c = $this->getPacConf();
@@ -5437,6 +5584,7 @@ DNS-over-HTTPS with IP:
<code>~pac~</code>
<code>~package~</code>
<code>~process~</code>
<code>~subnet~</code>
<code>~block~</code>
<code>~warp~</code>
<code>~dns~</code>
@@ -5445,6 +5593,7 @@ DNS-over-HTTPS with IP:
<code>~directdomain~</code>
<code>~cdndomain~</code>
<code>~short_id~</code>
<code>~email~</code>
<code>~public_key~</code>
<code>~server_name~</code>
<code>~ip~</code>
@@ -5569,6 +5718,14 @@ DNS-over-HTTPS with IP:
$text[] = "fake domain: <code>$fake</code>";
}
$text[] = 'transport: ' . ($p['transport'] ?: 'Websocket');
$td = $this->getBytes($p['vlessstat']['global']['download'] + $p['vlessstat']['session']['download']);
$tu = $this->getBytes($p['vlessstat']['global']['upload'] + $p['vlessstat']['session']['upload']);
$data[] = [
[
'text' => $this->i18n('reset stats') . ": ↓$td$tu",
'callback_data' => '/resetXrStats',
],
];
$data[] = [
[
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
@@ -5590,6 +5747,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('Websocket') . ' ' . ($p['transport'] != 'Reality' ? $this->i18n('on') : $this->i18n('off')),
'callback_data' => "/changeTransport 1",
],
[
'text' => $this->i18n('ip limit') . ' ' . ($p['ip_limit'] ? ": {$p['ip_limit']} sec" : $this->i18n('off')),
'callback_data' => "/setIpLimit",
],
];
if ($p['transport'] == 'Reality') {
$data[] = [
@@ -5694,9 +5855,6 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> routes';
$p = $this->getPacConf();
$outbound = $p['outbound'] ?: 'proxy';
$data = [
[[
'text' => $this->i18n('block'),
@@ -5710,6 +5868,10 @@ DNS-over-HTTPS with IP:
'text' => 'domains',
'callback_data' => "/xtlsproxy",
]],
[[
'text' => "subnet",
'callback_data' => "/xtlssubnet",
]],
[[
'text' => 'process',
'callback_data' => "/xtlsprocess",
@@ -5777,6 +5939,79 @@ DNS-over-HTTPS with IP:
return 'off';
}
public function analyzeXray()
{
while (true) {
if (!empty($this->getPacConf()['ip_limit'])) {
$this->pool = [];
$log = '/logs/xray';
$r = fopen($log, 'r');
fseek($r, 0, SEEK_END);
while (true) {
$pac = $this->getPacConf();
if (empty($pac['ip_limit'])) {
break;
}
$currentPosition = ftell($r);
clearstatcache();
$fileSize = filesize($log);
if ($fileSize > $currentPosition) {
fseek($r, $currentPosition); // сброс флага feof
while (!feof($r)) {
$line = fgets($r);
if ($line !== false) {
$this->frequencyAnalyze($line, $pac);
}
}
}
sleep(1);
}
fclose($r);
}
sleep(10);
}
}
public function frequencyAnalyze($line, $pac)
{
preg_match('~(?<date>.+)\sfrom\s(?<ip>\d+\.\d+\.\d+\.\d+)(?=.+email:\s(?<email>.+))~', $line, $m);
if (!empty($this->pool)) {
foreach ($this->pool as $i => $j) {
if (!empty($j['ips'])) {
foreach ($j['ips'] as $k => $v) {
if ($v + $pac['ip_limit'] < time()) {
unset($this->pool[$i]['ips'][$k]);
}
}
}
}
}
if (!empty($m['ip']) && !empty($m['email'])) {
$ip = ip2long($m['ip']);
if (!empty($this->pool[$m['email']]['ip']) && $this->pool[$m['email']]['ip'] != $ip) {
$this->pool[$m['email']]['ips'][$ip] = time();
}
if (!empty($this->pool[$m['email']]['ips']) && count($this->pool[$m['email']]['ips']) > 1) {
$xr = $this->getXray();
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
if (empty($v['off']) && $v['email'] == $m['email']) {
require __DIR__ . '/config.php';
foreach ($c['admin'] as $k => $v) {
$this->send($v, "vless: {$m['email']} is turned off (limit by one IP)");
}
unset($this->pool[$m['email']]);
$this->switchXr($k, 1);
$flag = 1;
break;
}
}
}
if (empty($flag)) {
$this->pool[$m['email']]['ip'] = $ip;
}
}
}
public function offWarp()
{
$p = $this->getPacConf();
@@ -5932,7 +6167,14 @@ DNS-over-HTTPS with IP:
$text[] = "mihomo config: <pre><code>$cl</code></pre>";
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac$hash?t=si&r=w&s={$c['id']}'>windows service</a>";
$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[] = [
[
'text' => $this->i18n('v2ray'),
@@ -6228,12 +6470,14 @@ DNS-over-HTTPS with IP:
'"~warp~"' => json_encode(array_keys(array_filter($pac['warplist'] ?: []))),
'"~process~"' => json_encode(array_keys(array_filter($pac['processlist'] ?: []))),
'"~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",
'~uid~' => $uid,
'~domain~' => $domain,
'~directdomain~' => $pac['domain'],
'~cdndomain~' => $pac['linkdomain'],
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
'~email~' => $email,
'~public_key~' => $pac['xray'],
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
'~ip~' => $this->ip,
@@ -6255,7 +6499,7 @@ DNS-over-HTTPS with IP:
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
if (!empty($c['route']['rules'])) {
foreach ($c['route']['rules'] as $k => $v) {
if (count($v) < 2) {
if (count($v) == 1 && array_key_exists('outbound', $v)) {
unset($c['route']['rules'][$k]);
}
}
@@ -6337,6 +6581,9 @@ DNS-over-HTTPS with IP:
case 'domain':
echo yaml_emit(['payload' => array_map(fn($e) => "+.$e", $v['list'])]);
break;
case 'ipcidr':
echo yaml_emit(['payload' => array_map(fn($e) => $e, $v['list'])]);
break;
default:
echo yaml_emit(['payload' => array_map(fn($e) => "PROCESS-NAME,$e", $v['list'])]);
@@ -6533,7 +6780,13 @@ DNS-over-HTTPS with IP:
public function getHashBot()
{
return substr(hash('sha256', $this->key), 0, 8);
$p = $this->getPacConf();
if (!empty($p['hashbot'])) {
return $p['hashbot'];
}
$p['hashbot'] = substr(hash('sha256', $this->key), 0, 8);
$this->setPacConf($p);
return $p['hashbot'];
}
public function cloakNginx()
@@ -6933,7 +7186,11 @@ DNS-over-HTTPS with IP:
'callback_data' => "/ports",
],
[
'text' => $this->i18n('IP ban & Logs'),
'text' => $this->i18n('logs'),
'callback_data' => "/logs",
],
[
'text' => $this->i18n('IP ban'),
'callback_data' => "/ipMenu",
],
];
@@ -7129,6 +7386,7 @@ DNS-over-HTTPS with IP:
public function logs()
{
$p = $this->getPacConf();
foreach (scandir('/logs/') as $k => $v) {
if (!preg_match('~^\.~', $v)) {
$size = filesize("/logs/$v");
@@ -7150,10 +7408,24 @@ DNS-over-HTTPS with IP:
'callback_data' => "/cleanLog",
],
];
$autocleanlogs = array_filter(explode('/', $p['autocleanlogs']));
if (!empty($autocleanlogs)) {
if (!empty(strtotime($autocleanlogs[0])) && !empty(strtotime($autocleanlogs[1]))) {
$autocleanlogs = "{$autocleanlogs[0]} start / {$autocleanlogs[1]} period";
} else {
$autocleanlogs = $this->i18n('off') . " {$p['autocleanlogs']} - wrong format";
}
}
$data[] = [
[
'text' => $this->i18n('autoclean'). ': ' . ($autocleanlogs ?: $this->i18n('off')),
'callback_data' => "/autoCleanLogs",
],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/ipMenu",
'callback_data' => "/menu config",
],
];
$this->update(
@@ -7249,6 +7521,22 @@ DNS-over-HTTPS with IP:
];
}
public function autoCleanLogs()
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter like: start / period",
$this->input['message_id'],
reply: 'enter like: now / 12 hours',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'start_callback' => $this->input['callback_id'],
'callback' => 'setAutoCleanLogs',
'args' => [],
];
}
public function changeFakeDomain()
{
$r = $this->send(
@@ -7382,6 +7670,24 @@ DNS-over-HTTPS with IP:
$this->menu('config');
}
public function setAutoCleanLogs($text)
{
$text = trim($text);
$c = $this->getPacConf();
if (empty($text)) {
$c['autocleanlogs'] = '';
} else {
[$start, $period] = explode('/', $text);
if (!empty(strtotime($start)) && !empty(strtotime($period))) {
$c['autocleanlogs'] = implode(' / ', [date('Y-m-d H:i', strtotime($start)), trim($period)]);
} else {
$this->send($this->input['from'], $this->input['message'] . ' - wrong format');
}
}
$this->setPacConf($c);
$this->logs();
}
public function debug()
{
$file = __DIR__ . '/config.php';
+1 -1
View File
@@ -30,7 +30,7 @@ $i = [
'ru' => 'PAC',
],
'chat' => [
'en' => 'discussion group',
'en' => 'chat',
'ru' => 'чат поддержки',
],
'back' => [
+10
View File
@@ -0,0 +1,10 @@
<?php
require __DIR__ . '/timezone.php';
// require __DIR__ . '/debug.php';
require __DIR__ . '/bot.php';
require __DIR__ . '/config.php';
require __DIR__ . '/i18n.php';
(new Bot($c['key'], $i))->analyzeXray();
+8
View File
@@ -133,6 +133,14 @@
"behavior": "domain",
"name": "pac"
},
{
"type": "RULE-SET",
"list": "~subnet~",
"action": "PROXY",
"interval": 30,
"behavior": "ipcidr",
"name": "subnet"
},
{
"type": "MATCH",
"action": "DIRECT"
+35 -22
View File
@@ -9,12 +9,12 @@
"tag": "tun-in",
"domain_strategy": "prefer_ipv4",
"interface_name": "sing-tun",
"address": ["172.19.0.1\/30"],
"address": [
"172.19.0.1\/30"
],
"mtu": 1400,
"gso": true,
"auto_route": true,
"strict_route": true,
"sniff": true,
"endpoint_independent_nat": false,
"stack": "mixed",
"platform": {
@@ -27,14 +27,7 @@
},
{
"type": "mixed",
"tag": "mixed-in",
"domain_strategy": "prefer_ipv4",
"listen": "127.0.0.1",
"listen_port": 2080,
"tcp_fast_open": true,
"sniff": true,
"sniff_override_destination": false,
"users": []
"tag": "in"
}
],
"dns": {
@@ -92,23 +85,28 @@
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"auto_detect_interface": true,
"override_android_vpn": true,
"rules": [
{
"action": "sniff"
},
{
"protocol": "dns",
"outbound": "dns-out"
"action": "hijack-dns"
},
{
"inbound": "in",
"action": "resolve",
"strategy": "prefer_ipv4"
},
{
"inbound": "in",
"action": "sniff",
"timeout": "1s"
},
{
"addruleset": true,
@@ -129,6 +127,21 @@
],
"outbound": "~outbound~"
},
{
"addruleset": true,
"createruleset": [
{
"name": "subnet",
"interval": "30s",
"rules": [
{
"ip_cidr": "~subnet~"
}
]
}
],
"outbound": "~outbound~"
},
{
"addruleset": true,
"createruleset": [
@@ -172,7 +185,7 @@
]
}
],
"outbound": "block"
"action": "reject"
},
{
"addruleset": true,
@@ -192,4 +205,4 @@
],
"final": "direct"
}
}
}
+5
View File
@@ -110,6 +110,11 @@
"outboundTag": "~outbound~",
"domain": "~pac~"
},
{
"type": "field",
"outboundTag": "~outbound~",
"ip": "~subnet~"
},
{
"type": "field",
"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
### Install:
## Install:
```shell
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
+1
View File
@@ -2,4 +2,5 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys
ssh-keygen -A
exec /usr/sbin/sshd -D -e "$@" &
php service.php
php iplimit.php &
php cron.php
Binary file not shown.
+19
View File
@@ -1,3 +1,22 @@
08.02.2025 v2.11
- vless: singbox 1.11
07.02.2025 v2.10
- vless: ip limit
- vless: общая стата
- vless: пакетное добавление профилей
- vless: при добавлении можно указывать свой uuid (name:uuid, name:uuid, ...)
- автоудаление логов
- хэш бота сохраняется в настройках и восстанавливается с бэкапом. можно накатывать бэкап на нового бота
02.02.2025 v2.9
- откат sing-box 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
- фикс скачивания шаблона михомо
- обновлен singbox.exe