Skip to content

Commit

Permalink
Increase the default timeout to 3 seconds and add a command line swit…
Browse files Browse the repository at this point in the history
…ch to control that
  • Loading branch information
Dadoum committed Aug 12, 2023
1 parent 61a0e82 commit 3ef10ba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -285,8 +292,6 @@ class AnisetteService {
}
}

enum timeout = dur!"msecs"(1250);

@method(HTTPMethod.GET)
@path("/v3/provisioning_session")
void provisionSession(scope WebSocket socket) {
Expand Down

0 comments on commit 3ef10ba

Please sign in to comment.