diff options
author | Simon Rettberg | 2020-11-05 10:51:20 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-11-05 10:51:20 +0100 |
commit | fe07a61d544007e2cc7e746d354467a9e5885df7 (patch) | |
tree | 64f8bd631993bd59b9488cda643d6d639c22c73c /modules-available/dnbd3 | |
parent | [locationinfo] Allow seconds in prettytime mode, change eco mode text (diff) | |
download | slx-admin-fe07a61d544007e2cc7e746d354467a9e5885df7.tar.gz slx-admin-fe07a61d544007e2cc7e746d354467a9e5885df7.tar.xz slx-admin-fe07a61d544007e2cc7e746d354467a9e5885df7.zip |
[dnbd3] Allow overriding certain server.conf values for proxy
As requested in issue #3328 you can now override the default values of
certain settings. It's kept simple, labeled "advanced config" with a
little disclaimer, as you can easily enter stupid values that will
render the dnbd3-proxy useless.
Diffstat (limited to 'modules-available/dnbd3')
6 files changed, 73 insertions, 21 deletions
diff --git a/modules-available/dnbd3/inc/dnbd3util.inc.php b/modules-available/dnbd3/inc/dnbd3util.inc.php index fdbf9190..8e355370 100644 --- a/modules-available/dnbd3/inc/dnbd3util.inc.php +++ b/modules-available/dnbd3/inc/dnbd3util.inc.php @@ -190,6 +190,14 @@ class Dnbd3Util { // Background replication ConfigHolder::add('SLX_DNBD3_BGR', '1'); } + // Extra config options + if (!empty($modeData['advancedSettings'])) { + $str = ''; + foreach ($modeData['advancedSettings'] as $k => $v) { + $str .= str_replace(["\n", "\r", "\t", ' '], '', $k . '=' . $v) . ' '; + } + ConfigHolder::add('SLX_DNBD3_EXTRA', $str); + } ConfigHolder::add('SLX_ADDONS', '', 1000); ConfigHolder::add('SLX_SHUTDOWN_TIMEOUT', '', 1000); ConfigHolder::add('SLX_SHUTDOWN_SCHEDULE', '', 1000); diff --git a/modules-available/dnbd3/lang/de/template-tags.json b/modules-available/dnbd3/lang/de/template-tags.json index f7323530..532d1c32 100644 --- a/modules-available/dnbd3/lang/de/template-tags.json +++ b/modules-available/dnbd3/lang/de/template-tags.json @@ -1,5 +1,7 @@ { "lang_addServer": "Server hinzuf\u00fcgen", + "lang_advancedConfigDesc": "Hier handelt es sich um Optionen, die normalerweise keiner weiteren Anpassung bed\u00fcrfen, im Einzelfall jedoch die Performance verbessern k\u00f6nnen, bzw. bessere Anpassung an lokale Gegebenheiten erm\u00f6glichen. Unpassende Werte k\u00f6nnen einen Proxy-Server jedoch effektiv unbrauchbar machen. \u00c4nderungen dieser Werte erfordern ebenfalls einen Neustart des Proxies.", + "lang_advancedProxyConfig": "Erweiterte Konfiguration", "lang_allowNfsFallback": "NFS-Fallback aktivieren", "lang_allowedSubnets": "Zum Zugriff freigegebene Subnets", "lang_altservers": "Uplinks", diff --git a/modules-available/dnbd3/lang/en/template-tags.json b/modules-available/dnbd3/lang/en/template-tags.json index a787cfdb..483991be 100644 --- a/modules-available/dnbd3/lang/en/template-tags.json +++ b/modules-available/dnbd3/lang/en/template-tags.json @@ -1,5 +1,7 @@ { "lang_addServer": "Add server", + "lang_advancedConfigDesc": "These are settings to further customize the proxy server. Usually the default values are fine, but under certain local circumstances it might make sense to change certain values to improve performance. Entering bogus values for some of these might effectively render the proxy unusable. Any change in these values requires a restart of the proxy.", + "lang_advancedProxyConfig": "Advanced configuration", "lang_allowNfsFallback": "NFS fallback", "lang_allowedSubnets": "Allowed subnets", "lang_altservers": "Uplinks", diff --git a/modules-available/dnbd3/page.inc.php b/modules-available/dnbd3/page.inc.php index 7721dac1..9ae7858e 100644 --- a/modules-available/dnbd3/page.inc.php +++ b/modules-available/dnbd3/page.inc.php @@ -66,8 +66,15 @@ class Page_Dnbd3 extends Page 'fixedip' => $overrideIp, )); } + $advancedSettings = []; + foreach (Request::post('extra', [], 'array') as $name => $value) { + $value = preg_replace('/[^0-9]/', '', $value); + if ($value === '') + continue; + $advancedSettings[$name] = $value; + } RunMode::setRunMode($server['machineuuid'], 'dnbd3', 'proxy', - json_encode(compact('bgr', 'firewall')), false); + json_encode(compact('bgr', 'firewall', 'advancedSettings')), false); } private function toggleUsage() @@ -533,6 +540,19 @@ class Page_Dnbd3 extends Page } $modeData = (array)json_decode($rm[$server['machineuuid']]['modedata'], true); $server += $modeData + Dnbd3Util::defaultRunmodeConfig(); + $extraSettings = $server['advancedSettings'] ?? []; + $server['advancedSettings'] = []; + foreach (['dnbd3.serverPenalty', + 'dnbd3.clientPenalty', + 'dnbd3.bgrMinClient', + 'dnbd3.bgrWindowSize', + 'dnbd3.autoFreeDiskSpaceDelay', + 'limits.maxClients', + 'limits.maxImages', + 'limits.maxPayload', + 'limits.maxReplicationSize'] as $item) { + $server['advancedSettings'][] = ['name' => $item, 'value' => $extraSettings[$item] ?? '']; + } echo Render::parse('fragment-server-settings', $server); } diff --git a/modules-available/dnbd3/templates/fragment-server-settings.html b/modules-available/dnbd3/templates/fragment-server-settings.html index be3e74e2..bd261bdd 100644 --- a/modules-available/dnbd3/templates/fragment-server-settings.html +++ b/modules-available/dnbd3/templates/fragment-server-settings.html @@ -1,22 +1,42 @@ <input type="hidden" name="server" value="{{serverid}}"> -<div class="checkbox"> - <input type="checkbox" name="bgr" id="bgr" {{#bgr}}checked{{/bgr}}> - <label for="bgr"><b>{{lang_backgroundReplication}}</b></label> -</div> -<i>{{lang_backgroundReplicationInfo}}</i> -<br><br> +<div class="row"> + <div class="col-md-6"> + <div class="checkbox"> + <input type="checkbox" name="bgr" id="bgr" {{#bgr}}checked{{/bgr}}> + <label for="bgr"><b>{{lang_backgroundReplication}}</b></label> + </div> + <i>{{lang_backgroundReplicationInfo}}</i> + <br><br> -<div class="checkbox"> - <input type="checkbox" name="firewall" id="firewall" {{#firewall}}checked{{/firewall}}> - <label for="firewall"><b>{{lang_firewalled}}</b></label> -</div> -<i>{{lang_firewallInfo}}</i> -<br><br> + <div class="checkbox"> + <input type="checkbox" name="firewall" id="firewall" {{#firewall}}checked{{/firewall}}> + <label for="firewall"><b>{{lang_firewalled}}</b></label> + </div> + <i>{{lang_firewallInfo}}</i> + <br><br> -<div> - <label for="fixedip">{{lang_overrideIp}}</label> - <input class="form-control" type="text" name="fixedip" id="fixedip" value="{{fixedip}}"> -</div> -<i>{{lang_overrideIpInfo}}</i> -<br> + <div> + <label for="fixedip">{{lang_overrideIp}}</label> + <input class="form-control" type="text" name="fixedip" id="fixedip" value="{{fixedip}}"> + </div> + <i>{{lang_overrideIpInfo}}</i> + <br><br> + + </div> + <div class="col-md-6"> + <h4>{{lang_advancedProxyConfig}}</h4> + <p><i>{{lang_advancedConfigDesc}}</i></p> + {{#advancedSettings}} + <div class="row"> + <div class="col-sm-8"> + <label for="ex-{{name}}">{{name}}</label> + </div> + <div class="col-sm-4"> + <input id="ex-{{name}}" class="form-control" type="text" pattern="[0-9]*" value="{{value}}" + name="extra[{{name}}]"> + </div> + </div> + {{/advancedSettings}} + </div> +</div>
\ No newline at end of file diff --git a/modules-available/dnbd3/templates/page-serverlist.html b/modules-available/dnbd3/templates/page-serverlist.html index c44eef0a..cdbd0789 100644 --- a/modules-available/dnbd3/templates/page-serverlist.html +++ b/modules-available/dnbd3/templates/page-serverlist.html @@ -223,8 +223,8 @@ </div> </div> -<div id="server-edit-modal" class="modal fade" role="dialog"> - <div class="modal-dialog"> +<div id="server-edit-modal" class="fade modal" role="dialog"> + <div class="modal-dialog modal-lg"> <div class="modal-content"> <form method="post" action="?do=dnbd3"> <input type="hidden" name="token" value="{{token}}"> |