Compare commits

..

7 Commits

Author SHA1 Message Date
mercury 855f516936 update version 2024-12-06 23:39:12 +04:00
mercury e1c13480d1 mihomo: fix empty rules 2024-12-06 23:36:43 +04:00
mercury bd5e10fa23 naming: clash -> mihomo 2024-12-06 23:12:22 +04:00
mercury 3627b389b4 mihomo: added yaml support 2024-12-06 22:26:00 +04:00
mercury f3f9cb5348 fix ruleset for mihomo 2024-12-06 22:11:12 +04:00
mercury 1527b9f856 added rule-set for clash 2024-12-04 00:08:32 +04:00
mercury f896b307ea removed check when adding a subnet to openconnect 2024-11-28 20:11:05 +04:00
5 changed files with 72 additions and 21 deletions
+57 -14
View File
@@ -2580,9 +2580,9 @@ DNS-over-HTTPS with IP:
case 'rulessetlist':
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} [direct | block | proxy]:time:URL",
"@{$this->input['username']} outbound[:behavior]:time:URL",
$this->input['message_id'],
reply: '[direct | block | proxy]:time:URL',
reply: 'outbound[:behavior]:time:URL',
);
break;
@@ -3130,9 +3130,6 @@ DNS-over-HTTPS with IP:
public function subnetSave($text, $wgpage, $page, $openconnect)
{
if (!preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$~', $text)) {
return $this->send($this->input['chat'], "wrong format: $text", $this->input['message_id']);
}
$c = $this->getPacConf();
$subnets = explode(',', $text);
if ($subnets) {
@@ -5331,7 +5328,7 @@ DNS-over-HTTPS with IP:
$pac = $this->getPacConf();
$domain = $this->getDomain();
$hash = substr(md5($this->key), 0, 8);
$text[] = "Menu -> " . $this->i18n('xray') . " -> $type templates";
$text[] = "Menu -> " . $this->i18n('xray') . " -> " . $this->i18n($type) . " templates";
$text[] = <<<TEXT
<code>~outbound~</code>
<code>"~pac~"</code>
@@ -5494,7 +5491,7 @@ DNS-over-HTTPS with IP:
'callback_data' => "/templates sing",
],
[
'text' => $this->i18n('clash templates'),
'text' => $this->i18n('mihomo templates'),
'callback_data' => "/templates clash",
],
];
@@ -5788,7 +5785,7 @@ DNS-over-HTTPS with IP:
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=st&s={$c['id']}#{$c['email']}'>import://streisand</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=h&s={$c['id']}#{$c['email']}'>import://hiddify</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=k&s={$c['id']}#{$c['email']}'>import://karing</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=c&s={$c['id']}#{$c['email']}'>import://clash</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=c&s={$c['id']}#{$c['email']}'>import://mihomo</a>";
$si = "$scheme://{$domain}/pac/" . base64_encode(serialize([
'h' => $hash,
@@ -5808,19 +5805,23 @@ DNS-over-HTTPS with IP:
$text[] = "\nxray config: <pre><code>$xr</code></pre>";
$text[] = "sing-box config: <pre><code>$si</code></pre>";
$text[] = "clash config: <pre><code>$cl</code></pre>";
$text[] = "mihomo config: <pre><code>$cl</code></pre>";
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac?h=$hash&t=si&r=w&s={$c['id']}'>windows service</a>";
$data[] = [
[
'text' => 'xray',
'text' => $this->i18n('v2ray'),
'web_app' => ['url' => "https://{$domain}/pac?h=$hash&t=s&s={$c['id']}"],
],
[
'text' => 'sing-box',
'text' => $this->i18n('singbox'),
'web_app' => ['url' => "https://{$domain}/pac?h=$hash&t=si&s={$c['id']}"],
],
[
'text' => $this->i18n('mihomo'),
'web_app' => ['url' => "https://{$domain}/pac?h=$hash&t=cl&s={$c['id']}"],
],
];
$data[] = [
[
@@ -5845,7 +5846,7 @@ DNS-over-HTTPS with IP:
'callback_data' => "/templateUser sing $i",
],
[
'text' => $this->i18n('clash') . ": $clashtemplate",
'text' => $this->i18n('mihomo') . ": $clashtemplate",
'callback_data' => "/templateUser clash $i",
],
];
@@ -6137,8 +6138,12 @@ DNS-over-HTTPS with IP:
}
break;
case 'cl':
$c = $this->clashRuleSet($c);
if (!empty($c['rules'])) {
$c['rules'] = $this->clashRules($c['rules']);
if (count($c['rules']) == 1) {
unset($c['rules']);
}
}
break;
}
@@ -6153,6 +6158,44 @@ DNS-over-HTTPS with IP:
echo json_encode($c);
}
public function clashRuleSet($c)
{
$p = $this->getPacConf();
if (!empty($p['rulessetlist']) && $c['add-rule-providers']) {
foreach ($p['rulessetlist'] as $k => $v) {
if (!empty($v)) {
[$type, $behavior, $time, $url] = explode(':', $k, 4);
if (preg_match('~\.(?:mrs|yaml|yml)$~', $url)) {
$c['rule-providers'][$url] = [
'type' => 'http',
'url' => $url,
'interval' => (int) $time,
'behavior' => $behavior,
];
switch ($type) {
case 'reject':
array_unshift($c['rules'], [
'RULE-SET', $url, strtoupper($type)
]);
break;
default:
array_splice($c['rules'], count($c['rules']) - 1, 0, [[
'RULE-SET', $url, strtoupper($type)
]]);
break;
}
}
}
}
}
unset($c['add-rule-providers']);
if (empty($c['rule-providers'])) {
unset($c['rule-providers']);
}
return $c;
}
public function clashRules($rules)
{
foreach ($rules as $v) {
@@ -6163,7 +6206,7 @@ DNS-over-HTTPS with IP:
}
}
} else {
$tmp[] = "{$v['type']}, {$v['action']}";
$tmp[] = implode(', ', $v);
}
}
return $tmp;
@@ -6187,7 +6230,7 @@ DNS-over-HTTPS with IP:
foreach ($p['rulessetlist'] as $k => $v) {
if (!empty($v)) {
[$type, $time, $url] = explode(':', $k, 3);
if (!empty($route['rules'][$t[$type]])) {
if (preg_match('~\.srs$~', $url) && !empty($route['rules'][$t[$type]])) {
$route['rule_set'][] = [
"tag" => $k,
"type" => "remote",
+6 -2
View File
@@ -262,8 +262,12 @@ $i = [
'ru' => 'очистить',
],
'xray' => [
'en' => 'Xray',
'ru' => 'Xray',
'en' => 'Vless',
'ru' => 'Vless',
],
'clash' => [
'en' => 'mihomo',
'ru' => 'mihomo',
],
'geodb' => [
'en' => 'GeoIp/GeoSite',
+2
View File
@@ -90,6 +90,8 @@
]
}
],
"add-rule-providers": true,
"rule-providers": {},
"rules": [
{
"type": "DOMAIN-SUFFIX",
+5 -5
View File
@@ -115,7 +115,7 @@
"createruleset": [
{
"name": "pac",
"interval": "15s",
"interval": "30s",
"rules": [
{
"domain_suffix": "~pac~"
@@ -130,7 +130,7 @@
"createruleset": [
{
"name": "package",
"interval": "15s",
"interval": "30s",
"rules": [
{
"package_name": "~package~"
@@ -145,7 +145,7 @@
"createruleset": [
{
"name": "process",
"interval": "15s",
"interval": "30s",
"rules": [
{
"process_name": "~process~"
@@ -160,7 +160,7 @@
"createruleset": [
{
"name": "block",
"interval": "15s",
"interval": "30s",
"rules": [
{
"domain_suffix": "~block~"
@@ -175,7 +175,7 @@
"createruleset": [
{
"name": "warp",
"interval": "15s",
"interval": "30s",
"rules": [
{
"domain_suffix": "~warp~"
+2
View File
@@ -1,3 +1,5 @@
06.12.2024 v1.110
- ruleset для mihomo
28.11.2024 v1.109
- фикс автоскана
- добавление clash-шаблонов