<?php declare(strict_types = 0);
class CControllerProxyCreate extends CController {
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
protected function checkInput(): bool {
'name' => 'required|not_empty|db proxy.name',
'proxy_groupid' => 'db proxy.proxy_groupid',
'local_address' => 'db proxy.local_address',
'local_port' => 'db proxy.local_port',
'operating_mode' => 'required|db proxy.operating_mode|in '.implode(',', [PROXY_OPERATING_MODE_ACTIVE, PROXY_OPERATING_MODE_PASSIVE]),
'address' => 'db proxy.address',
'port' => 'db proxy.port',
'allowed_addresses' => 'db proxy.allowed_addresses',
'description' => 'db proxy.description',
'tls_connect' => 'db proxy.tls_connect|in '.implode(',', [HOST_ENCRYPTION_NONE, HOST_ENCRYPTION_PSK, HOST_ENCRYPTION_CERTIFICATE]),
'tls_accept_none' => 'in 1',
'tls_accept_psk' => 'in 1',
'tls_accept_certificate' => 'in 1',
'tls_psk_identity' => 'db proxy.tls_psk_identity',
'tls_psk' => 'db proxy.tls_psk',
'tls_issuer' => 'db proxy.tls_issuer',
'tls_subject' => 'db proxy.tls_subject',
'clone_proxyid' => 'db proxy.proxyid',
'clone_psk' => 'required|bool',
'custom_timeouts' => 'db proxy.custom_timeouts|in '.implode(',', [ZBX_PROXY_CUSTOM_TIMEOUTS_DISABLED, ZBX_PROXY_CUSTOM_TIMEOUTS_ENABLED]),
'timeout_zabbix_agent' => 'db proxy.timeout_zabbix_agent',
'timeout_simple_check' => 'db proxy.timeout_simple_check',
'timeout_snmp_agent' => 'db proxy.timeout_snmp_agent',
'timeout_external_check' => 'db proxy.timeout_external_check',
'timeout_db_monitor' => 'db proxy.timeout_db_monitor',
'timeout_http_agent' => 'db proxy.timeout_http_agent',
'timeout_ssh_agent' => 'db proxy.timeout_ssh_agent',
'timeout_telnet_agent' => 'db proxy.timeout_telnet_agent',
'timeout_script' => 'db proxy.timeout_script',
'timeout_browser' => 'db proxy.timeout_browser'
$ret = $this->validateInput($fields);
if ($this->getInput('proxy_groupid', 0) != 0) {
if ($this->getInput('local_address', '') === '') {
info(_s('Incorrect value for field "%1$s": %2$s.',
_s('%1$s: %2$s', _('Address for active agents'), _('Address')), _('cannot be empty')
if ($this->getInput('local_port', '') === '') {
info(_s('Incorrect value for field "%1$s": %2$s.',
_s('%1$s: %2$s', _('Address for active agents'), _('Port')), _('cannot be empty')
switch ($this->getInput('operating_mode')) {
case PROXY_OPERATING_MODE_ACTIVE:
if (!$this->hasInput('tls_accept_none') && !$this->hasInput('tls_accept_psk')
&& !$this->hasInput('tls_accept_certificate')) {
info(_s('Incorrect value for field "%1$s": %2$s.', _('Connections from proxy'),