feat: new output formats Dnsmasq nfset and ipset, ClashX, Keenetic KVAS

This commit is contained in:
Rekryt
2024-09-04 16:42:20 +03:00
parent 1fdc844f45
commit ef457a1fda
9 changed files with 130 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace OpenCCK\App\Controller;
/**
* Format Keenetic (KVAS)
*/
class KvasController extends TextController {
const DELIMITER = "\n";
/**
* @param array $response
* @return string
*/
protected function render(array $response): string {
$data = $this->request->getQueryParameter('data') ?? '';
$handlers = [
'domains' => fn(string $row) => '*' . $row,
'ip4' => fn(string $row) => $row . '/32',
'ip6' => fn(string $row) => $row . '/128',
'cidr4' => fn(string $row) => $row,
'cidr6' => fn(string $row) => $row,
];
return implode($this::DELIMITER, array_map($handlers[$data] ?? fn(string $row) => $row, $response));
}
}