Set custom user agent

This commit is contained in:
Mateusz Małek 2020-05-18 17:02:29 +02:00
parent c0e0b260d5
commit edc263f703
No known key found for this signature in database
GPG Key ID: A4E41153E7FE6B4D
5 changed files with 17 additions and 4 deletions

View File

@ -452,8 +452,8 @@ namespace {
}
if ($add_agent) {
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; phpservermon/' .
PSM_VERSION . '; +https://github.com/phpservermon/phpservermon)');
curl_setopt($ch, CURLOPT_USERAGENT, psm_get_conf('user_agent', 'Mozilla/5.0 (compatible; phpservermon/' .
PSM_VERSION . '; +https://github.com/phpservermon/phpservermon)'));
}
$result['exec'] = curl_exec($ch);

View File

@ -414,6 +414,8 @@ $sm_lang = array(
'log_retention_period_description' => 'Number of days to keep logs of notifications and archives of server
uptime. Enter 0 to disable log cleanup.',
'log_retention_days' => 'days',
'user_agent' => 'User Agent',
'user_agent_key_note' => 'Custom user agent used by monitor within communication with external services.',
),
'notifications' => array(
'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%',

View File

@ -272,6 +272,8 @@ $sm_lang = array(
archiwizować uptime serwera. Wpisz 0 aby wyłączyć czyszczenie
logów.',
'log_retention_days' => 'dni',
'user_agent' => 'User Agent',
'user_agent_key_note' => 'Nazwa używana przez monitoring do identyfikacji ze sprawdzaną usługą.',
),
'notifications' => array(
'off_sms' => 'Serwer \'%LABEL%\' przestał odpowiadać: ip=%IP%, port=%PORT%. Błąd=%ERROR%',

View File

@ -77,7 +77,8 @@ class ConfigController extends AbstractController
'jabber_host',
'jabber_port',
'jabber_username',
'jabber_domain'
'jabber_domain',
'user_agent',
);
/**
@ -191,6 +192,11 @@ class ConfigController extends AbstractController
foreach ($this->fields as $input_key) {
$tpl_data[$input_key] = (isset($config[$input_key])) ? $config[$input_key] : '';
}
$tpl_data['user_agent'] = empty($tpl_data['user_agent']) ?
'Mozilla/5.0 (compatible; phpservermon/' .
PSM_VERSION . '; +https://github.com/phpservermon/phpservermon)' : $tpl_data['user_agent'];
// encrypted fields
foreach ($this->encryptedFields as $encryptedField) {
$tpl_data[$encryptedField] = '';
@ -516,7 +522,8 @@ class ConfigController extends AbstractController
'label_log_retention_days' => psm_get_lang('config', 'log_retention_days'),
'label_days' => psm_get_lang('config', 'log_retention_days'),
'label_leave_blank' => psm_get_lang('users', 'password_leave_blank'),
'label_user_agent' => psm_get_lang('config', 'user_agent'),
'label_user_agent_key_note' => psm_get_lang('config', 'user_agent_key_note'),
);
}
}

View File

@ -48,6 +48,8 @@
<!-- Password encryption key -->
<!-- TODO how does the encryption function works currently? -->
{{ macro.input_field("text", "password_encrypt_key", null, "password_encrypt_key", label_password_encrypt_key, password_encrypt_key, "cab03a766...", "40", "password_encrypt_key_help", label_password_encrypt_key_note) }}
<!-- Custom user agent -->
{{ macro.input_field("text", "user_agent", null, "user_agent", label_user_agent, user_agent, "Mozilla/5.0...", "255", "user_agent_key_help", label_user_agent_key_note) }}
</fieldset>
<!-- Notification settings -->
<fieldset>