feat: template for MikrotikController

https://github.com/rekryt/iplist/issues/88
This commit is contained in:
Rekryt
2025-12-25 12:36:36 +03:00
parent e08e143a71
commit 1f001233ad
3 changed files with 24 additions and 1 deletions

View File

@@ -279,6 +279,12 @@ iplist_v4_cidr
- In IP -> Firewall -> Address Lists, a new lists should appear (in this example, named `youtube`)
- ![4](https://github.com/user-attachments/assets/bb9ada57-60eb-40df-a031-7a0bc05bc4cb)
Using the `template` GET parameter for the `mikrotik` format, you can specify a template for the list name:
```
https://iplist.opencck.org/?format=mikrotik&data=cidr4&append=timeout%3D1d&template={group}_{data}
```
By default the template has the value: `{group}_{data}`
## Setting up HomeProxy (sing-box)
Enable "Routing mode" in "Only proxy mainland China":
![1](https://github.com/user-attachments/assets/b0295368-b160-430d-8802-9b65db4e096f)

View File

@@ -287,6 +287,12 @@ iplist_v4_cidr
- А в разделе IP -> Firewall -> Address Lists должны появиться новые списоки (в примере с именем `youtube`)
- ![4](https://github.com/user-attachments/assets/bb9ada57-60eb-40df-a031-7a0bc05bc4cb)
Через GET-параметр `template` для формата `mikrotik` можно указывать шаблон для имени списка:
```
https://iplist.opencck.org/?format=mikrotik&data=cidr4&append=timeout%3D1d&template={group}_{data}
```
По умолчанию шаблон имеет значение: `{group}_{data}`
## Настройка HomeProxy (sing-box)
Включите "Routing mode" в "Only proxy mainland China":
![1](https://github.com/user-attachments/assets/b0295368-b160-430d-8802-9b65db4e096f)

View File

@@ -15,6 +15,7 @@ class MikrotikController extends AbstractIPListController {
$sites = SiteFactory::normalizeArray($this->request->getQueryParameters()['site'] ?? []);
$data = $this->request->getQueryParameter('data') ?? '';
$append = $this->request->getQueryParameter('append') ?? '';
$template = $this->request->getQueryParameter('template') ?? '{group}_{data}';
if ($data == '') {
return "# Error: The 'data' GET parameter is required in the URL to access this page";
}
@@ -28,7 +29,17 @@ class MikrotikController extends AbstractIPListController {
continue;
}
$listName = $groupName . '_' . $data;
foreach (
[
'group' => $groupName,
'data' => $data,
]
as $key => $value
) {
$template = str_replace('{' . $key . '}', $value, $template);
}
$listName = $template;
$response = array_merge($response, [
'/ip firewall address-list remove [find list="' . $listName . '"];',
':delay 5s',