Compare commits

...

3 Commits

Author SHA1 Message Date
mercury 68e6e5919d fixes for first launch 2024-10-21 01:07:05 +04:00
mercury 28c5b9d506 xray route: учет регистра в process_name, package_name 2024-10-14 09:47:19 +04:00
mercury 9cc42fd34a xray route: добавлен список process_name 2024-10-14 01:11:21 +04:00
8 changed files with 118 additions and 182 deletions
+92 -44
View File
@@ -145,6 +145,9 @@ class Bot
case preg_match('~^/appOutbound$~', $this->input['callback'], $m):
$this->appOutbound();
break;
case preg_match('~^/processOutbound$~', $this->input['callback'], $m):
$this->processOutbound();
break;
case preg_match('~^/offWarp$~', $this->input['callback'], $m):
$this->offWarp();
break;
@@ -431,6 +434,9 @@ class Bot
case preg_match('~^/xtlsapp(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsapp($m[1] ?: 0);
break;
case preg_match('~^/xtlsprocess(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsprocess($m[1] ?: 0);
break;
case preg_match('~^/xtlsrulesset(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsrulesset($m[1] ?: 0);
break;
@@ -1754,10 +1760,14 @@ class Bot
$this->adguardProtect();
$u = $this->ssh("nginx -t 2>&1", 'ng');
$out[] = $u;
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
if (empty($nomenu)) {
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
}
if (preg_match('~test is successful~', $u)) {
$out[] = $this->ssh("nginx -s reload 2>&1", 'ng');
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
if (empty($nomenu)) {
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
}
$this->setPacConf($conf);
$this->chocdomain($domain);
$this->setUpstreamDomainOcserv($domain);
@@ -2422,7 +2432,7 @@ DNS-over-HTTPS with IP:
if (!empty($domains)) {
$conf = $this->getPacConf();
foreach ($domains as $k => $v) {
$conf[$type][$type == 'rulessetlist' ? trim($v) : idn_to_ascii(trim($v))] = true;
$conf[$type][in_array($type, ['rulessetlist', 'packagelist', 'processlist']) ? trim($v) : idn_to_ascii(trim($v))] = true;
}
ksort($conf[$type]);
$this->setPacConf($conf);
@@ -2446,6 +2456,10 @@ DNS-over-HTTPS with IP:
$this->xrayUpdateRules();
$this->xtlswarp();
break;
case 'processlist':
$this->xrayUpdateRules();
$this->xtlsprocess();
break;
case 'packagelist':
$this->xrayUpdateRules();
$this->xtlsapp();
@@ -3425,6 +3439,9 @@ DNS-over-HTTPS with IP:
case 'packagelist':
$this->xtlsapp();
break;
case 'processlist':
$this->xtlsprocess();
break;
case 'rulessetlist':
$this->xtlsrulesset();
break;
@@ -3570,6 +3587,14 @@ DNS-over-HTTPS with IP:
$this->xtlsapp();
}
public function processOutbound()
{
$p = $this->getPacConf();
$p['process_outbound'] = !$p['process_outbound'];
$p = $this->setPacConf($p);
$this->xtlsprocess();
}
public function xtlsapp($page = 0)
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> package list';
@@ -3596,6 +3621,32 @@ DNS-over-HTTPS with IP:
);
}
public function xtlsprocess($page = 0)
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> process list';
$data = $this->listPac('processlist', $page, 'xtlsprocess');
$p = $this->getPacConf();
$data[] = [
[
'text' => 'set to ' . ($p['process_outbound'] ? 'proxy' : 'direct'),
'callback_data' => "/processOutbound",
],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/routes",
],
];
$this->update(
$this->input['chat'],
$this->input['message_id'],
implode("\n", $text ?: ['...']),
$data ?: false,
);
}
public function xtlsrulesset($page = 0)
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> rulesset list';
@@ -3633,7 +3684,7 @@ DNS-over-HTTPS with IP:
foreach ($domains as $k => $v) {
$data[] = [
[
'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . idn_to_utf8($k),
'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . (in_array($type, ['rulessetlist', 'packagelist', 'processlist']) ? $k : idn_to_utf8($k)),
'callback_data' => "/change$type " . ($i + $page * $this->limit),
],
[
@@ -4496,6 +4547,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('warp'),
'callback_data' => "/xtlswarp",
]],
[[
'text' => $this->i18n('process'),
'callback_data' => "/xtlsprocess",
]],
[[
'text' => $this->i18n('package'),
'callback_data' => "/xtlsapp",
@@ -4981,8 +5036,6 @@ DNS-over-HTTPS with IP:
}
$c['route']['rules'] = array_values($c['route']['rules']);
$c['route'] = $this->addRuleSet($c['route']);
$c['route'] = $this->addPackageRule($c['route']);
$c['route'] = $this->addProcessRule($c['route']);
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
$c['route'] = $this->clearEmptyRules($c['route']);
break;
@@ -5003,42 +5056,6 @@ DNS-over-HTTPS with IP:
return $route;
}
public function addPackageRule($route)
{
foreach ($route['rules'] as $k => $v) {
if (array_key_exists('package_name', $v)) {
$p = $this->getPacConf();
if (!empty($t = array_filter($p['packagelist'] ?: []))) {
$route['rules'][$k] = [
'package_name' => array_keys($t),
'outbound' => $p['app_outbound'] ? 'direct' : 'proxy',
];
} else {
unset($route['rules'][$k]);
}
}
}
return $route;
}
public function addProcessRule($route)
{
foreach ($route['rules'] as $k => $v) {
if (array_key_exists('process_name', $v)) {
$p = $this->getPacConf();
if (!empty($t = array_filter($p['processlist'] ?: []))) {
$route['rules'][$k] = [
'process_name' => array_keys($t),
'outbound' => $p['process_outbound'] ? 'direct' : 'proxy',
];
} else {
unset($route['rules'][$k]);
}
}
}
return $route;
}
public function addRuleSet($route)
{
foreach ($route['rules'] as $k => $v) {
@@ -5721,13 +5738,44 @@ DNS-over-HTTPS with IP:
$this->logs();
}
public function selfUpdate()
{
require __DIR__ . '/config.php';
if (!empty($c['admin'])) {
$ip = getenv('IP');
$rm = explode(':', trim(file_get_contents('/update/reload_message')));
$m = file_get_contents('/update/message');
foreach ($c['admin'] as $k => $v) {
$r = $this->send($v, "start $ip");
$this->input['chat'] = $v;
$this->input['message_id'] = $r['result']['message_id'];
if (file_exists($this->update)) {
if (!empty($m)) {
$this->send($v, "<pre>$m</pre>", $v == $rm[0] ? $rm[1] : 0);
}
$r = $this->send($v, "import settings");
$this->input['chat'] = $v;
$this->input['message_id'] = $r['result']['message_id'];
$this->input['callback_id'] = $r['result']['message_id'];
if (empty($flag)) {
$this->importFile($this->update);
unlink($this->update);
$flag = true;
}
}
}
}
file_put_contents('/update/message', '');
file_put_contents('/update/reload_message', '');
}
public function backup()
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter like start / period",
"@{$this->input['username']} enter like: start / period",
$this->input['message_id'],
reply: 'enter like now / 12:00',
reply: 'enter like: now / 12 hours',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
+1 -2
View File
@@ -7,5 +7,4 @@ require __DIR__ . '/bot.php';
require __DIR__ . '/config.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
$bot->cron();
(new Bot($c['key'], $i))->cron();
+5 -4
View File
@@ -10,8 +10,9 @@ if ($c['debug']) {
}
$bot = new Bot($c['key'], $i);
$bot->adguardProtect();
$bot->adguardCheckPswd();
$bot->setcommands();
$bot->syncPortClients();
$bot->setwebhook();
$bot->selfUpdate();
$bot->adguardCheckPswd();
$bot->adguardProtect();
$bot->syncPortClients();
$bot->setcommands();
-26
View File
@@ -12,32 +12,6 @@ if ($c['debug']) {
$bot = new Bot($c['key'], $i);
if (!empty($c['admin'])) {
$ip = getenv('IP');
$rm = explode(':', trim(file_get_contents('/update/reload_message')));
$m = file_get_contents('/update/message');
foreach ($c['admin'] as $k => $v) {
$r = $bot->send($v, "start $ip");
$bot->input['chat'] = $v;
$bot->input['message_id'] = $r['result']['message_id'];
if (file_exists($bot->update)) {
if (!empty($m)) {
$bot->send($v, "<pre>$m</pre>", $v == $rm[0] ? $rm[1] : 0);
}
$r = $bot->send($v, "import settings");
$bot->input['chat'] = $v;
$bot->input['message_id'] = $r['result']['message_id'];
$bot->input['callback_id'] = $r['result']['message_id'];
if (empty($flag)) {
$bot->importFile($bot->update);
unlink($bot->update);
$flag = true;
}
}
}
}
file_put_contents('/update/message', '');
file_put_contents('/update/reload_message', '');
$bot->restartTG();
$bot->sslip();
$bot->cleanDocker();
+1 -99
View File
@@ -1,99 +1 @@
{
"zapret": false,
"excludelist": {
"(?:v|w)ul(?:c|k)an": true,
"^\\d": true,
"^a\\w-": true,
"^admiral": true,
"^avtomaty": true,
"^azart": true,
"^azimob": true,
"^baltplay": true,
"a(?:s|z)ino": true,
"adrenalin": true,
"alco": true,
"bet": true,
"prostitut": true,
"zenit": true,
"zerkalo": true,
"777": true
},
"includelist": {},
"reverselist": {},
"subzoneslist": {
"3dn": false,
"3nx": true,
"akadns": true,
"appspot": true,
"azurewebsites": true,
"beget": true,
"berlogovo": true,
"biz": true,
"brightcove": true,
"cc": true,
"cloudfront": true,
"co": true,
"com": true,
"cu": true,
"ddns": true,
"deviantart": true,
"dn": true,
"dp": true,
"dyndns": true,
"edgecastcdn": true,
"edu": true,
"eu": true,
"fastly": true,
"force": true,
"github": true,
"google": true,
"googleusercontent": true,
"gov": true,
"herokuapp": true,
"hldns": true,
"ho": true,
"hopto": true,
"hwcdn": true,
"i": true,
"iboards": true,
"in": true,
"info": true,
"int": true,
"itch": true,
"keenetic": true,
"kiev": true,
"kirov": true,
"linode": true,
"livejournal": true,
"maryno": true,
"mil": true,
"msk": true,
"my1": true,
"mybb2": true,
"ne": true,
"net": true,
"netdna-ssl": true,
"nnov": true,
"notion": true,
"nov": true,
"od": true,
"org": true,
"pp": true,
"pximg": true,
"pythonanywhere": true,
"ru": true,
"scaleway": true,
"sl": true,
"sl-reverse": true,
"spb": true,
"tilda": true,
"trafficmanager": true,
"tut": true,
"u-stream": true,
"ucoz": true,
"v": true,
"vercel": true,
"wix": true,
"wixmp": true
}
}
{}
+3 -2
View File
@@ -33,7 +33,8 @@ services:
- ./config/sshd_config:/etc/ssh/sshd_config
- ./logs/:/logs/
ports:
- 443:443
- 443:443/tcp
- 443:443/udp
hostname: upstream
container_name: upstream-${VER}
depends_on:
@@ -127,7 +128,7 @@ services:
required: false
hostname: php
container_name: php-${VER}
restart: unless-stopped
# restart: unless-stopped
stop_grace_period: 1s
command: ["/bin/sh", "/start_php.sh"]
working_dir: /app
+9 -5
View File
@@ -2,8 +2,12 @@ rm /ssh/key*
ssh-keygen -m PEM -t rsa -f /ssh/key -N ''
openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -keyout /certs/self_private -out /certs/self_public -subj "/C=NN/ST=N/L=N/O=N/CN=$IP"
php init.php
php cron.php &
unitd --log /logs/unit_error
curl -X PUT --data-binary @/config/unit.json --unix-socket /var/run/control.unit.sock http://localhost/config
pkill unitd
unitd --no-daemon --control 0.0.0.0:8080 --log /logs/unit_error
if [[ -f "/start" && -f "/ssh/key.pub" && -s "/ssh/key.pub" ]]; then
php cron.php &
unitd --log /logs/unit_error
curl -X PUT --data-binary @/config/unit.json --unix-socket /var/run/control.unit.sock http://localhost/config
pkill unitd
unitd --no-daemon --control 0.0.0.0:8080 --log /logs/unit_error
else
exit 1;
fi
+7
View File
@@ -1,3 +1,10 @@
21.10.2024 v1.71
- фикс установки nip.io при первом запуске
- фикс инициализации вебпанели adguardHome при первом запуске
14.10.2024 v1.70
- xray route: учет регистра в process_name, package_name
14.10.2024 v1.69
- xray route: добавлен список process_name
14.10.2024 v1.68
- singbox template: package_name -> ruleset
13.10.2024 v1.67