Allow setting of custom sizes for types hash (#219)

This commit is contained in:
Matt (IPv4) Cowley 2021-02-04 19:28:50 +00:00 committed by GitHub
parent 5f8931c231
commit 323cae4c50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 1 deletions

View file

@ -66,7 +66,8 @@ export default (domains, global) => {
config.http.push(['server_tokens', 'off']);
if (!global.logging.logNotFound.computed)
config.http.push(['log_not_found', 'off']);
config.http.push(['types_hash_max_size', 2048]);
config.http.push(['types_hash_max_size', global.nginx.typesHashMaxSize.computed]);
config.http.push(['types_hash_bucket_size', global.nginx.typesHashBucketSize.computed]);
config.http.push(['client_max_body_size', `${global.nginx.clientMaxBodySize.computed}M`]);
config.http.push(['# MIME', '']);

View file

@ -116,6 +116,38 @@ THE SOFTWARE.
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label">
<label class="label">types_hash_max_size</label>
</div>
<div class="field-body">
<div class="field">
<div :class="`control${typesHashMaxSizeChanged ? ' is-changed' : ''}`">
<VueSelect v-model="typesHashMaxSize"
:options="$props.data.typesHashMaxSize.options"
:clearable="false"
></VueSelect>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label">
<label class="label">types_hash_bucket_size</label>
</div>
<div class="field-body">
<div class="field">
<div :class="`control${typesHashBucketSizeChanged ? ' is-changed' : ''}`">
<VueSelect v-model="typesHashBucketSize"
:options="$props.data.typesHashBucketSize.options"
:clearable="false"
></VueSelect>
</div>
</div>
</div>
</div>
</div>
</template>
@ -150,6 +182,16 @@ THE SOFTWARE.
default: 16,
enabled: true,
},
typesHashMaxSize: {
default: 2048,
options: Array.from({ length: 8 }, (_, i) => Math.pow(2, i + 6)),
enabled: true,
},
typesHashBucketSize: {
default: 64,
options: Array.from({ length: 10 }, (_, i) => Math.pow(2, i + 4)),
enabled: true,
},
};
export default {
@ -195,6 +237,26 @@ THE SOFTWARE.
},
deep: true,
},
// Check hash max size selection is valid
'$props.data.typesHashMaxSize': {
handler(data) {
// This might cause recursion, but seems not to
if (data.enabled)
if (!data.options.includes(data.computed))
data.computed = data.default;
},
deep: true,
},
// Check hash bucket size selection is valid
'$props.data.typesHashBucketSize': {
handler(data) {
// This might cause recursion, but seems not to
if (data.enabled)
if (!data.options.includes(data.computed))
data.computed = data.default;
},
deep: true,
},
},
};
</script>