From 3ef10ba2b84fd40f1f293c60c082ba70e5573a17 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sat, 12 Aug 2023 04:11:52 +0200 Subject: [PATCH] Increase the default timeout to 3 seconds and add a command line switch to control that --- source/app.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/app.d b/source/app.d index 87c2212..cd0f795 100644 --- a/source/app.d +++ b/source/app.d @@ -40,6 +40,8 @@ enum dsId = -2; __gshared ADI v1Adi; __gshared Device v1Device; +__gshared Duration timeout; + int main(string[] args) { debug { configureLoggingProvider(new shared DefaultProvider(true, Levels.DEBUG)); @@ -57,15 +59,20 @@ int main(string[] args) { string certificateChainPath = null; string privateKeyPath = null; + long timeoutMsecs = 3000; + auto helpInformation = getopt( args, "n|host", format!"The hostname to bind to (default: %s)"(hostname), &hostname, "p|port", format!"The port to bind to (default: %s)"(port), &port, "a|adi-path", format!"Where the provisioning information should be stored on the computer for anisette-v1 backwards compat (default: %s)"(configurationPath), &configurationPath, + "timeout", format!"Timeout duration for Anisette V3 in milliseconds (default: %d)"(timeoutMsecs), &timeoutMsecs, "private-key", "Path to the PEM-formatted private key file for HTTPS support (requires --cert-chain)", &certificateChainPath, "cert-chain", "Path to the PEM-formatted certificate chain file for HTTPS support (requires --private-key)", &privateKeyPath, ); + timeout = dur!"msecs"(timeoutMsecs); + if ((certificateChainPath && !privateKeyPath) || (!certificateChainPath && privateKeyPath)) { log.error("--certificate-chain and --private-key must both be specified for HTTPS support (they can be both be in the same file though)."); return 1; @@ -285,8 +292,6 @@ class AnisetteService { } } - enum timeout = dur!"msecs"(1250); - @method(HTTPMethod.GET) @path("/v3/provisioning_session") void provisionSession(scope WebSocket socket) {