Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a21c9b5fe9 | |||
| 696779450f | |||
| 7c5b3dfa3a | |||
| 74404559f9 | |||
| 11e8fb468b | |||
| ca92ca703f | |||
| f527888db8 | |||
| 0e47a771cc | |||
| ff10cbefc8 | |||
| 3371ba4bae | |||
| 621fb08467 | |||
| 5153b2c94a | |||
| 1e9461cc49 | |||
| 88f48a036c | |||
| b40e052d3f | |||
| a43082ae27 | |||
| c2cd945991 | |||
| 0737327e4b | |||
| f620bf12cd | |||
| 8b3730c61f | |||
| c6d9dcd47b | |||
| d83ba51d81 |
+299
-53
@@ -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;
|
||||
@@ -381,6 +385,9 @@ class Bot
|
||||
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;
|
||||
@@ -577,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;
|
||||
@@ -726,7 +736,7 @@ class Bot
|
||||
"statsOutboundDownlink" => true
|
||||
];
|
||||
if (empty($norestart)) {
|
||||
$c = $this->collectSession($c);
|
||||
$this->collectSession();
|
||||
file_put_contents('/config/xray.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
$this->ssh('pkill xray', 'xr');
|
||||
$this->ssh('xray run -config /xray.json > /dev/null 2>&1 &', 'xr');
|
||||
@@ -735,14 +745,23 @@ class Bot
|
||||
}
|
||||
}
|
||||
|
||||
public function collectSession($c) {
|
||||
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;
|
||||
public function collectSession() {
|
||||
$p = $this->getXrayStats();
|
||||
$p['global'] = [
|
||||
'download' => $p['global']['download'] + $p['session']['download'],
|
||||
'upload' => $p['global']['upload'] + $p['session']['upload'],
|
||||
];
|
||||
$p['session'] = [
|
||||
'download' => 0,
|
||||
'upload' => 0,
|
||||
];
|
||||
foreach ($p['clients'] as $k => $v) {
|
||||
$p['clients'][$k]['global']['download'] += $v['session']['download'];
|
||||
$p['clients'][$k]['session']['download'] = 0;
|
||||
$p['clients'][$k]['global']['upload'] += $v['session']['upload'];
|
||||
$p['clients'][$k]['session']['upload'] = 0;
|
||||
}
|
||||
return $c;
|
||||
$this->setXrayStats($p);
|
||||
}
|
||||
|
||||
public function linkMtproto()
|
||||
@@ -1008,7 +1027,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'],
|
||||
@@ -1318,6 +1337,7 @@ class Bot
|
||||
$this->shutdownClientXr();
|
||||
$this->checkVersion();
|
||||
$this->checkBackup($period);
|
||||
$this->checkLogs($period);
|
||||
$this->checkCert();
|
||||
$this->autoAnalyzeLogs();
|
||||
$this->xrayStatsUser();
|
||||
@@ -1328,18 +1348,25 @@ class Bot
|
||||
public function xrayStatsUser()
|
||||
{
|
||||
try {
|
||||
$x = $this->getXray();
|
||||
$x = $this->getXray();
|
||||
$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 = $this->getXrayStats();
|
||||
$p['session'] = [
|
||||
'download' => $td,
|
||||
'upload' => $tu,
|
||||
];
|
||||
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;
|
||||
$u = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "user>>>' . $v['email'] . '>>>traffic>>>uplink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
|
||||
$x['inbounds'][0]['settings']['clients'][$k]['session'] = [
|
||||
$p['users'][$k]['session'] = [
|
||||
'download' => $d,
|
||||
'upload' => $u,
|
||||
];
|
||||
}
|
||||
$this->restartXray($x, norestart: 1);
|
||||
}
|
||||
$this->setXrayStats($p);
|
||||
} catch (\Throwable $th) {
|
||||
}
|
||||
}
|
||||
@@ -1410,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', []);
|
||||
@@ -1622,7 +1669,7 @@ class Bot
|
||||
'ocu' => file_get_contents('/config/ocserv.passwd'),
|
||||
'ss' => $this->getSSConfig(),
|
||||
'sl' => $this->getSSLocalConfig(),
|
||||
|
||||
'xraystats' => $this->getXrayStats(),
|
||||
];
|
||||
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
@@ -1735,6 +1782,12 @@ class Bot
|
||||
$this->adguardXrayClients();
|
||||
$this->setUpstreamDomain($json['pac']['transport'] != 'Reality' ? 't' : ($json['pac']['reality']['domain'] ?: $json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
||||
}
|
||||
// xraystats
|
||||
if (!empty($json['xraystats'])) {
|
||||
$out[] = 'update xray stats';
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->setXrayStats($json['xraystats']);
|
||||
}
|
||||
// ocserv
|
||||
if (!empty($json['oc'])) {
|
||||
$out[] = 'update ocserv';
|
||||
@@ -2370,6 +2423,21 @@ class Bot
|
||||
];
|
||||
}
|
||||
|
||||
public function setIpLimit()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter seconds and count ip",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter seconds:count_ip',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'callback' => 'switchIpLimit',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function addLinkDomain()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -4384,6 +4452,21 @@ DNS-over-HTTPS with IP:
|
||||
$this->ipMenu();
|
||||
}
|
||||
|
||||
public function switchIpLimit($limit)
|
||||
{
|
||||
$limit = explode(':', $limit);
|
||||
$c = $this->getPacConf();
|
||||
if ((int) $limit[0] <= 0) {
|
||||
unset($c['ip_limit']);
|
||||
unset($c['ip_count']);
|
||||
} else {
|
||||
$c['ip_limit'] = (int) $limit[0];
|
||||
$c['ip_count'] = (int) $limit[1] ?: 1;
|
||||
}
|
||||
$this->setPacConf($c);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function switchSilence()
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
@@ -4398,12 +4481,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')),
|
||||
@@ -5252,22 +5329,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)
|
||||
@@ -5317,17 +5402,34 @@ DNS-over-HTTPS with IP:
|
||||
$this->userXr($i);
|
||||
}
|
||||
|
||||
public function getXrayStats()
|
||||
{
|
||||
return json_decode(file_get_contents('/config/xray.stats'), true) ?: [];
|
||||
}
|
||||
|
||||
public function setXrayStats($x)
|
||||
{
|
||||
file_put_contents('/config/xray.stats', json_encode($x));
|
||||
}
|
||||
|
||||
public function resetXrUser($i)
|
||||
{
|
||||
$c = $this->getXray();
|
||||
$c['inbounds'][0]['settings']['clients'][$i]['global'] = [
|
||||
$c = $this->getXrayStats();
|
||||
$c['clients'][$i]['global'] = [
|
||||
'download' => 0,
|
||||
'upload' => 0,
|
||||
];
|
||||
$this->restartXray($c);
|
||||
$this->restartXray($this->getXray());
|
||||
$this->userXr($i);
|
||||
}
|
||||
|
||||
public function resetXrStats()
|
||||
{
|
||||
$this->restartXray($this->getXray());
|
||||
$this->setXrayStats([]);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function listXr($i)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
@@ -5628,6 +5730,15 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "fake domain: <code>$fake</code>";
|
||||
}
|
||||
$text[] = 'transport: ' . ($p['transport'] ?: 'Websocket');
|
||||
$st = $this->getXrayStats();
|
||||
$td = $this->getBytes($st['global']['download'] + $st['session']['download']);
|
||||
$tu = $this->getBytes($st['global']['upload'] + $st['session']['upload']);
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('reset stats') . ": ↓$td ↑$tu",
|
||||
'callback_data' => '/resetXrStats',
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
|
||||
@@ -5640,6 +5751,7 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => '/addLinkDomain',
|
||||
],
|
||||
];
|
||||
$ip_count = $p['ip_count'] ?: 1;
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('Reality') . ' ' . ($p['transport'] == 'Reality' ? $this->i18n('on') : $this->i18n('off')),
|
||||
@@ -5649,6 +5761,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 & $ip_count" : $this->i18n('off')),
|
||||
'callback_data' => "/setIpLimit",
|
||||
],
|
||||
];
|
||||
if ($p['transport'] == 'Reality') {
|
||||
$data[] = [
|
||||
@@ -5698,8 +5814,8 @@ DNS-over-HTTPS with IP:
|
||||
$page = $page == -2 ? $all - 1 : $page;
|
||||
$clients = $page != -1 ? array_slice($clients, $page * $this->limit, $this->limit, true) : $clients;
|
||||
foreach ($clients as $k => $v) {
|
||||
$download = $this->getBytes($v['global']['download'] + $v['session']['download']);
|
||||
$upload = $this->getBytes($v['global']['upload'] + $v['session']['upload']);
|
||||
$download = $this->getBytes($st['users'][$k]['global']['download'] + $st['users'][$k]['session']['download']);
|
||||
$upload = $this->getBytes($st['users'][$k]['global']['upload'] + $st['users'][$k]['session']['upload']);
|
||||
$time = $v['time'] ? $this->getTime($v['time']) : '';
|
||||
$data[] = [
|
||||
[
|
||||
@@ -5837,6 +5953,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']) > ($pac['ip_count'] ?: 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();
|
||||
@@ -5991,8 +6180,16 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "sing-box config: <pre><code>$si</code></pre>";
|
||||
$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>";
|
||||
|
||||
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac$hash?t=si&r=w&s={$c['id']}'>windows service</a>";
|
||||
$st = $this->getXrayStats();
|
||||
$download = $this->getBytes($st['users'][$i]['global']['download'] + $st['users'][$i]['session']['download']);
|
||||
$upload = $this->getBytes($st['users'][$i]['global']['upload'] + $st['users'][$i]['session']['upload']);
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('reset stats') . ": ↓$download ↑$upload",
|
||||
'callback_data' => "/resetXrUser $i",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('v2ray'),
|
||||
@@ -6048,14 +6245,6 @@ DNS-over-HTTPS with IP:
|
||||
'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[] = [
|
||||
[
|
||||
'text' => $this->i18n('rename'),
|
||||
@@ -6325,7 +6514,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]);
|
||||
}
|
||||
}
|
||||
@@ -6606,7 +6795,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()
|
||||
@@ -7005,10 +7200,12 @@ DNS-over-HTTPS with IP:
|
||||
'text' => $this->i18n('Ports'),
|
||||
'callback_data' => "/ports",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('IP ban & Logs'),
|
||||
'text' => $this->i18n('logs'),
|
||||
'callback_data' => "/logs",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('IP ban'),
|
||||
'callback_data' => "/ipMenu",
|
||||
],
|
||||
];
|
||||
@@ -7204,6 +7401,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");
|
||||
@@ -7225,10 +7423,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(
|
||||
@@ -7324,6 +7536,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(
|
||||
@@ -7457,6 +7685,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';
|
||||
|
||||
@@ -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();
|
||||
+21
-21
@@ -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,9 @@
|
||||
},
|
||||
{
|
||||
"type": "mixed",
|
||||
"tag": "mixed-in",
|
||||
"domain_strategy": "prefer_ipv4",
|
||||
"tag": "in",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 2080,
|
||||
"tcp_fast_open": true,
|
||||
"sniff": true,
|
||||
"sniff_override_destination": false,
|
||||
"users": []
|
||||
"listen_port": 2080
|
||||
}
|
||||
],
|
||||
"dns": {
|
||||
@@ -92,23 +87,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,
|
||||
@@ -187,7 +187,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"outbound": "block"
|
||||
"action": "reject"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
@@ -207,4 +207,4 @@
|
||||
],
|
||||
"final": "direct"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
@@ -1,3 +1,15 @@
|
||||
11.02.2025 v2.12
|
||||
- vless: хранение статы в отдельном файле
|
||||
- vless ip limit: возможность указать кол-во айпи
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user