Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e41c8e30a4 | |||
| 260f988360 | |||
| ca4905220d | |||
| 08c5ff136e | |||
| 8709531717 | |||
| 71f53c3575 | |||
| 2607f1f264 | |||
| a94cab7dc1 | |||
| 694d446402 | |||
| 6074d40643 | |||
| 4b1df94325 | |||
| 232c75d5bf | |||
| 5e860a4896 | |||
| 5b05486b98 | |||
| fb22744fa7 | |||
| af812b7c93 | |||
| 3302ca8871 | |||
| 2c5eff03d5 | |||
| a8a203041f | |||
| a21c9b5fe9 | |||
| 696779450f | |||
| 7c5b3dfa3a | |||
| 74404559f9 | |||
| 11e8fb468b | |||
| ca92ca703f | |||
| f527888db8 | |||
| 0e47a771cc | |||
| ff10cbefc8 | |||
| 3371ba4bae | |||
| 621fb08467 | |||
| 5153b2c94a | |||
| 1e9461cc49 | |||
| 88f48a036c | |||
| b40e052d3f | |||
| a43082ae27 | |||
| c2cd945991 | |||
| 0737327e4b | |||
| f620bf12cd | |||
| 8b3730c61f | |||
| c6d9dcd47b | |||
| d83ba51d81 | |||
| 1a593100b7 | |||
| 414a67c10d | |||
| f92b484011 | |||
| 7af0276944 | |||
| 24aaa8756c | |||
| 07e2beff9b | |||
| 86261e6b76 | |||
| d816582e6f | |||
| 6d1ab0cb3a | |||
| 284b025881 | |||
| 0ca93b56a3 | |||
| 7bcd8de007 | |||
| 34eb950852 | |||
| 46021855a5 | |||
| 29c18ceb9d | |||
| 49d0827b9e | |||
| 07e04c384a | |||
| 579457b4f4 | |||
| 3dac9416ca | |||
| 5b4d3b5627 | |||
| 658e125cd8 | |||
| 1840555573 | |||
| ecdc028226 | |||
| d432bf82f2 | |||
| 211e2c079d | |||
| 1696c4da7b | |||
| b8d5700eba |
+529
-72
@@ -13,6 +13,7 @@ class Bot
|
|||||||
public $mtu;
|
public $mtu;
|
||||||
public $logs;
|
public $logs;
|
||||||
public $reg;
|
public $reg;
|
||||||
|
public $pool;
|
||||||
|
|
||||||
public function __construct($key, $i18n)
|
public function __construct($key, $i18n)
|
||||||
{
|
{
|
||||||
@@ -161,6 +162,9 @@ class Bot
|
|||||||
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
|
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
|
||||||
$this->switchBanIp();
|
$this->switchBanIp();
|
||||||
break;
|
break;
|
||||||
|
case preg_match('~^/setIpLimit$~', $this->input['callback'], $m):
|
||||||
|
$this->setIpLimit();
|
||||||
|
break;
|
||||||
case preg_match('~^/searchLogs (.+)$~', $this->input['message'], $m):
|
case preg_match('~^/searchLogs (.+)$~', $this->input['message'], $m):
|
||||||
$this->searchLogs($m[1]);
|
$this->searchLogs($m[1]);
|
||||||
break;
|
break;
|
||||||
@@ -238,6 +242,7 @@ class Bot
|
|||||||
break;
|
break;
|
||||||
case preg_match('~^/id$~', $this->input['message'], $m):
|
case preg_match('~^/id$~', $this->input['message'], $m):
|
||||||
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
||||||
|
$this->send($this->input['chat'], $this->input['chat'], $this->input['message_id']);
|
||||||
break;
|
break;
|
||||||
case preg_match('~^/adguardChBr$~', $this->input['callback'], $m):
|
case preg_match('~^/adguardChBr$~', $this->input['callback'], $m):
|
||||||
$this->adguardChBr();
|
$this->adguardChBr();
|
||||||
@@ -296,7 +301,7 @@ class Bot
|
|||||||
case preg_match('~^/delLog (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
case preg_match('~^/delLog (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
||||||
$this->delLog(...explode('_', $m['arg']));
|
$this->delLog(...explode('_', $m['arg']));
|
||||||
break;
|
break;
|
||||||
case preg_match('~^/debug$~', $this->input['callback'], $m):
|
case preg_match('~^/debug$~', $this->input['message'], $m):
|
||||||
$this->debug();
|
$this->debug();
|
||||||
break;
|
break;
|
||||||
case preg_match('~^/backup$~', $this->input['callback'], $m):
|
case preg_match('~^/backup$~', $this->input['callback'], $m):
|
||||||
@@ -377,6 +382,12 @@ 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('~^/resetXrStats$~', $this->input['callback'], $m):
|
||||||
|
$this->resetXrStats();
|
||||||
|
break;
|
||||||
case preg_match('~^/v2ray$~', $this->input['callback'], $m):
|
case preg_match('~^/v2ray$~', $this->input['callback'], $m):
|
||||||
$this->v2ray();
|
$this->v2ray();
|
||||||
break;
|
break;
|
||||||
@@ -540,6 +551,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;
|
||||||
@@ -570,6 +584,9 @@ class Bot
|
|||||||
case preg_match('~^/changeFakeDomain$~', $this->input['callback'], $m):
|
case preg_match('~^/changeFakeDomain$~', $this->input['callback'], $m):
|
||||||
$this->changeFakeDomain();
|
$this->changeFakeDomain();
|
||||||
break;
|
break;
|
||||||
|
case preg_match('~^/autoCleanLogs$~', $this->input['callback'], $m):
|
||||||
|
$this->autoCleanLogs();
|
||||||
|
break;
|
||||||
case preg_match('~^/selfFakeDomain$~', $this->input['callback'], $m):
|
case preg_match('~^/selfFakeDomain$~', $this->input['callback'], $m):
|
||||||
$this->selfFakeDomain();
|
$this->selfFakeDomain();
|
||||||
break;
|
break;
|
||||||
@@ -667,13 +684,84 @@ class Bot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function restartXray($c)
|
public function restartXray($c, $norestart = false)
|
||||||
{
|
{
|
||||||
$c['inbounds'][0]['settings']['clients'] = array_values($c['inbounds'][0]['settings']['clients']);
|
$c['inbounds'][0]['settings']['clients'] = array_values($c['inbounds'][0]['settings']['clients']);
|
||||||
$c['log']['access'] = '/logs/xray';
|
$c['log']['access'] = '/logs/xray';
|
||||||
$this->ssh('pkill xray', 'xr');
|
foreach ($c['inbounds'] as $v) {
|
||||||
file_put_contents('/config/xray.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
if ($v['tag'] == 'api') {
|
||||||
$this->ssh('xray run -config /xray.json > /dev/null 2>&1 &', 'xr');
|
$inbound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($inbound)) {
|
||||||
|
$c['inbounds'][] = [
|
||||||
|
"listen" => "127.0.0.1",
|
||||||
|
"port" => 8080,
|
||||||
|
"protocol" => "dokodemo-door",
|
||||||
|
"settings" => [
|
||||||
|
"address" => "127.0.0.1"
|
||||||
|
],
|
||||||
|
"tag" => "api"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
foreach ($c['routing']['rules'] as $v) {
|
||||||
|
if ($v['outboundTag'] == 'api') {
|
||||||
|
$rule = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($rule)) {
|
||||||
|
$c['routing']['rules'][] = [
|
||||||
|
"inboundTag" => ["api"],
|
||||||
|
"outboundTag" => "api",
|
||||||
|
"type" => "field"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$c['stats'] = new stdClass();
|
||||||
|
$c['api'] = [
|
||||||
|
'services' => ['StatsService'],
|
||||||
|
'tag' => 'api'
|
||||||
|
];
|
||||||
|
$l = new stdClass();
|
||||||
|
$l->{'0'} = [
|
||||||
|
"statsUserUplink" => true,
|
||||||
|
"statsUserDownlink" => true
|
||||||
|
];
|
||||||
|
$c['policy']['levels'] = $l;
|
||||||
|
$c['policy']['system'] = [
|
||||||
|
"statsInboundUplink" => true,
|
||||||
|
"statsInboundDownlink" => true,
|
||||||
|
"statsOutboundUplink" => true,
|
||||||
|
"statsOutboundDownlink" => true
|
||||||
|
];
|
||||||
|
if (empty($norestart)) {
|
||||||
|
$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');
|
||||||
|
} else {
|
||||||
|
file_put_contents('/config/xray.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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['users'] as $k => $v) {
|
||||||
|
$p['users'][$k]['global']['download'] += $v['session']['download'];
|
||||||
|
$p['users'][$k]['session']['download'] = 0;
|
||||||
|
$p['users'][$k]['global']['upload'] += $v['session']['upload'];
|
||||||
|
$p['users'][$k]['session']['upload'] = 0;
|
||||||
|
}
|
||||||
|
$this->setXrayStats($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function linkMtproto()
|
public function linkMtproto()
|
||||||
@@ -905,7 +993,7 @@ class Bot
|
|||||||
{
|
{
|
||||||
$r = $this->send(
|
$r = $this->send(
|
||||||
$this->input['chat'],
|
$this->input['chat'],
|
||||||
"@{$this->input['username']} enter pass",
|
"@{$this->input['username']} enter password",
|
||||||
$this->input['message_id'],
|
$this->input['message_id'],
|
||||||
reply: 'enter password',
|
reply: 'enter password',
|
||||||
);
|
);
|
||||||
@@ -923,7 +1011,7 @@ class Bot
|
|||||||
$this->input['chat'],
|
$this->input['chat'],
|
||||||
"@{$this->input['username']} enter name",
|
"@{$this->input['username']} enter name",
|
||||||
$this->input['message_id'],
|
$this->input['message_id'],
|
||||||
reply: 'enter password',
|
reply: 'enter name',
|
||||||
);
|
);
|
||||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||||
'start_message' => $this->input['message_id'],
|
'start_message' => $this->input['message_id'],
|
||||||
@@ -939,7 +1027,7 @@ class Bot
|
|||||||
$this->input['chat'],
|
$this->input['chat'],
|
||||||
"@{$this->input['username']} enter name",
|
"@{$this->input['username']} enter name",
|
||||||
$this->input['message_id'],
|
$this->input['message_id'],
|
||||||
reply: 'enter password',
|
reply: 'enter name:uuid [,name:uuid]',
|
||||||
);
|
);
|
||||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||||
'start_message' => $this->input['message_id'],
|
'start_message' => $this->input['message_id'],
|
||||||
@@ -1249,12 +1337,48 @@ class Bot
|
|||||||
$this->shutdownClientXr();
|
$this->shutdownClientXr();
|
||||||
$this->checkVersion();
|
$this->checkVersion();
|
||||||
$this->checkBackup($period);
|
$this->checkBackup($period);
|
||||||
|
$this->checkLogs($period);
|
||||||
$this->checkCert();
|
$this->checkCert();
|
||||||
$this->autoAnalyzeLogs();
|
$this->autoAnalyzeLogs();
|
||||||
|
$this->xrayStatsUser();
|
||||||
sleep($period);
|
sleep($period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function xrayStatsUser()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$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'])) {
|
||||||
|
$tmp = [];
|
||||||
|
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;
|
||||||
|
$tmp[$k] = [
|
||||||
|
'session' => [
|
||||||
|
'download' => $d,
|
||||||
|
'upload' => $u,
|
||||||
|
],
|
||||||
|
'global' => [
|
||||||
|
'download' => $p['users'][$k]['global']['download'],
|
||||||
|
'upload' => $p['users'][$k]['global']['upload'],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$p['users'] = $tmp;
|
||||||
|
}
|
||||||
|
$this->setXrayStats($p);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function autoAnalyzeLogs()
|
public function autoAnalyzeLogs()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -1321,6 +1445,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
|
public function cleanQueue(): void
|
||||||
{
|
{
|
||||||
$r = $this->request('deleteWebhook', []);
|
$r = $this->request('deleteWebhook', []);
|
||||||
@@ -1533,7 +1677,7 @@ class Bot
|
|||||||
'ocu' => file_get_contents('/config/ocserv.passwd'),
|
'ocu' => file_get_contents('/config/ocserv.passwd'),
|
||||||
'ss' => $this->getSSConfig(),
|
'ss' => $this->getSSConfig(),
|
||||||
'sl' => $this->getSSLocalConfig(),
|
'sl' => $this->getSSLocalConfig(),
|
||||||
|
'xraystats' => $this->getXrayStats(),
|
||||||
];
|
];
|
||||||
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
}
|
}
|
||||||
@@ -1646,6 +1790,12 @@ class Bot
|
|||||||
$this->adguardXrayClients();
|
$this->adguardXrayClients();
|
||||||
$this->setUpstreamDomain($json['pac']['transport'] != 'Reality' ? 't' : ($json['pac']['reality']['domain'] ?: $json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
$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
|
// ocserv
|
||||||
if (!empty($json['oc'])) {
|
if (!empty($json['oc'])) {
|
||||||
$out[] = 'update ocserv';
|
$out[] = 'update ocserv';
|
||||||
@@ -2281,6 +2431,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()
|
public function addLinkDomain()
|
||||||
{
|
{
|
||||||
$r = $this->send(
|
$r = $this->send(
|
||||||
@@ -2612,15 +2777,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':
|
||||||
@@ -3435,8 +3600,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",
|
||||||
@@ -3670,6 +3833,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;
|
||||||
@@ -3716,6 +3885,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[] = [
|
||||||
[
|
[
|
||||||
@@ -3863,7 +4048,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'),
|
||||||
@@ -3919,7 +4122,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),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -4119,12 +4322,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'),
|
||||||
@@ -4175,10 +4372,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'),
|
||||||
@@ -4257,6 +4460,21 @@ DNS-over-HTTPS with IP:
|
|||||||
$this->ipMenu();
|
$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()
|
public function switchSilence()
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
@@ -4271,12 +4489,6 @@ DNS-over-HTTPS with IP:
|
|||||||
$pac = $this->getPacConf();
|
$pac = $this->getPacConf();
|
||||||
$d = count($pac['deny'] ?: []);
|
$d = count($pac['deny'] ?: []);
|
||||||
$w = count($pac['white'] ?: []);
|
$w = count($pac['white'] ?: []);
|
||||||
$data[] = [
|
|
||||||
[
|
|
||||||
'text' => $this->i18n('logs'),
|
|
||||||
'callback_data' => "/logs",
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('autoscan') . ': ' . ($pac['autoscan'] ? $this->getTime(strtotime(($pac['autoscan_timeout'] ?: 3600) . ' seconds')) : $this->i18n('off')),
|
'text' => $this->i18n('autoscan') . ': ' . ($pac['autoscan'] ? $this->getTime(strtotime(($pac['autoscan_timeout'] ?: 3600) . ' seconds')) : $this->i18n('off')),
|
||||||
@@ -4426,7 +4638,6 @@ DNS-over-HTTPS with IP:
|
|||||||
}
|
}
|
||||||
|
|
||||||
$t = [
|
$t = [
|
||||||
$this->suspicious('~\d+\.\d+\.\d+\.\d+.+200\s\d+\s0$~', '/logs/upstream_access', $xr, 'possibly a Reality Degenerate'),
|
|
||||||
$this->suspicious($this->reg, '/logs/nginx_default_access', $xr, 'possibly a scanner', true),
|
$this->suspicious($this->reg, '/logs/nginx_default_access', $xr, 'possibly a scanner', true),
|
||||||
$this->suspicious($this->reg, '/logs/nginx_domain_access', $xr, 'possibly a scanner', true),
|
$this->suspicious($this->reg, '/logs/nginx_domain_access', $xr, 'possibly a scanner', true),
|
||||||
];
|
];
|
||||||
@@ -4438,6 +4649,15 @@ DNS-over-HTTPS with IP:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$r = $this->suspicious('~\d+\.\d+\.\d+\.\d+.+200\s\d+\s0$~', '/logs/upstream_access', $xr, 'possibly a Reality Degenerate');
|
||||||
|
if (!empty($r)) {
|
||||||
|
foreach ($r as $k => $v) {
|
||||||
|
if (count($v) > 30) {
|
||||||
|
$ip[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($return)) {
|
if (!empty($return)) {
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
@@ -5092,10 +5312,13 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function delxr($i)
|
public function delxr($i)
|
||||||
{
|
{
|
||||||
$r = $this->getXray();
|
$r = $this->getXray();
|
||||||
|
$st = $this->getXrayStats();
|
||||||
foreach ($r['inbounds'][0]['settings']['clients'] as $k => $v) {
|
foreach ($r['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||||
if ($i == $k) {
|
if ($i == $k) {
|
||||||
unset($r['inbounds'][0]['settings']['clients'][$k]);
|
unset($r['inbounds'][0]['settings']['clients'][$k]);
|
||||||
|
unset($st['users'][$k]);
|
||||||
|
$this->setXrayStats($st);
|
||||||
$this->restartXray($r);
|
$this->restartXray($r);
|
||||||
$this->adguardXrayClients();
|
$this->adguardXrayClients();
|
||||||
break;
|
break;
|
||||||
@@ -5117,35 +5340,43 @@ DNS-over-HTTPS with IP:
|
|||||||
$this->menu('oc');
|
$this->menu('oc');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addxrus($user)
|
public function addxrus($users)
|
||||||
{
|
{
|
||||||
$c = $this->getXray();
|
$c = $this->getXray();
|
||||||
$p = $this->getPacConf();
|
$p = $this->getPacConf();
|
||||||
$uuid = trim($this->ssh('xray uuid', 'xr'));
|
$users = array_map(fn ($e) => trim($e), explode(',', $users));
|
||||||
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
|
$users = array_map(fn ($e) => explode(':', $e), $users);
|
||||||
'id' => $uuid,
|
foreach ($users as $user) {
|
||||||
'email' => $user,
|
$uuid = $user[1] ?: trim($this->ssh('xray uuid', 'xr'));
|
||||||
] : [
|
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
|
||||||
'id' => $uuid,
|
'id' => $uuid,
|
||||||
'flow' => 'xtls-rprx-vision',
|
'email' => $user[0],
|
||||||
'email' => $user,
|
] : [
|
||||||
];
|
'id' => $uuid,
|
||||||
|
'flow' => 'xtls-rprx-vision',
|
||||||
|
'email' => $user[0],
|
||||||
|
];
|
||||||
|
}
|
||||||
$this->restartXray($c);
|
$this->restartXray($c);
|
||||||
$this->adguardXrayClients();
|
$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)
|
public function setTimerXr($time, $i)
|
||||||
{
|
{
|
||||||
$time = strtotime($time);
|
|
||||||
if ($time === false) {
|
|
||||||
$this->send($this->input['chat'], 'wrong format');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$c = $this->getXray();
|
$c = $this->getXray();
|
||||||
if (empty($time)) {
|
if (empty($time)) {
|
||||||
unset($c['inbounds'][0]['settings']['clients'][$i]['time']);
|
unset($c['inbounds'][0]['settings']['clients'][$i]['time']);
|
||||||
} else {
|
} else {
|
||||||
|
$time = strtotime($time);
|
||||||
|
if ($time === false) {
|
||||||
|
$this->send($this->input['chat'], 'wrong format');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!empty($c['inbounds'][0]['settings']['clients'][$i]['off'])) {
|
if (!empty($c['inbounds'][0]['settings']['clients'][$i]['off'])) {
|
||||||
$this->switchXr($i, 1);
|
$this->switchXr($i, 1);
|
||||||
$c = $this->getXray();
|
$c = $this->getXray();
|
||||||
@@ -5182,6 +5413,31 @@ DNS-over-HTTPS with IP:
|
|||||||
$this->userXr($i);
|
$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->getXrayStats();
|
||||||
|
unset($c['users'][$i]);
|
||||||
|
$this->restartXray($this->getXray());
|
||||||
|
$this->userXr($i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetXrStats()
|
||||||
|
{
|
||||||
|
$this->restartXray($this->getXray());
|
||||||
|
$this->setXrayStats([]);
|
||||||
|
$this->xray();
|
||||||
|
}
|
||||||
|
|
||||||
public function listXr($i)
|
public function listXr($i)
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
@@ -5314,14 +5570,7 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function downloadOrigin($type)
|
public function downloadOrigin($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
$f = new \CURLFile("/config/$type.json", 'application/json', 'origin.json');
|
||||||
case 'sing':
|
|
||||||
$f = new \CURLFile('/config/sing.json', 'application/json', 'origin.json');
|
|
||||||
break;
|
|
||||||
case 'v2ray':
|
|
||||||
$f = new \CURLFile('/config/v2ray.json', 'application/json', 'origin.json');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$this->sendFile($this->input['chat'], $f);
|
$this->sendFile($this->input['chat'], $f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5355,14 +5604,17 @@ 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>
|
||||||
|
<code>~dnspath~</code>
|
||||||
<code>~uid~</code>
|
<code>~uid~</code>
|
||||||
<code>~domain~</code>
|
<code>~domain~</code>
|
||||||
<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>
|
||||||
@@ -5456,6 +5708,25 @@ DNS-over-HTTPS with IP:
|
|||||||
$this->xray();
|
$this->xray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBytes($bytes)
|
||||||
|
{
|
||||||
|
$t = [
|
||||||
|
'B',
|
||||||
|
'KB',
|
||||||
|
'MB',
|
||||||
|
'GB',
|
||||||
|
'TB',
|
||||||
|
];
|
||||||
|
foreach ($t as $k => $v) {
|
||||||
|
if ($k == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($bytes / (1024 ** $k) < 1) {
|
||||||
|
return round($bytes / (1024 ** ($k - 1)), 2) . " {$t[$k - 1]}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function xray($page = 0)
|
public function xray($page = 0)
|
||||||
{
|
{
|
||||||
if (!$this->ssh('pgrep xray', 'xr')) {
|
if (!$this->ssh('pgrep xray', 'xr')) {
|
||||||
@@ -5468,6 +5739,15 @@ DNS-over-HTTPS with IP:
|
|||||||
$text[] = "fake domain: <code>$fake</code>";
|
$text[] = "fake domain: <code>$fake</code>";
|
||||||
}
|
}
|
||||||
$text[] = 'transport: ' . ($p['transport'] ?: 'Websocket');
|
$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[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
|
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
|
||||||
@@ -5490,6 +5770,13 @@ DNS-over-HTTPS with IP:
|
|||||||
'callback_data' => "/changeTransport 1",
|
'callback_data' => "/changeTransport 1",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
$ip_count = $p['ip_count'] ?: 1;
|
||||||
|
$data[] = [
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('ip limit') . ' ' . ($p['ip_limit'] ? ": {$p['ip_limit']} sec & $ip_count" : $this->i18n('off')),
|
||||||
|
'callback_data' => "/setIpLimit",
|
||||||
|
],
|
||||||
|
];
|
||||||
if ($p['transport'] == 'Reality') {
|
if ($p['transport'] == 'Reality') {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
@@ -5538,10 +5825,12 @@ DNS-over-HTTPS with IP:
|
|||||||
$page = $page == -2 ? $all - 1 : $page;
|
$page = $page == -2 ? $all - 1 : $page;
|
||||||
$clients = $page != -1 ? array_slice($clients, $page * $this->limit, $this->limit, true) : $clients;
|
$clients = $page != -1 ? array_slice($clients, $page * $this->limit, $this->limit, true) : $clients;
|
||||||
foreach ($clients as $k => $v) {
|
foreach ($clients as $k => $v) {
|
||||||
$time = $v['time'] ? $this->getTime($v['time']) : '';
|
$download = $this->getBytes($st['users'][$k]['global']['download'] + $st['users'][$k]['session']['download']);
|
||||||
$data[] = [
|
$upload = $this->getBytes($st['users'][$k]['global']['upload'] + $st['users'][$k]['session']['upload']);
|
||||||
|
$time = $v['time'] ? $this->getTime($v['time']) : '';
|
||||||
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => "{$v['email']}" . ($time ? ": $time" : ''),
|
'text' => "{$v['email']}" . ($time ? ": $time" : '') . " (↓$download ↑$upload)",
|
||||||
'callback_data' => "/userXr $k",
|
'callback_data' => "/userXr $k",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -5591,9 +5880,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'),
|
||||||
@@ -5607,6 +5893,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",
|
||||||
@@ -5674,6 +5964,79 @@ DNS-over-HTTPS with IP:
|
|||||||
return 'off';
|
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 $admin) {
|
||||||
|
$this->send($admin, "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()
|
public function offWarp()
|
||||||
{
|
{
|
||||||
$p = $this->getPacConf();
|
$p = $this->getPacConf();
|
||||||
@@ -5828,8 +6191,16 @@ DNS-over-HTTPS with IP:
|
|||||||
$text[] = "sing-box config: <pre><code>$si</code></pre>";
|
$text[] = "sing-box config: <pre><code>$si</code></pre>";
|
||||||
$text[] = "mihomo config: <pre><code>$cl</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[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('v2ray'),
|
'text' => $this->i18n('v2ray'),
|
||||||
@@ -6125,12 +6496,15 @@ 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",
|
||||||
|
'~dnspath~' => "/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,
|
||||||
@@ -6152,7 +6526,7 @@ DNS-over-HTTPS with IP:
|
|||||||
$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) == 1 && array_key_exists('outbound', $v)) {
|
||||||
unset($c['route']['rules'][$k]);
|
unset($c['route']['rules'][$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6234,6 +6608,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'])]);
|
||||||
@@ -6279,7 +6656,7 @@ DNS-over-HTTPS with IP:
|
|||||||
if (!empty($route['rules'])) {
|
if (!empty($route['rules'])) {
|
||||||
foreach ($route['rules'] as $k => $v) {
|
foreach ($route['rules'] as $k => $v) {
|
||||||
if (!empty($v['addruleset'])) {
|
if (!empty($v['addruleset'])) {
|
||||||
$t[$v['outbound']] = $k;
|
$t[$v['outbound'] ?: 'block'] = $k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$p = $this->getPacConf();
|
$p = $this->getPacConf();
|
||||||
@@ -6430,7 +6807,13 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function getHashBot()
|
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()
|
public function cloakNginx()
|
||||||
@@ -6474,7 +6857,13 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function getHashSubdomain($subdomain)
|
public function getHashSubdomain($subdomain)
|
||||||
{
|
{
|
||||||
return $this->getPacConf()["{$subdomain}_domain"] ?: substr(hash('sha256', "$subdomain{$this->key}"), 0, 8);
|
$p = $this->getPacConf();
|
||||||
|
if (!empty($p["{$subdomain}_domain"])) {
|
||||||
|
return $p["{$subdomain}_domain"];
|
||||||
|
}
|
||||||
|
$p["{$subdomain}_domain"] = substr(hash('sha256', "$subdomain{$this->key}"), 0, 8);
|
||||||
|
$this->setPacConf($p);
|
||||||
|
return $p["{$subdomain}_domain"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addWg($page)
|
public function addWg($page)
|
||||||
@@ -6830,7 +7219,11 @@ DNS-over-HTTPS with IP:
|
|||||||
'callback_data' => "/ports",
|
'callback_data' => "/ports",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('IP ban & Logs'),
|
'text' => $this->i18n('logs'),
|
||||||
|
'callback_data' => "/logs",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('IP ban'),
|
||||||
'callback_data' => "/ipMenu",
|
'callback_data' => "/ipMenu",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -6919,6 +7312,7 @@ DNS-over-HTTPS with IP:
|
|||||||
$text[] = 'Settings -> Ports';
|
$text[] = 'Settings -> Ports';
|
||||||
$f = '/docker/compose';
|
$f = '/docker/compose';
|
||||||
$c = yaml_parse_file($f)['services'];
|
$c = yaml_parse_file($f)['services'];
|
||||||
|
$pac = $this->getPacConf();
|
||||||
$data = [
|
$data = [
|
||||||
[[
|
[[
|
||||||
'text' => $this->i18n($c['wg'] ? 'on' : 'off') . ' ' . getenv('WGPORT') . ' Wireguard',
|
'text' => $this->i18n($c['wg'] ? 'on' : 'off') . ' ' . getenv('WGPORT') . ' Wireguard',
|
||||||
@@ -6941,6 +7335,14 @@ DNS-over-HTTPS with IP:
|
|||||||
'callback_data' => "/hidePort ss",
|
'callback_data' => "/hidePort ss",
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
|
if (!empty($pac['restart'])) {
|
||||||
|
$data[] = [
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('restart'),
|
||||||
|
'callback_data' => "/restart",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('back'),
|
'text' => $this->i18n('back'),
|
||||||
@@ -6976,7 +7378,10 @@ DNS-over-HTTPS with IP:
|
|||||||
} else {
|
} else {
|
||||||
yaml_emit_file($f, $c);
|
yaml_emit_file($f, $c);
|
||||||
}
|
}
|
||||||
$this->restart();
|
$pac = $this->getPacConf();
|
||||||
|
$pac['restart'] = 1;
|
||||||
|
$this->setPacConf($pac);
|
||||||
|
$this->ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function branches()
|
public function branches()
|
||||||
@@ -7014,6 +7419,7 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function logs()
|
public function logs()
|
||||||
{
|
{
|
||||||
|
$p = $this->getPacConf();
|
||||||
foreach (scandir('/logs/') as $k => $v) {
|
foreach (scandir('/logs/') as $k => $v) {
|
||||||
if (!preg_match('~^\.~', $v)) {
|
if (!preg_match('~^\.~', $v)) {
|
||||||
$size = filesize("/logs/$v");
|
$size = filesize("/logs/$v");
|
||||||
@@ -7035,10 +7441,24 @@ DNS-over-HTTPS with IP:
|
|||||||
'callback_data' => "/cleanLog",
|
'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[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('back'),
|
'text' => $this->i18n('back'),
|
||||||
'callback_data' => "/ipMenu",
|
'callback_data' => "/menu config",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$this->update(
|
$this->update(
|
||||||
@@ -7113,6 +7533,9 @@ DNS-over-HTTPS with IP:
|
|||||||
}
|
}
|
||||||
file_put_contents('/update/message', '');
|
file_put_contents('/update/message', '');
|
||||||
file_put_contents('/update/reload_message', '');
|
file_put_contents('/update/reload_message', '');
|
||||||
|
$pac = $this->getPacConf();
|
||||||
|
unset($pac['restart']);
|
||||||
|
$this->setPacConf($pac);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backup()
|
public function backup()
|
||||||
@@ -7131,6 +7554,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()
|
public function changeFakeDomain()
|
||||||
{
|
{
|
||||||
$r = $this->send(
|
$r = $this->send(
|
||||||
@@ -7264,6 +7703,24 @@ DNS-over-HTTPS with IP:
|
|||||||
$this->menu('config');
|
$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()
|
public function debug()
|
||||||
{
|
{
|
||||||
$file = __DIR__ . '/config.php';
|
$file = __DIR__ . '/config.php';
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ $i = [
|
|||||||
'ru' => 'PAC',
|
'ru' => 'PAC',
|
||||||
],
|
],
|
||||||
'chat' => [
|
'chat' => [
|
||||||
'en' => 'discussion group',
|
'en' => 'chat',
|
||||||
'ru' => 'чат поддержки',
|
'ru' => 'чат поддержки',
|
||||||
],
|
],
|
||||||
'back' => [
|
'back' => [
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -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"
|
||||||
|
|||||||
+36
-21
@@ -9,12 +9,12 @@
|
|||||||
"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,
|
|
||||||
"endpoint_independent_nat": false,
|
"endpoint_independent_nat": false,
|
||||||
"stack": "mixed",
|
"stack": "mixed",
|
||||||
"platform": {
|
"platform": {
|
||||||
@@ -27,14 +27,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "mixed",
|
"type": "mixed",
|
||||||
"tag": "mixed-in",
|
"tag": "in",
|
||||||
"domain_strategy": "prefer_ipv4",
|
|
||||||
"listen": "127.0.0.1",
|
"listen": "127.0.0.1",
|
||||||
"listen_port": 2080,
|
"listen_port": 2080
|
||||||
"tcp_fast_open": true,
|
|
||||||
"sniff": true,
|
|
||||||
"sniff_override_destination": false,
|
|
||||||
"users": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dns": {
|
"dns": {
|
||||||
@@ -92,23 +87,28 @@
|
|||||||
{
|
{
|
||||||
"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": [
|
||||||
|
{
|
||||||
|
"action": "sniff"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"protocol": "dns",
|
"protocol": "dns",
|
||||||
"outbound": "dns-out"
|
"action": "hijack-dns"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inbound": "in",
|
||||||
|
"action": "resolve",
|
||||||
|
"strategy": "prefer_ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inbound": "in",
|
||||||
|
"action": "sniff",
|
||||||
|
"timeout": "1s"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"addruleset": true,
|
"addruleset": true,
|
||||||
@@ -129,6 +129,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 +187,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbound": "block"
|
"action": "reject"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"addruleset": true,
|
"addruleset": true,
|
||||||
@@ -192,4 +207,4 @@
|
|||||||
],
|
],
|
||||||
"final": "direct"
|
"final": "direct"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+111
-81
@@ -4,92 +4,122 @@
|
|||||||
"error": "",
|
"error": "",
|
||||||
"loglevel": "warning"
|
"loglevel": "warning"
|
||||||
},
|
},
|
||||||
"inbounds": [{
|
"inbounds": [
|
||||||
"tag": "socks",
|
{
|
||||||
"port": 10808,
|
"tag": "socks",
|
||||||
"listen": "127.0.0.1",
|
"port": 10808,
|
||||||
"protocol": "socks",
|
"listen": "127.0.0.1",
|
||||||
"sniffing": {
|
"protocol": "socks",
|
||||||
"enabled": true,
|
"sniffing": {
|
||||||
"destOverride": ["http", "tls"],
|
"enabled": true,
|
||||||
"routeOnly": false
|
"destOverride": [
|
||||||
},
|
"http",
|
||||||
"settings": {
|
"tls"
|
||||||
"auth": "noauth",
|
],
|
||||||
"udp": true,
|
"routeOnly": false
|
||||||
"allowTransparent": false
|
},
|
||||||
}
|
"settings": {
|
||||||
}, {
|
"auth": "noauth",
|
||||||
"tag": "http",
|
"udp": true,
|
||||||
"port": 10809,
|
"allowTransparent": false
|
||||||
"listen": "127.0.0.1",
|
|
||||||
"protocol": "http",
|
|
||||||
"sniffing": {
|
|
||||||
"enabled": true,
|
|
||||||
"destOverride": ["http", "tls"],
|
|
||||||
"routeOnly": false
|
|
||||||
},
|
|
||||||
"settings": {
|
|
||||||
"auth": "noauth",
|
|
||||||
"udp": true,
|
|
||||||
"allowTransparent": false
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"outbounds": [{
|
|
||||||
"tag": "~outbound~",
|
|
||||||
"protocol": "vless",
|
|
||||||
"settings": {
|
|
||||||
"vnext": [{
|
|
||||||
"address": "~domain~",
|
|
||||||
"port": 443,
|
|
||||||
"users": [{
|
|
||||||
"id": "~uid~",
|
|
||||||
"alterId": 0,
|
|
||||||
"email": "t@t.tt",
|
|
||||||
"security": "auto",
|
|
||||||
"encryption": "none",
|
|
||||||
"flow": "xtls-rprx-vision"
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"streamSettings": {
|
|
||||||
"network": "tcp",
|
|
||||||
"security": "reality",
|
|
||||||
"realitySettings": {
|
|
||||||
"serverName": "~server_name~",
|
|
||||||
"fingerprint": "chrome",
|
|
||||||
"show": false,
|
|
||||||
"publicKey": "~public_key~",
|
|
||||||
"shortId": "~short_id~",
|
|
||||||
"spiderX": ""
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mux": {
|
{
|
||||||
"enabled": false,
|
"tag": "http",
|
||||||
"concurrency": -1
|
"port": 10809,
|
||||||
}
|
"listen": "127.0.0.1",
|
||||||
}, {
|
"protocol": "http",
|
||||||
"tag": "direct",
|
"sniffing": {
|
||||||
"protocol": "freedom"
|
"enabled": true,
|
||||||
}, {
|
"destOverride": [
|
||||||
"tag": "block",
|
"http",
|
||||||
"protocol": "blackhole",
|
"tls"
|
||||||
"settings": {
|
],
|
||||||
"response": {
|
"routeOnly": false
|
||||||
"type": "http"
|
},
|
||||||
|
"settings": {
|
||||||
|
"auth": "noauth",
|
||||||
|
"udp": true,
|
||||||
|
"allowTransparent": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
],
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"tag": "direct",
|
||||||
|
"protocol": "freedom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "~outbound~",
|
||||||
|
"protocol": "vless",
|
||||||
|
"settings": {
|
||||||
|
"vnext": [
|
||||||
|
{
|
||||||
|
"address": "~domain~",
|
||||||
|
"port": 443,
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"id": "~uid~",
|
||||||
|
"alterId": 0,
|
||||||
|
"email": "t@t.tt",
|
||||||
|
"security": "auto",
|
||||||
|
"encryption": "none",
|
||||||
|
"flow": "xtls-rprx-vision"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"streamSettings": {
|
||||||
|
"network": "tcp",
|
||||||
|
"security": "reality",
|
||||||
|
"realitySettings": {
|
||||||
|
"serverName": "~server_name~",
|
||||||
|
"fingerprint": "chrome",
|
||||||
|
"show": false,
|
||||||
|
"publicKey": "~public_key~",
|
||||||
|
"shortId": "~short_id~",
|
||||||
|
"spiderX": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mux": {
|
||||||
|
"enabled": false,
|
||||||
|
"concurrency": -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "block",
|
||||||
|
"protocol": "blackhole",
|
||||||
|
"settings": {
|
||||||
|
"response": {
|
||||||
|
"type": "http"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"routing": {
|
"routing": {
|
||||||
"domainStrategy": "AsIs",
|
"domainStrategy": "AsIs",
|
||||||
"rules": [{
|
"rules": [
|
||||||
"type": "field",
|
{
|
||||||
"outboundTag": "~outbound~",
|
"type": "field",
|
||||||
"domain": "~pac~"
|
"outboundTag": "block",
|
||||||
}, {
|
"domain": "~block~"
|
||||||
"type": "field",
|
},
|
||||||
"port": "0-65535",
|
{
|
||||||
"outboundTag": "direct"
|
"type": "field",
|
||||||
}]
|
"outboundTag": "~outbound~",
|
||||||
|
"domain": "~pac~"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "field",
|
||||||
|
"outboundTag": "~outbound~",
|
||||||
|
"ip": "~subnet~"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "field",
|
||||||
|
"outboundTag": "~outbound~",
|
||||||
|
"domain": "~warp~"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+39
-1
@@ -22,6 +22,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tag": "vless_tls"
|
"tag": "vless_tls"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"listen": "127.0.0.1",
|
||||||
|
"port": 8080,
|
||||||
|
"protocol": "dokodemo-door",
|
||||||
|
"settings": {
|
||||||
|
"address": "127.0.0.1"
|
||||||
|
},
|
||||||
|
"tag": "api"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"log": {
|
"log": {
|
||||||
@@ -40,6 +49,35 @@
|
|||||||
],
|
],
|
||||||
"routing": {
|
"routing": {
|
||||||
"domainStrategy": "AsIs",
|
"domainStrategy": "AsIs",
|
||||||
"rules": []
|
"rules": [
|
||||||
|
{
|
||||||
|
"inboundTag": [
|
||||||
|
"api"
|
||||||
|
],
|
||||||
|
"outboundTag": "api",
|
||||||
|
"type": "field"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stats": {},
|
||||||
|
"api": {
|
||||||
|
"services": [
|
||||||
|
"StatsService"
|
||||||
|
],
|
||||||
|
"tag": "api"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"levels": {
|
||||||
|
"0": {
|
||||||
|
"statsUserUplink": true,
|
||||||
|
"statsUserDownlink": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"statsInboundUplink": true,
|
||||||
|
"statsInboundDownlink": true,
|
||||||
|
"statsOutboundUplink": true,
|
||||||
|
"statsOutboundDownlink": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -432,7 +432,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.12
|
ipv4_address: 10.10.0.12
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
wp:
|
wp:
|
||||||
image: mercurykd/vpnbot-wp:1.2
|
image: mercurykd/vpnbot-wp:1.3
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/warp.dockerfile
|
dockerfile: dockerfile/warp.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -442,7 +442,7 @@ services:
|
|||||||
devices:
|
devices:
|
||||||
- /dev/net/tun:/dev/net/tun
|
- /dev/net/tun:/dev/net/tun
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/.profile:/root/.ashrc:ro
|
- ./config/.profile:/root/.bashrc:ro
|
||||||
- ./ssh:/ssh
|
- ./ssh:/ssh
|
||||||
- ./config/sshd_config:/etc/ssh/sshd_config
|
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||||
- ./config:/config
|
- ./config:/config
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
FROM ubuntu:22.04 AS build
|
FROM ubuntu:22.04
|
||||||
RUN apt update && apt install -y curl gpg lsb-release \
|
RUN apt update && apt install -y curl gpg socat jq lsb-release openssh-server \
|
||||||
&& curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg \
|
&& curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg \
|
||||||
&& echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list \
|
&& echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list \
|
||||||
&& apt update && apt install -y cloudflare-warp
|
&& apt update && apt install -y cloudflare-warp \
|
||||||
|
|
||||||
FROM alpine:3.17
|
|
||||||
ARG GLIBC_VERSION=2.34-r0
|
|
||||||
COPY --from=build /usr/bin/warp-cli /usr/bin/warp-svc /usr/local/bin/
|
|
||||||
RUN apk add --no-cache dbus-libs wget socat openssh-server jq curl \
|
|
||||||
&& mkdir /tmp/glibc-pkgs \
|
|
||||||
&& for PKG in glibc-$GLIBC_VERSION.apk glibc-bin-$GLIBC_VERSION.apk; do wget -q --directory-prefix /tmp/glibc-pkgs https://github.com/sgerrand/alpine-pkg-glibc/releases/download/$GLIBC_VERSION/$PKG; done \
|
|
||||||
&& apk add --no-cache --allow-untrusted --force-overwrite /tmp/glibc-pkgs/* \
|
|
||||||
&& rm -rf /tmp/glibc-pkgs \
|
|
||||||
&& /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib \
|
|
||||||
&& mkdir /root/.ssh
|
&& mkdir /root/.ssh
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ up: # консоль сервиса
|
|||||||
ad: # консоль сервиса
|
ad: # консоль сервиса
|
||||||
docker compose exec ad /bin/sh
|
docker compose exec ad /bin/sh
|
||||||
wp: # консоль сервиса
|
wp: # консоль сервиса
|
||||||
docker compose exec wp /bin/sh
|
docker compose exec wp bash
|
||||||
proxy: # консоль сервиса
|
proxy: # консоль сервиса
|
||||||
docker compose exec proxy /bin/sh
|
docker compose exec proxy /bin/sh
|
||||||
tg: # консоль сервиса
|
tg: # консоль сервиса
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys
|
|||||||
ssh-keygen -A
|
ssh-keygen -A
|
||||||
exec /usr/sbin/sshd -D -e "$@" &
|
exec /usr/sbin/sshd -D -e "$@" &
|
||||||
php service.php
|
php service.php
|
||||||
|
php iplimit.php &
|
||||||
php cron.php
|
php cron.php
|
||||||
+4
-3
@@ -1,9 +1,10 @@
|
|||||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||||
ssh-keygen -A
|
echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config
|
||||||
exec /usr/sbin/sshd -D -e "$@" &
|
echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config
|
||||||
|
service ssh start
|
||||||
off=$(cat /config/pac.json | jq -r .warpoff)
|
off=$(cat /config/pac.json | jq -r .warpoff)
|
||||||
key=$(cat /config/pac.json | jq -r .warp)
|
key=$(cat /config/pac.json | jq -r .warp)
|
||||||
if [ "$off" == 'null' ]
|
if [ "$off" = 'null' ]
|
||||||
then
|
then
|
||||||
warp-svc > /dev/null &
|
warp-svc > /dev/null &
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|||||||
Binary file not shown.
@@ -1,3 +1,35 @@
|
|||||||
|
02.03.2025 v2.14
|
||||||
|
- vless ip limit: фикс выключения юзера
|
||||||
|
22.02.2025 v2.13
|
||||||
|
- vless: улучшение сбора статы
|
||||||
|
- vless: фикс добавления правил srs для block outbound
|
||||||
|
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
|
||||||
|
- 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
|
||||||
|
- вывод статистики vless пользователей
|
||||||
|
- смягчил паттерн поиска reality degenerate в логах
|
||||||
07.01.2025 v2.4
|
07.01.2025 v2.4
|
||||||
- вернул shadowsocks (спасибо за донат)
|
- вернул shadowsocks (спасибо за донат)
|
||||||
04.01.2025
|
04.01.2025
|
||||||
|
|||||||
Reference in New Issue
Block a user