mirror of
https://github.com/rekryt/iplist.git
synced 2025-10-13 08:59:34 +03:00
feat: portal groups
This commit is contained in:
@@ -18,6 +18,7 @@ final class Site {
|
||||
|
||||
/**
|
||||
* @param string $name Name of portal
|
||||
* @param string $group Group of portal
|
||||
* @param array $domains List of portal domains
|
||||
* @param array $dns List of DNS servers for updating IP addresses
|
||||
* @param int $timeout Time interval between domain IP address updates (seconds)
|
||||
@@ -30,6 +31,7 @@ final class Site {
|
||||
*/
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $group,
|
||||
public array $domains = [],
|
||||
public array $dns = [],
|
||||
public int $timeout = 1440 * 60,
|
||||
@@ -149,7 +151,7 @@ final class Site {
|
||||
*/
|
||||
private function saveConfig(): void {
|
||||
file_put_contents(
|
||||
PATH_ROOT . '/config/' . $this->name . '.json',
|
||||
PATH_ROOT . '/config/' . $this->group . '/' . $this->name . '.json',
|
||||
json_encode($this->getConfig(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
|
||||
);
|
||||
}
|
||||
|
@@ -21,11 +21,12 @@ class SiteFactory {
|
||||
|
||||
/**
|
||||
* @param string $name Name of portal
|
||||
* @param string $group Group of portal
|
||||
* @param object $config Configuration of portal
|
||||
* @return Site
|
||||
*
|
||||
*/
|
||||
static function create(string $name, object $config): Site {
|
||||
static function create(string $name, string $group, object $config): Site {
|
||||
$domains = $config->domains ?? [];
|
||||
$dns = $config->dns ?? [];
|
||||
$timeout = $config->timeout ?? 1440 * 60;
|
||||
@@ -75,10 +76,13 @@ class SiteFactory {
|
||||
$domains = self::normalize($domains);
|
||||
$ip4 = self::normalize($ip4, true);
|
||||
$ip6 = self::normalize($ip6, true);
|
||||
$cidr4 = self::normalize(IP4Helper::processCIDR($ip4, self::normalize($cidr4)), true);
|
||||
$cidr6 = self::normalize(IP6Helper::processCIDR($ip6, self::normalize($cidr6)), true);
|
||||
|
||||
return new Site($name, $domains, $dns, $timeout, $ip4, $ip6, $cidr4, $cidr6, $external);
|
||||
if ($timeout) {
|
||||
$cidr4 = self::normalize(IP4Helper::processCIDR($ip4, self::normalize($cidr4)), true);
|
||||
$cidr6 = self::normalize(IP6Helper::processCIDR($ip6, self::normalize($cidr6)), true);
|
||||
}
|
||||
|
||||
return new Site($name, $group, $domains, $dns, $timeout, $ip4, $ip6, $cidr4, $cidr6, $external);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user