Increase the default timeout to 3 seconds and add a command line switch to control that

This commit is contained in:
Dadoum 2023-08-12 04:11:52 +02:00
parent 61a0e828b0
commit 3ef10ba2b8

View File

@ -40,6 +40,8 @@ enum dsId = -2;
__gshared ADI v1Adi; __gshared ADI v1Adi;
__gshared Device v1Device; __gshared Device v1Device;
__gshared Duration timeout;
int main(string[] args) { int main(string[] args) {
debug { debug {
configureLoggingProvider(new shared DefaultProvider(true, Levels.DEBUG)); configureLoggingProvider(new shared DefaultProvider(true, Levels.DEBUG));
@ -57,15 +59,20 @@ int main(string[] args) {
string certificateChainPath = null; string certificateChainPath = null;
string privateKeyPath = null; string privateKeyPath = null;
long timeoutMsecs = 3000;
auto helpInformation = getopt( auto helpInformation = getopt(
args, args,
"n|host", format!"The hostname to bind to (default: %s)"(hostname), &hostname, "n|host", format!"The hostname to bind to (default: %s)"(hostname), &hostname,
"p|port", format!"The port to bind to (default: %s)"(port), &port, "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, "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, "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, "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)) { 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)."); 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; return 1;
@ -285,8 +292,6 @@ class AnisetteService {
} }
} }
enum timeout = dur!"msecs"(1250);
@method(HTTPMethod.GET) @method(HTTPMethod.GET)
@path("/v3/provisioning_session") @path("/v3/provisioning_session")
void provisionSession(scope WebSocket socket) { void provisionSession(scope WebSocket socket) {