Compare commits

...

4 Commits

Author SHA1 Message Date
mercury 5f8979a62d update version 2024-04-09 18:14:04 +04:00
mercury 969e981874 timer for xray users 2024-04-09 18:13:19 +04:00
mercury 99d27da162 fix back in branches 2024-04-09 15:18:12 +04:00
mercury a0f8b4df05 fix sing-box sub 2024-04-09 15:16:34 +04:00
2 changed files with 66 additions and 3 deletions
+64 -3
View File
@@ -278,6 +278,9 @@ class Bot
case preg_match('~^/userXr (\d+)$~', $this->input['callback'], $m):
$this->userXr($m[1]);
break;
case preg_match('~^/timerXr (\d+)$~', $this->input['callback'], $m):
$this->timerXr($m[1]);
break;
case preg_match('~^/delxr (\d+)$~', $this->input['callback'], $m):
$this->delxr($m[1]);
break;
@@ -890,6 +893,7 @@ class Bot
{
while (true) {
$this->shutdownClient();
$this->shutdownClientXr();
$this->checkVersion();
$this->checkBackup();
$this->checkCert();
@@ -1038,6 +1042,24 @@ class Bot
}
}
public function shutdownClientXr()
{
try {
$c = $this->getXray();
$f = 0;
foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) {
if (!empty($v['time']) && $v['time'] < time()) {
unset($c['inbounds'][0]['settings']['clients'][$k]);
$f = 1;
}
}
if (!empty($f)) {
$this->restartXray($c);
}
} catch (Exception $e) {
}
}
public function renameClient(string $name, int $client)
{
$clients = $this->readClients();
@@ -1874,6 +1896,21 @@ class Bot
];
}
public function timerXr($k)
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter time like https://www.php.net/manual/ru/function.strtotime.php:",
$this->input['message_id'],
reply: 'enter time like https://www.php.net/manual/ru/function.strtotime.php:',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'callback' => 'setTimerXr',
'args' => [$k],
];
}
public function setAdKey($key)
{
$c = $this->getPacConf();
@@ -3467,6 +3504,18 @@ DNS-over-HTTPS with IP:
$this->xray();
}
public function setTimerXr($time, $i)
{
$c = $this->getXray();
if (empty($time)) {
unset($c['inbounds'][0]['settings']['clients'][$i]['time']);
} else {
$c['inbounds'][0]['settings']['clients'][$i]['time'] = strtotime($time);
}
file_put_contents('/config/xray.json', json_encode($c, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
$this->userXr($i);
}
public function renXrUs($name, $i)
{
$c = $this->getXray();
@@ -3500,9 +3549,10 @@ DNS-over-HTTPS with IP:
],
];
foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) {
$time = $v['time'] ? $this->getTime($v['time']) : '';
$data[] = [
[
'text' => "{$v['email']}",
'text' => "{$v['email']}" . ($time ? ": $time" : ''),
'callback_data' => "/userXr $k",
],
];
@@ -3543,6 +3593,16 @@ DNS-over-HTTPS with IP:
$text[] = "v2ray: <a href='$v2ray'>$v2ray</a>\n";
$text[] = "sing-box: <a href='$sing'>$sing</a>";
if ($time = $c['inbounds'][0]['settings']['clients'][$i]['time']) {
$text[] = "\ntimer: " . $this->getTime($time);
}
$data[] = [
[
'text' => $this->i18n('timer'),
'callback_data' => "/timerXr $i",
],
];
$data[] = [
[
'text' => $this->i18n('show QR'),
@@ -3641,7 +3701,8 @@ DNS-over-HTTPS with IP:
}
$c['outbounds'][0]['server'] = $domain;
$c['outbounds'][0]['tls']['reality']['public_key'] = $key;
$c['outbounds'][0]['uuid'] = $key;
$c['outbounds'][0]['tls']['reality']['public_key'] = $pac['xray'];
$c['outbounds'][0]['tls']['server_name'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
$c['outbounds'][0]['tls']['reality']['short_id'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
$c['route']['rules'][1]['domain_suffix'] = array_keys(array_filter($pac['includelist']));
@@ -4098,7 +4159,7 @@ DNS-over-HTTPS with IP:
file_put_contents('/update/branch', trim(str_replace('origin/', '', $v)));
}
}
$this->menu('config');
$this->menu('update');
}
public function logs()
+2
View File
@@ -1,3 +1,5 @@
09.04.2024 v1.17
- редактируемые конфиги v2ray/sing-box
09.04.2024 v1.16
- редактируемые конфиги v2ray/sing-box
09.04.2024 v1.15.4