diff options
Diffstat (limited to 'modules-available/webinterface/page.inc.php')
| -rw-r--r-- | modules-available/webinterface/page.inc.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/modules-available/webinterface/page.inc.php b/modules-available/webinterface/page.inc.php index b721da27..1b082000 100644 --- a/modules-available/webinterface/page.inc.php +++ b/modules-available/webinterface/page.inc.php @@ -29,6 +29,10 @@ class Page_WebInterface extends Page User::assertPermission("edit.https"); $this->handleApiKey(substr($action, 14)); break; + case 'trusted-proxies': + User::assertPermission("edit.proxies"); + $this->actionConfigureProxies(); + break; default: if ($action !== null) { Message::addWarning('main.invalid-action', $action); @@ -87,6 +91,24 @@ class Page_WebInterface extends Page Util::redirect('?do=WebInterface'); } + private function actionConfigureProxies(): void + { + $trustedProxies = Request::post('trusted-proxies-list', '', 'string'); + $trustedProxies = preg_split('/[\r\n]+/', $trustedProxies, 0, PREG_SPLIT_NO_EMPTY); + $cleaned = []; + foreach ($trustedProxies as $line) { + $line = preg_split("~(#|//|'|;)~", $line, 2, PREG_SPLIT_NO_EMPTY); + $ip = trim($line[0]); + $ipNormal = IpUtil::normalizeIp($ip); + if ($ipNormal !== null) { + $cleaned[$ip] = $line[1] ?? ''; + } else { + Message::addWarning('invalid-proxy-ip', $ip); + } + } + WebInterface::setProxiesTrusted($cleaned); + } + protected function doRender() { Render::addTemplate("heading"); @@ -192,6 +214,20 @@ class Page_WebInterface extends Page Permission::addGlobalTags($data['perms'], null, ['edit.password']); Render::addTemplate('passwords', $data); // + // Trusted Proxies + // + $list = ''; + foreach (WebInterface::getProxiesTrusted() as $ip => $comment) { + $list .= $ip; + if (!empty($comment)) { + $list .= " # $comment"; + } + $list .= "\r\n"; + } + $data = ['trustedProxiesList' => $list]; + Permission::addGlobalTags($data['perms'], null, ['edit.trusted-proxies']); + Render::addTemplate('trusted-proxies', $data); + // // Colors/Prefix // $data = array('prefix' => Property::get('page-title-prefix')); |
