Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2441eb9fd | |||
| 269d0e9956 | |||
| 8ba85164aa | |||
| e7cc7b66e2 | |||
| 54fa8d35b1 | |||
| ffe6bb4ba8 | |||
| 6be95533c4 | |||
| 8d13bee021 | |||
| db6a18f498 | |||
| 6954a16fa2 | |||
| ca7a9c955d | |||
| 852fbd55c6 | |||
| 3a8a843d8c | |||
| 90828d1117 | |||
| 37e8b96bcf | |||
| 306bc41813 | |||
| f6e5da382b | |||
| d7ed7042ec | |||
| 4496a30552 | |||
| ca1a596f85 | |||
| b3edf1bdcc | |||
| c6306aa918 | |||
| d5bbc9a564 | |||
| d2aab8ee4b | |||
| 304217d36e | |||
| 2622397542 | |||
| 702123e39c | |||
| 01ef7707c4 | |||
| 064d39d80b | |||
| 1b93d41421 | |||
| e41c8e30a4 | |||
| 260f988360 | |||
| ca4905220d | |||
| 08c5ff136e | |||
| 8709531717 | |||
| 71f53c3575 | |||
| 2607f1f264 | |||
| a94cab7dc1 | |||
| 694d446402 | |||
| 6074d40643 | |||
| 4b1df94325 | |||
| 232c75d5bf | |||
| 5e860a4896 | |||
| 5b05486b98 | |||
| fb22744fa7 | |||
| af812b7c93 | |||
| 3302ca8871 | |||
| 2c5eff03d5 | |||
| a8a203041f |
@@ -26,3 +26,5 @@ docker-compose.override.yml
|
||||
backup.json
|
||||
app/webapp/override/
|
||||
.rest
|
||||
|
||||
subscription.php
|
||||
+333
-106
@@ -40,7 +40,7 @@ class Bot
|
||||
$this->reg = '~' . implode('|', [
|
||||
'GET / HTTP',
|
||||
'GET /favicon.ico HTTP',
|
||||
preg_quote($this->getHashBot())
|
||||
preg_quote($this->getHashBot(1))
|
||||
]) . '~';
|
||||
}
|
||||
|
||||
@@ -162,6 +162,9 @@ class Bot
|
||||
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
|
||||
$this->switchBanIp();
|
||||
break;
|
||||
case preg_match('~^/switchMonthlyStats$~', $this->input['callback'], $m):
|
||||
$this->switchMonthlyStats();
|
||||
break;
|
||||
case preg_match('~^/setIpLimit$~', $this->input['callback'], $m):
|
||||
$this->setIpLimit();
|
||||
break;
|
||||
@@ -241,8 +244,7 @@ class Bot
|
||||
$this->addLinkDomain();
|
||||
break;
|
||||
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['chat'], $this->input['message_id']);
|
||||
$this->send($this->input['chat'], "your id: {$this->input['from']}\nchat id: {$this->input['chat']}", $this->input['message_id']);
|
||||
break;
|
||||
case preg_match('~^/adguardChBr$~', $this->input['callback'], $m):
|
||||
$this->adguardChBr();
|
||||
@@ -755,11 +757,11 @@ class Bot
|
||||
'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;
|
||||
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);
|
||||
}
|
||||
@@ -993,7 +995,7 @@ class Bot
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter pass",
|
||||
"@{$this->input['username']} enter password",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter password',
|
||||
);
|
||||
@@ -1011,7 +1013,7 @@ class Bot
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter name",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter password',
|
||||
reply: 'enter name',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
@@ -1188,8 +1190,7 @@ class Bot
|
||||
$this->ssh('ssserver -v -d -c /config.json', 'ss');
|
||||
$this->ssh('sslocal -v -d -c /config.json', 'proxy');
|
||||
|
||||
$this->sd($c, 1);
|
||||
if (!empty($nomenu)) {
|
||||
if (empty($nomenu)) {
|
||||
$this->menu('ss');
|
||||
}
|
||||
}
|
||||
@@ -1338,6 +1339,7 @@ class Bot
|
||||
$this->checkVersion();
|
||||
$this->checkBackup($period);
|
||||
$this->checkLogs($period);
|
||||
$this->checkResetXrayStats($period);
|
||||
$this->checkCert();
|
||||
$this->autoAnalyzeLogs();
|
||||
$this->xrayStatsUser();
|
||||
@@ -1357,14 +1359,22 @@ class Bot
|
||||
'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;
|
||||
$p['users'][$k]['session'] = [
|
||||
'download' => $d,
|
||||
'upload' => $u,
|
||||
$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) {
|
||||
@@ -1437,6 +1447,29 @@ class Bot
|
||||
}
|
||||
}
|
||||
|
||||
public function checkResetXrayStats($delta)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
if (!empty($pac['reset_monthly'])) {
|
||||
$now = strtotime(date('Y-m-d H:i:s'));
|
||||
$start = strtotime('first day of previous month midnight');
|
||||
$period = strtotime('1 month', 0);
|
||||
if (
|
||||
!empty($start)
|
||||
&& !empty($period)
|
||||
&& empty($this->backup)
|
||||
&& $now - $start >= 0
|
||||
&& (($now - $start) % $period < $delta)
|
||||
) {
|
||||
$this->resetXrStats(1);
|
||||
require __DIR__ . '/config.php';
|
||||
foreach ($c['admin'] as $admin) {
|
||||
$this->send($admin, "vless: reset stats");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkLogs($delta)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
@@ -3388,10 +3421,14 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page - 1 >= 0 ? $page - 1 : $all - 1) . ($openconnect ? '_1' : ''),
|
||||
],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/subnet {$wgpage}_$page" . ($openconnect ? '_1' : ''),
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page < $all - 1 ? $page + 1 : 0) . ($openconnect ? '_1' : ''),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3627,10 +3664,10 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/menu wg " . ($page - 1 >= 0 ? $page - 1 : $all - 1),
|
||||
],
|
||||
// [
|
||||
// 'text' => 'all',
|
||||
// 'callback_data' => "/menu wg -1",
|
||||
// ],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/menu wg $page",
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/menu wg " . ($page < $all - 1 ? $page + 1 : 0),
|
||||
@@ -4130,10 +4167,14 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/$menu " . ($page - 1 >= 0 ? $page - 1 : $all - 1),
|
||||
],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/$menu $page",
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/$menu " . ($page < $all - 1 ? $page + 1 : 0),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
$data[] = [
|
||||
@@ -4269,6 +4310,43 @@ DNS-over-HTTPS with IP:
|
||||
$this->menu('wg', 0);
|
||||
}
|
||||
|
||||
public function alignColumns(array $columns): string
|
||||
{
|
||||
// Находим максимальную длину для каждого столбца
|
||||
$columnLengths = [];
|
||||
foreach ($columns as $column) {
|
||||
$maxLength = 0;
|
||||
foreach ($column as $cell) {
|
||||
$len = mb_strlen($cell, 'UTF-8');
|
||||
$maxLength = max($maxLength, $len);
|
||||
}
|
||||
$columnLengths[] = $maxLength;
|
||||
}
|
||||
|
||||
// Получаем количество строк из первого столбца
|
||||
$rowCount = count($columns[0]);
|
||||
$columnCount = count($columns);
|
||||
|
||||
// Формируем строки с выравниванием
|
||||
$result = [];
|
||||
for ($row = 0; $row < $rowCount; $row++) {
|
||||
$line = '';
|
||||
for ($col = 0; $col < $columnCount; $col++) {
|
||||
$cell = $columns[$col][$row];
|
||||
$padding = str_repeat(' ', $columnLengths[$col] - mb_strlen($cell, 'UTF-8'));
|
||||
$line .= $cell . $padding;
|
||||
|
||||
// Добавляем разделитель между столбцами, кроме последнего
|
||||
if ($col < $columnCount - 1) {
|
||||
$line .= ' '; // Два пробела между столбцами
|
||||
}
|
||||
}
|
||||
$result[] = $line;
|
||||
}
|
||||
|
||||
return implode("\n", $result);
|
||||
}
|
||||
|
||||
public function menu($type = false, $arg = false, $return = false)
|
||||
{
|
||||
$conf = $this->getPacConf();
|
||||
@@ -4289,26 +4367,70 @@ DNS-over-HTTPS with IP:
|
||||
$f = '/docker/compose';
|
||||
$c = yaml_parse_file($f)['services'];
|
||||
$main[] = 'v' . getenv('VER') . " $branch" . ($update ? ' (have updates)' : '');
|
||||
$main[] = '';
|
||||
$main[] = $cron;
|
||||
$main[] = $this->i18n($backup ? 'on' : 'off') . ' autobackup' . ($backup ? " $backup" : '');
|
||||
$main[] = $this->i18n($conf['autoupdate'] ? 'on' : 'off') . ' autoupdate';
|
||||
$main[] = $this->i18n($conf['autoscan'] ? 'on' : 'off') . ' autoscan';
|
||||
$main[] = $this->i18n($conf['autodeny'] ? 'on' : 'off') . ' autoblock' . ($conf['deny'] ? ': ' . count($conf['deny']) : '');
|
||||
$main[] = '';
|
||||
$main[] = $this->i18n($c['wg'] ? 'on' : 'off') . ' ' . getenv('WGPORT') . ' Wireguard';
|
||||
$main[] = $this->i18n($c['wg1'] ? 'on' : 'off') . ' ' . getenv('WG1PORT') . ' Wireguard 1';
|
||||
$main[] = $this->i18n($c['tg'] ? 'on' : 'off') . ' ' . getenv('TGPORT') . ' MTProto';
|
||||
$main[] = $this->i18n($c['ad'] ? 'on' : 'off') . ' 853 AdguardHome DoT';
|
||||
$main[] = $this->i18n($c['ss'] ? 'on' : 'off') . ' 8388 Shadowsocks';
|
||||
|
||||
if (!empty($conf['domain'])) {
|
||||
$main[] = '';
|
||||
$oc = $this->getHashSubdomain('oc');
|
||||
$np = $this->getHashSubdomain('np');
|
||||
$main[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\n$np.{$conf['domain']} (for naiveproxy)\n$oc.{$conf['domain']} (for openconnect)" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']} (for adguard DoT)" : '') : $this->i18n('domain explain');
|
||||
$ssl = $this->expireCert();
|
||||
$main[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) . "\n" . $this->domainsCert() : 'none') : '';
|
||||
if (!empty($conf['domain'])) {
|
||||
$ssl_expiry = $this->expireCert();
|
||||
$certs = $this->domainsCert() ?: [];
|
||||
|
||||
$main[] = "<blockquote>";
|
||||
$main[] = "Domains:";
|
||||
$main[] = $conf['domain'] . (in_array($conf['domain'], $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
$main[] = 'naive ' . "$np.{$conf['domain']}" . (in_array("$np.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
$main[] = 'openconnect ' . "$oc.{$conf['domain']}" . (in_array("$oc.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
if (!empty($conf['adguardkey'])) {
|
||||
$main[] = "{$conf['adguardkey']}.{$conf['domain']}" . (in_array("{$conf['adguardkey']}.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '') . ' adguard DOT';;
|
||||
}
|
||||
$main[] = "</blockquote>";
|
||||
} else {
|
||||
$main[] = $this->i18n('domain explain');
|
||||
}
|
||||
}
|
||||
$main[] = '';
|
||||
|
||||
$main[] = '<code>';
|
||||
$main[] = $this->alignColumns([
|
||||
[
|
||||
$this->i18n($this->ssh($this->getPacConf()['amnezia'] ? 'awg' : 'wg', 'wg') ? 'on' : 'off') . ' ' . $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'),
|
||||
$this->i18n($this->ssh($this->getPacConf()['wg1_amnezia'] ? 'awg' : 'wg', 'wg1') ? 'on' : 'off') . ' ' . $this->i18n($this->getPacConf()['wg1_amnezia'] ? 'amnezia' : 'wg_title'),
|
||||
$this->i18n($this->ssh('pgrep xray', 'xr') ? 'on' : 'off') . ' ' . $this->i18n('xray'),
|
||||
$this->i18n($this->ssh('pgrep caddy', 'np') ? 'on' : 'off') . ' ' . $this->i18n('naive'),
|
||||
$this->i18n($this->ssh('pgrep ocserv', 'oc') ? 'on' : 'off') . ' ' . $this->i18n('ocserv'),
|
||||
$this->i18n($this->ssh('pgrep mtproto-proxy', 'tg') ? 'on' : 'off') . ' ' . $this->i18n('mtproto'),
|
||||
$this->i18n(exec("JSON=1 timeout 2 dnslookup google.com ad") ? 'on' : 'off') . ' ' . $this->i18n('ad_title'),
|
||||
$this->i18n($this->ssh('pgrep ssserver', 'ss') ? 'on' : 'off') . ' ' . $this->i18n('sh_title'),
|
||||
$this->i18n($this->warpStatus()) . ' ' . $this->i18n('warp'),
|
||||
],
|
||||
[
|
||||
$this->i18n($c['wg'] ? 'on' : 'off') . ' ' . getenv('WGPORT'),
|
||||
$this->i18n($c['wg1'] ? 'on' : 'off') . ' ' . getenv('WG1PORT'),
|
||||
$this->i18n('on') . ' 443',
|
||||
$this->i18n('on') . ' 443',
|
||||
$this->i18n('on') . ' 443',
|
||||
$this->i18n($c['tg'] ? 'on' : 'off') . ' ' . getenv('TGPORT'),
|
||||
$this->i18n($c['ad'] ? 'on' : 'off') . ' 853',
|
||||
$this->i18n($c['ss'] ? 'on' : 'off') . ' ' . getenv('SSPORT'),
|
||||
'',
|
||||
],
|
||||
]);
|
||||
$main[] = '';
|
||||
$main[] = $this->alignColumns([
|
||||
[
|
||||
$this->i18n($backup ? 'on' : 'off') . ' autobackup',
|
||||
$this->i18n($conf['autoupdate'] ? 'on' : 'off') . ' autoupdate',
|
||||
$this->i18n($conf['autoscan'] ? 'on' : 'off') . ' autoscan',
|
||||
],
|
||||
[
|
||||
$this->i18n($conf['autodeny'] ? 'on' : 'off') . ' autoblock' . ($conf['deny'] ? ': ' . count($conf['deny']) : ''),
|
||||
$this->i18n($conf['reset_monthly'] ? 'on' : 'off') . ' autoreset',
|
||||
$cron,
|
||||
],
|
||||
]);
|
||||
$main[] = '</code>';
|
||||
|
||||
}
|
||||
$menu = [
|
||||
'main' => [
|
||||
@@ -4350,7 +4472,7 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => "/menu adguard",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('warp') . ': ' . $this->warpStatus(),
|
||||
'text' => $this->i18n('warp'),
|
||||
'callback_data' => "/warp",
|
||||
],
|
||||
],
|
||||
@@ -4452,6 +4574,14 @@ DNS-over-HTTPS with IP:
|
||||
$this->ipMenu();
|
||||
}
|
||||
|
||||
public function switchMonthlyStats()
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
$c['reset_monthly'] = $c['reset_monthly'] ? 0 : 1;
|
||||
$this->setPacConf($c);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function switchIpLimit($limit)
|
||||
{
|
||||
$limit = explode(':', $limit);
|
||||
@@ -4672,10 +4802,14 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/analysisIp " . ($page - 1 >= 0 ? $page - 1 : $all - 1),
|
||||
],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/analysisIp $page",
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/analysisIp " . ($page < $all - 1 ? $page + 1 : 0),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4881,10 +5015,14 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/denyList " . ($page - 1 >= 0 ? $page - 1 : $all - 1) . ($white ? " 1" : ' 0'),
|
||||
],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/denyList $page" . ($white ? " 1" : ' 0'),
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/denyList " . ($page < $all - 1 ? $page + 1 : 0) . ($white ? " 1" : ' 0'),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
$data[] = [
|
||||
@@ -5171,35 +5309,21 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function getMirror()
|
||||
{
|
||||
unlink('/config/mirror.tar.gz');
|
||||
unlink('/config/mirror.tar');
|
||||
$s = file_get_contents('/mirror/start_socat.sh');
|
||||
$t = preg_replace([
|
||||
'~{ip}~',
|
||||
'~{tg}~',
|
||||
'~{ss}~',
|
||||
'~{wg}~',
|
||||
$t = str_replace([
|
||||
'~ip~',
|
||||
'~tg~',
|
||||
'~ss~',
|
||||
'~wg1~',
|
||||
'~wg2~',
|
||||
], [
|
||||
getenv('IP'),
|
||||
getenv('TGPORT'),
|
||||
getenv('SSPORT'),
|
||||
getenv('WGPORT'),
|
||||
getenv('WG1PORT'),
|
||||
], $s);
|
||||
file_put_contents('/mirror/start_socat.sh', $t);
|
||||
$a = new PharData('/config/mirror.tar');
|
||||
$a->buildFromDirectory('/mirror');
|
||||
$a->compress(Phar::GZ);
|
||||
if (!empty($this->input)) {
|
||||
$this->sendFile($this->input['from'], curl_file_create('/config/mirror.tar.gz'));
|
||||
} else {
|
||||
header('Content-Disposition: attachment; filename=mirror.tar.gz');
|
||||
header('Content-Type: application/tar+gzip');
|
||||
echo file_get_contents('/config/mirror.tar.gz');
|
||||
exit;
|
||||
}
|
||||
unlink('/config/mirror.tar.gz');
|
||||
unlink('/config/mirror.tar');
|
||||
file_put_contents('/mirror/start_socat.sh', $s);
|
||||
$this->sendFile($this->input['from'], new CURLStringFile($t, 'socat.sh', 'application/x-sh'));
|
||||
}
|
||||
|
||||
public function ocMenu()
|
||||
@@ -5304,10 +5428,13 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function delxr($i)
|
||||
{
|
||||
$r = $this->getXray();
|
||||
$r = $this->getXray();
|
||||
$st = $this->getXrayStats();
|
||||
foreach ($r['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
if ($i == $k) {
|
||||
unset($r['inbounds'][0]['settings']['clients'][$k]);
|
||||
unset($st['users'][$k]);
|
||||
$this->setXrayStats($st);
|
||||
$this->restartXray($r);
|
||||
$this->adguardXrayClients();
|
||||
break;
|
||||
@@ -5335,8 +5462,16 @@ DNS-over-HTTPS with IP:
|
||||
$p = $this->getPacConf();
|
||||
$users = array_map(fn ($e) => trim($e), explode(',', $users));
|
||||
$users = array_map(fn ($e) => explode(':', $e), $users);
|
||||
foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
$uuids[] = $v['id'];
|
||||
$emails[] = $v['email'];
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
$uuid = $user[1] ?: trim($this->ssh('xray uuid', 'xr'));
|
||||
if (in_array($uuid, $uuids ?: []) || in_array($user[0], $emails ?: [])) {
|
||||
$this->send($this->input['chat'], "user {$user[0]} already exists");
|
||||
return $this->xray();
|
||||
}
|
||||
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
|
||||
'id' => $uuid,
|
||||
'email' => $user[0],
|
||||
@@ -5366,20 +5501,22 @@ DNS-over-HTTPS with IP:
|
||||
$this->send($this->input['chat'], 'wrong format');
|
||||
return;
|
||||
}
|
||||
if (!empty($c['inbounds'][0]['settings']['clients'][$i]['off'])) {
|
||||
$this->switchXr($i, 1);
|
||||
$c = $this->getXray();
|
||||
}
|
||||
$c['inbounds'][0]['settings']['clients'][$i]['time'] = $time;
|
||||
}
|
||||
file_put_contents('/config/xray.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
$this->userXr($i);
|
||||
$this->restartXray($c, 1);
|
||||
if (!empty($c['inbounds'][0]['settings']['clients'][$i]['off'])) {
|
||||
$this->switchXr($i, 0, 1);
|
||||
} else {
|
||||
$this->userXr($i);
|
||||
}
|
||||
}
|
||||
|
||||
public function switchXr($i, $nm = 0)
|
||||
public function switchXr($i, $nm = 0, $time = false)
|
||||
{
|
||||
$c = $this->getXray();
|
||||
unset($c['inbounds'][0]['settings']['clients'][$i]['time']);
|
||||
if (empty($time)) {
|
||||
unset($c['inbounds'][0]['settings']['clients'][$i]['time']);
|
||||
}
|
||||
if (empty($c['inbounds'][0]['settings']['clients'][$i]['off'])) {
|
||||
$c['inbounds'][0]['settings']['clients'][$i]['off'] = $c['inbounds'][0]['settings']['clients'][$i]['id'];
|
||||
$c['inbounds'][0]['settings']['clients'][$i]['id'] = trim($this->ssh('xray uuid', 'xr'));
|
||||
@@ -5415,19 +5552,18 @@ DNS-over-HTTPS with IP:
|
||||
public function resetXrUser($i)
|
||||
{
|
||||
$c = $this->getXrayStats();
|
||||
$c['clients'][$i]['global'] = [
|
||||
'download' => 0,
|
||||
'upload' => 0,
|
||||
];
|
||||
unset($c['users'][$i]);
|
||||
$this->restartXray($this->getXray());
|
||||
$this->userXr($i);
|
||||
}
|
||||
|
||||
public function resetXrStats()
|
||||
public function resetXrStats($nomenu = false)
|
||||
{
|
||||
$this->restartXray($this->getXray());
|
||||
$this->setXrayStats([]);
|
||||
$this->xray();
|
||||
if (empty($nomenu)) {
|
||||
$this->xray();
|
||||
}
|
||||
}
|
||||
|
||||
public function listXr($i)
|
||||
@@ -5600,6 +5736,7 @@ DNS-over-HTTPS with IP:
|
||||
<code>~block~</code>
|
||||
<code>~warp~</code>
|
||||
<code>~dns~</code>
|
||||
<code>~dnspath~</code>
|
||||
<code>~uid~</code>
|
||||
<code>~domain~</code>
|
||||
<code>~directdomain~</code>
|
||||
@@ -5733,11 +5870,16 @@ DNS-over-HTTPS with IP:
|
||||
$st = $this->getXrayStats();
|
||||
$td = $this->getBytes($st['global']['download'] + $st['session']['download']);
|
||||
$tu = $this->getBytes($st['global']['upload'] + $st['session']['upload']);
|
||||
$text[] = "↓$td ↑$tu";
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('reset stats') . ": ↓$td ↑$tu",
|
||||
'text' => $this->i18n('reset stats'),
|
||||
'callback_data' => '/resetXrStats',
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('reset monthly') . ": " . $this->i18n($this->getPacConf()['reset_monthly'] ? 'on' : 'off'),
|
||||
'callback_data' => '/switchMonthlyStats',
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
@@ -5751,7 +5893,6 @@ 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')),
|
||||
@@ -5761,6 +5902,9 @@ DNS-over-HTTPS with IP:
|
||||
'text' => $this->i18n('Websocket') . ' ' . ($p['transport'] != 'Reality' ? $this->i18n('on') : $this->i18n('off')),
|
||||
'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",
|
||||
@@ -5830,10 +5974,14 @@ DNS-over-HTTPS with IP:
|
||||
'text' => '<<',
|
||||
'callback_data' => "/xray " . ($page - 1 >= 0 ? $page - 1 : $all - 1),
|
||||
],
|
||||
[
|
||||
'text' => $page + 1,
|
||||
'callback_data' => "/xray $page",
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/xray " . ($page < $all - 1 ? $page + 1 : 0),
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
$data[] = [
|
||||
@@ -5948,7 +6096,7 @@ DNS-over-HTTPS with IP:
|
||||
if (!empty($this->ssh('pgrep warp-svc', 'wp'))) {
|
||||
$st = $this->ssh('curl -m 1 -x socks5://127.0.0.1:40000 https://cloudflare.com/cdn-cgi/trace', 'wp');
|
||||
preg_match('~warp=(\w+)~', $st, $m);
|
||||
return $m[1];
|
||||
return trim($m[1]) ?: 'off';
|
||||
}
|
||||
return 'off';
|
||||
}
|
||||
@@ -5988,7 +6136,6 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
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'])) {
|
||||
@@ -6000,6 +6147,9 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty(preg_match('~(?<date>.+)\sfrom\s(?<ip>\d+\.\d+\.\d+\.\d+)(?=.+email:\s(?<email>.+))~', $line, $m))) {
|
||||
return;
|
||||
}
|
||||
if (!empty($m['ip']) && !empty($m['email'])) {
|
||||
$ip = ip2long($m['ip']);
|
||||
if (!empty($this->pool[$m['email']]['ip']) && $this->pool[$m['email']]['ip'] != $ip) {
|
||||
@@ -6010,19 +6160,20 @@ DNS-over-HTTPS with IP:
|
||||
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)");
|
||||
foreach ($c['admin'] as $admin) {
|
||||
$this->send($admin, "vless: {$m['email']} limit ip " . count($this->pool[$m['email']]['ips']) . ' > ' . ($pac['ip_count'] ?: 1), button: [[
|
||||
[
|
||||
'text' => $this->i18n($c['off'] ? 'off' : 'on'),
|
||||
'callback_data' => "/switchXr $k",
|
||||
],
|
||||
]]);
|
||||
}
|
||||
unset($this->pool[$m['email']]);
|
||||
$this->switchXr($k, 1);
|
||||
$flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($flag)) {
|
||||
$this->pool[$m['email']]['ip'] = $ip;
|
||||
}
|
||||
$this->pool[$m['email']]['ip'] = $ip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6151,6 +6302,9 @@ DNS-over-HTTPS with IP:
|
||||
$hash = $this->getHashBot();
|
||||
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . " -> {$c['email']}\n";
|
||||
if (file_exists(__DIR__ . '/subscription.php')) {
|
||||
$text[] = "<a href='$scheme://{$domain}/pac$hash/sub?id={$c['id']}'>subscription</a>";
|
||||
}
|
||||
$text[] = "<pre><code>{$this->linkXray($i)}</code></pre>\n";
|
||||
|
||||
$text[] = "<a href='$scheme://{$domain}/pac$hash?t=s&r=v&s={$c['id']}#{$c['email']}'>import://v2rayng</a>";
|
||||
@@ -6278,7 +6432,57 @@ DNS-over-HTTPS with IP:
|
||||
return $c['domain'] ?: $this->ip;
|
||||
}
|
||||
|
||||
public function subscription()
|
||||
public function sub()
|
||||
{
|
||||
$xr = $this->getXray();
|
||||
$pac = $this->getPacConf();
|
||||
$st = $this->getXrayStats();
|
||||
$domain = $_GET['cdn'] ?: ($_SERVER['SERVER_NAME'] ?: $this->getDomain($pac['transport'] != 'Reality'));
|
||||
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
|
||||
$hash = $this->getHashBot();
|
||||
$flag = true;
|
||||
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
if ($v['id'] == $_GET['id']) {
|
||||
if (empty($v['off'])) {
|
||||
$flag = false;
|
||||
}
|
||||
$uid = $v['id'];
|
||||
$email = $v['email'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$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']);
|
||||
$singbox = "$scheme://{$domain}/pac$hash/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 'si',
|
||||
's' => $uid,
|
||||
]));
|
||||
$xray = "$scheme://{$domain}/pac$hash/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 's',
|
||||
's' => $uid,
|
||||
]));
|
||||
$clash = "$scheme://{$domain}/pac$hash/" . base64_encode(serialize([
|
||||
'h' => $hash,
|
||||
't' => 'cl',
|
||||
's' => $uid,
|
||||
]));
|
||||
$vless = $this->linkXray($k);
|
||||
$windows = "$scheme://{$domain}/pac$hash?t=si&r=w&s=$uid";
|
||||
$_GET['s'] = $uid;
|
||||
foreach ([
|
||||
'xray' => 's',
|
||||
'singbox' => 'si',
|
||||
'clash' => 'cl'
|
||||
] as $k => $v) {
|
||||
$_GET['t'] = $v;
|
||||
$configs[$k] = $this->subscription(1);
|
||||
}
|
||||
require __DIR__ . '/subscription.php';
|
||||
}
|
||||
|
||||
public function subscription($return = false)
|
||||
{
|
||||
switch ($_GET['t']) {
|
||||
case 's':
|
||||
@@ -6347,7 +6551,7 @@ DNS-over-HTTPS with IP:
|
||||
header("Location: hiddify://install-config/?url=$si");
|
||||
exit;
|
||||
case 'c':
|
||||
header("Location: clash://install-config/?url=$cl&name=$email");
|
||||
header("Location: clash://install-config/?url=$cl&overwrite=no&name=$email");
|
||||
exit;
|
||||
case 'w':
|
||||
$link = htmlspecialchars($si, ENT_XML1, 'UTF-8');
|
||||
@@ -6487,6 +6691,7 @@ DNS-over-HTTPS with IP:
|
||||
'"~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",
|
||||
'~dnspath~' => "/dns-query$hash/$uid",
|
||||
'~uid~' => $uid,
|
||||
'~domain~' => $domain,
|
||||
'~directdomain~' => $pac['domain'],
|
||||
@@ -6531,6 +6736,12 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!empty($return)) {
|
||||
if ($_GET['t'] == 'cl') {
|
||||
return yaml_emit($c);
|
||||
}
|
||||
return json_encode($c);
|
||||
}
|
||||
|
||||
if ($_GET['t'] == 'cl') {
|
||||
header('Content-type: text/yaml');
|
||||
@@ -6644,7 +6855,7 @@ DNS-over-HTTPS with IP:
|
||||
if (!empty($route['rules'])) {
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
if (!empty($v['addruleset'])) {
|
||||
$t[$v['outbound']] = $k;
|
||||
$t[$v['outbound'] ?: 'block'] = $k;
|
||||
}
|
||||
}
|
||||
$p = $this->getPacConf();
|
||||
@@ -6793,14 +7004,16 @@ DNS-over-HTTPS with IP:
|
||||
$this->ssh("nginx -s reload 2>&1", 'up');
|
||||
}
|
||||
|
||||
public function getHashBot()
|
||||
public function getHashBot($notset = false)
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($p['hashbot'])) {
|
||||
return $p['hashbot'];
|
||||
}
|
||||
$p['hashbot'] = substr(hash('sha256', $this->key), 0, 8);
|
||||
$this->setPacConf($p);
|
||||
if (empty($notset)) {
|
||||
$this->setPacConf($p);
|
||||
}
|
||||
return $p['hashbot'];
|
||||
}
|
||||
|
||||
@@ -6845,7 +7058,13 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
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)
|
||||
@@ -7064,7 +7283,7 @@ DNS-over-HTTPS with IP:
|
||||
if (empty($domains)) {
|
||||
return false;
|
||||
}
|
||||
return implode("\n", array_map(fn($e) => trim($e), explode(',', str_replace('DNS:', '', $domains))));
|
||||
return array_map(fn($e) => trim($e), explode(',', str_replace('DNS:', '', $domains)));
|
||||
}
|
||||
|
||||
public function updatebot()
|
||||
@@ -7134,17 +7353,24 @@ DNS-over-HTTPS with IP:
|
||||
public function configMenu()
|
||||
{
|
||||
$conf = $this->getPacConf();
|
||||
if (!empty($conf['subdomain'])) {
|
||||
$custom = "\ncustom:\n";
|
||||
foreach ($conf['subdomain'] as $v) {
|
||||
$custom .= "$v\n";
|
||||
}
|
||||
}
|
||||
$oc = $this->getHashSubdomain('oc');
|
||||
$np = $this->getHashSubdomain('np');
|
||||
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\n$np.{$conf['domain']} (for naiveproxy)\n$oc.{$conf['domain']} (for openconnect)" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']} (for adguard DoT)" : '') : $this->i18n('domain explain');
|
||||
$ssl = $this->expireCert();
|
||||
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) . "\n" . $this->domainsCert() : 'none') : '';
|
||||
if (!empty($conf['domain'])) {
|
||||
$ssl_expiry = $this->expireCert();
|
||||
$certs = $this->domainsCert() ?: [];
|
||||
|
||||
$text[] = "<blockquote>";
|
||||
$text[] = "Domains:";
|
||||
$text[] = $conf['domain'] . (in_array($conf['domain'], $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
$text[] = 'naive ' . "$np.{$conf['domain']}" . (in_array("$np.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
$text[] = 'openconnect ' . "$oc.{$conf['domain']}" . (in_array("$oc.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '');
|
||||
if (!empty($conf['adguardkey'])) {
|
||||
$text[] = "{$conf['adguardkey']}.{$conf['domain']}" . (in_array("{$conf['adguardkey']}.{$conf['domain']}", $certs) ? ' (ssl: ' . date('Y-m-d H:i:s', $ssl_expiry) . ')' : '') . ' adguard DOT';;
|
||||
}
|
||||
$text[] = "</blockquote>";
|
||||
} else {
|
||||
$text[] = $this->i18n('domain explain');
|
||||
}
|
||||
|
||||
$data = [
|
||||
[
|
||||
@@ -8065,8 +8291,9 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
echo "$ip\n";
|
||||
var_dump($r = $this->request('setWebhook', [
|
||||
'url' => "https://$ip/tlgrm?k={$this->key}",
|
||||
'certificate' => curl_file_create('/certs/self_public'),
|
||||
'url' => "https://$ip/tlgrm?k={$this->key}",
|
||||
'certificate' => curl_file_create('/certs/self_public'),
|
||||
'allowed_updates' => json_encode(['*']),
|
||||
]));
|
||||
if (!empty($r['result']) && $r['result'] == true) {
|
||||
file_put_contents('/start', 1);
|
||||
|
||||
+5
-1
@@ -38,10 +38,14 @@ switch (true) {
|
||||
|
||||
// adguard cookie
|
||||
case preg_match('~^' . preg_quote("/webapp$hash/check") . '~', $_SERVER['REQUEST_URI']) && $webapp:
|
||||
setcookie('c', substr(hash('sha256', $c['key']), 0, 8), 0, '/');
|
||||
setcookie('c', $hash, 0, '/');
|
||||
echo "/adguard$hash/";
|
||||
break;
|
||||
|
||||
case preg_match('~^' . preg_quote("/pac$hash/sub") . '~', $_SERVER['REQUEST_URI']) && file_exists(__DIR__ . '/subscription.php'):
|
||||
$bot->sub();
|
||||
exit;
|
||||
|
||||
// subs & pac
|
||||
case preg_match('~^' . preg_quote("/pac$hash") . '~', $_SERVER['REQUEST_URI']):
|
||||
if (!empty($t = unserialize(base64_decode(explode('/', $_SERVER['REQUEST_URI'])[2])))) { // fix sing-box import
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
"uuid": "~uid~",
|
||||
"network": "tcp",
|
||||
"flow": "xtls-rprx-vision",
|
||||
"udp": true,
|
||||
"tls": true,
|
||||
"reality-opts": {
|
||||
"public-key": "~public_key~",
|
||||
|
||||
+14
-6
@@ -42,10 +42,18 @@ services:
|
||||
depends_on:
|
||||
php:
|
||||
condition: service_healthy
|
||||
ng:
|
||||
condition: service_started
|
||||
ad:
|
||||
condition: service_started
|
||||
ss:
|
||||
condition: service_started
|
||||
xr:
|
||||
condition: service_started
|
||||
oc:
|
||||
condition: service_started
|
||||
np:
|
||||
condition: service_started
|
||||
env_file:
|
||||
- path: ./.env
|
||||
required: true # default
|
||||
@@ -79,9 +87,6 @@ services:
|
||||
- 80:80
|
||||
hostname: nginx
|
||||
container_name: nginx-${VER}
|
||||
depends_on:
|
||||
up:
|
||||
condition: service_started
|
||||
env_file:
|
||||
- path: ./.env
|
||||
required: true # default
|
||||
@@ -95,6 +100,9 @@ services:
|
||||
xray:
|
||||
ipv4_address: 10.10.1.2
|
||||
logging: *default-logging
|
||||
depends_on:
|
||||
php:
|
||||
condition: service_healthy
|
||||
php:
|
||||
image: mercurykd/vpnbot-php:1.7
|
||||
build:
|
||||
@@ -147,7 +155,7 @@ services:
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
service:
|
||||
image: mercurykd/vpnbot-php:1.6
|
||||
image: mercurykd/vpnbot-php:1.7
|
||||
build:
|
||||
dockerfile: dockerfile/php.dockerfile
|
||||
args:
|
||||
@@ -432,7 +440,7 @@ services:
|
||||
ipv4_address: 10.10.0.12
|
||||
logging: *default-logging
|
||||
wp:
|
||||
image: mercurykd/vpnbot-wp:1.2
|
||||
image: mercurykd/vpnbot-wp:1.3
|
||||
build:
|
||||
dockerfile: dockerfile/warp.dockerfile
|
||||
args:
|
||||
@@ -442,7 +450,7 @@ services:
|
||||
devices:
|
||||
- /dev/net/tun:/dev/net/tun
|
||||
volumes:
|
||||
- ./config/.profile:/root/.ashrc:ro
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./ssh:/ssh
|
||||
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||
- ./config:/config
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
FROM ubuntu:22.04 AS build
|
||||
RUN apt update && apt install -y curl gpg lsb-release \
|
||||
FROM ubuntu:22.04
|
||||
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 \
|
||||
&& 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
|
||||
|
||||
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 \
|
||||
&& apt update && apt install -y cloudflare-warp \
|
||||
&& mkdir /root/.ssh
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
b:
|
||||
docker compose build
|
||||
u: # запуск контейнеров
|
||||
$(eval IP := $(shell curl -s -t 1 2ip.io || curl -s -t 1 ipinfo.io/ip || curl -s -t 1 ifconfig.me))
|
||||
$(eval IP := $(shell hostname -I | awk '{print $$1}'))
|
||||
bash ./update/update.sh &
|
||||
touch ./override.env ./docker-compose.override.yml
|
||||
IP=$(IP) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
@@ -32,7 +32,7 @@ up: # консоль сервиса
|
||||
ad: # консоль сервиса
|
||||
docker compose exec ad /bin/sh
|
||||
wp: # консоль сервиса
|
||||
docker compose exec wp /bin/sh
|
||||
docker compose exec wp bash
|
||||
proxy: # консоль сервиса
|
||||
docker compose exec proxy /bin/sh
|
||||
tg: # консоль сервиса
|
||||
@@ -41,6 +41,8 @@ xr: # консоль сервиса
|
||||
docker compose exec xr /bin/sh
|
||||
oc: # консоль сервиса
|
||||
docker compose exec oc /bin/sh
|
||||
service: # консоль сервиса
|
||||
docker compose exec service /bin/sh
|
||||
clean:
|
||||
docker image prune
|
||||
docker builder prune
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
socat:
|
||||
build:
|
||||
dockerfile: ./dockerfile
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
- 853:853
|
||||
- ${TGPORT}:${TGPORT}
|
||||
- ${SSPORT}:${SSPORT}
|
||||
- ${SSPORT}:${SSPORT}/udp
|
||||
- ${WGPORT}:${WGPORT}/udp
|
||||
volumes:
|
||||
- ./start_socat.sh:/start_socat.sh
|
||||
command: /bin/sh /start_socat.sh
|
||||
stop_grace_period: 1s
|
||||
@@ -1,2 +0,0 @@
|
||||
FROM alpine:3.18
|
||||
RUN apk add socat htop net-tools
|
||||
@@ -1,11 +0,0 @@
|
||||
b:
|
||||
docker compose build --no-cache
|
||||
u:
|
||||
docker compose up -d --build
|
||||
d:
|
||||
docker compose down
|
||||
ps:
|
||||
docker compose ps
|
||||
e:
|
||||
docker compose exec socat sh
|
||||
r: d u
|
||||
+53
-8
@@ -1,8 +1,53 @@
|
||||
socat TCP-LISTEN:80,fork TCP:{ip}:80 &
|
||||
socat TCP-LISTEN:443,fork TCP:{ip}:443 &
|
||||
socat TCP-LISTEN:853,fork TCP:{ip}:853 &
|
||||
socat TCP-LISTEN:{tg},fork TCP:{ip}:{tg} &
|
||||
socat TCP-LISTEN:{ss},fork TCP:{ip}:{ss} &
|
||||
socat UDP-LISTEN:{ss},fork UDP:{ip}:{ss} &
|
||||
socat UDP-LISTEN:{wg},fork UDP:{ip}:{wg} &
|
||||
tail -f /dev/null
|
||||
#!/bin/bash
|
||||
|
||||
# Параметры (можно менять)
|
||||
PORTS=(80 443 853 ~tg~ ~ss~ ~wg1~ ~wg2~) # Прослушиваемые порты
|
||||
TARGET="~ip~" # Куда перенаправляем трафик
|
||||
TCP_CMD="socat TCP-LISTEN:{PORT},fork,reuseaddr TCP:$TARGET:{PORT}"
|
||||
UDP_CMD="socat UDP-LISTEN:{PORT},fork,reuseaddr UDP:$TARGET:{PORT}"
|
||||
|
||||
# Проверяем, установлен ли socat
|
||||
if ! command -v socat &> /dev/null; then
|
||||
echo "socat не установлен. Устанавливаем..."
|
||||
if [[ -f /etc/debian_version ]]; then
|
||||
sudo apt update && sudo apt install -y socat
|
||||
elif [[ -f /etc/redhat-release ]]; then
|
||||
sudo yum install -y socat
|
||||
else
|
||||
echo "Ошибка: Неизвестный дистрибутив. Установите socat вручную."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Проверяем, заняты ли порты (TCP и UDP)
|
||||
for PORT in "${PORTS[@]}"; do
|
||||
# Проверка TCP
|
||||
if ss -tulnp | grep -q ":$PORT "; then
|
||||
PROCESS=$(ss -tulnp | grep ":$PORT " | awk '{print $7}')
|
||||
echo "Ошибка: Порт $PORT (TCP) занят процессом: $PROCESS"
|
||||
exit 1
|
||||
fi
|
||||
# Проверка UDP
|
||||
if ss -ulnp | grep -q ":$PORT "; then
|
||||
PROCESS=$(ss -ulnp | grep ":$PORT " | awk '{print $6}')
|
||||
echo "Ошибка: Порт $PORT (UDP) занят процессом: $PROCESS"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Запускаем socat для каждого порта (TCP и UDP)
|
||||
for PORT in "${PORTS[@]}"; do
|
||||
# TCP
|
||||
CMD_TCP=$(echo "$TCP_CMD" | sed "s/{PORT}/$PORT/g")
|
||||
echo "Запуск (TCP): $CMD_TCP"
|
||||
eval "$CMD_TCP &" # Запускаем в фоне
|
||||
|
||||
# UDP
|
||||
CMD_UDP=$(echo "$UDP_CMD" | sed "s/{PORT}/$PORT/g")
|
||||
echo "Запуск (UDP): $CMD_UDP"
|
||||
eval "$CMD_UDP &" # Запускаем в фоне
|
||||
done
|
||||
|
||||
echo "socat запущен для портов: ${PORTS[*]} (TCP и UDP)"
|
||||
echo "Трафик перенаправляется на: $TARGET"
|
||||
echo "Для остановки выполните: pkill socat"
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config
|
||||
echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config
|
||||
service ssh start
|
||||
off=$(cat /config/pac.json | jq -r .warpoff)
|
||||
key=$(cat /config/pac.json | jq -r .warp)
|
||||
if [ "$off" == 'null' ]
|
||||
if [ "$off" = 'null' ]
|
||||
then
|
||||
warp-svc > /dev/null &
|
||||
sleep 3
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -38,7 +38,7 @@ do
|
||||
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "launching the bot"/')"
|
||||
> $pwd/update/key
|
||||
> $pwd/update/curl
|
||||
IP=$(curl -s -t 1 2ip.io || curl -s -t 1 ipinfo.io/ip || curl -s -t 1 ifconfig.me) VER=$(git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
IP=$(hostname -I | awk '{print $1}') VER=$(git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
|
||||
bash $pwd/update/update.sh &
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,38 @@
|
||||
16.07.2025 v2.23
|
||||
- фикс зависания бота из-за пустого статуса warp
|
||||
- скрипт socat.sh для мостов /mirror
|
||||
04.07.2025 v2.23
|
||||
- фикс двойного /id
|
||||
- фикс отображения статы vless на мобилке
|
||||
- страница подписок app/subscription.php
|
||||
18.06.2025 v2.22
|
||||
- фикс определения айпи при запуске
|
||||
11.06.2025 v2.21
|
||||
- пагинация в списках
|
||||
20.05.2025 v2.20
|
||||
- коррекция главного меню
|
||||
- vless: опция обнуления статы ежемесячно
|
||||
17.05.2025 v2.19
|
||||
- фикс падения vless при одинаковом имени пользователей
|
||||
- фикс падения vless при установке таймера для выключенного пользователя
|
||||
- подсветка в меню работы процесса контейнера
|
||||
- overwrite=no для импорта клеш подписки (legiz)
|
||||
18.04.2025 v2.18
|
||||
- фикс отсутствия ssl при первом старте
|
||||
- iplimit уведомляет без отключения пользователя
|
||||
- включение udp в mihomo-шаблоне
|
||||
- удаление лишнего образа пхп
|
||||
07.04.2025 v2.17
|
||||
- фикс циклической перезагрузки панели adguardHome
|
||||
07.04.2025 v2.16
|
||||
- фикс warp
|
||||
07.04.2025 v2.15
|
||||
- миграция поддоменов np/oc вместе в с бэкапом
|
||||
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: возможность указать кол-во айпи
|
||||
|
||||
Reference in New Issue
Block a user