Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99bce7a988 | |||
| 446a5d7150 | |||
| 855f516936 | |||
| e1c13480d1 | |||
| bd5e10fa23 | |||
| 3627b389b4 | |||
| f3f9cb5348 | |||
| 1527b9f856 | |||
| f896b307ea |
+59
-14
@@ -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,46 @@ 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, $m)) {
|
||||
$c['rule-providers'][$url] = [
|
||||
'type' => 'http',
|
||||
'url' => $url,
|
||||
'interval' => (int) $time,
|
||||
'behavior' => $behavior,
|
||||
'format' => $m[1],
|
||||
];
|
||||
switch ($type) {
|
||||
case 'reject':
|
||||
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 +6208,7 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tmp[] = "{$v['type']}, {$v['action']}";
|
||||
$tmp[] = implode(', ', $v);
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
@@ -6187,7 +6232,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
@@ -262,8 +262,12 @@ $i = [
|
||||
'ru' => 'очистить',
|
||||
],
|
||||
'xray' => [
|
||||
'en' => 'Xray',
|
||||
'ru' => 'Xray',
|
||||
'en' => 'Vless',
|
||||
'ru' => 'Vless',
|
||||
],
|
||||
'clash' => [
|
||||
'en' => 'mihomo',
|
||||
'ru' => 'mihomo',
|
||||
],
|
||||
'geodb' => [
|
||||
'en' => 'GeoIp/GeoSite',
|
||||
|
||||
@@ -90,6 +90,8 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"add-rule-providers": true,
|
||||
"rule-providers": {},
|
||||
"rules": [
|
||||
{
|
||||
"type": "DOMAIN-SUFFIX",
|
||||
|
||||
+5
-5
@@ -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~"
|
||||
|
||||
Reference in New Issue
Block a user