Skip to content

Configuration

hrj edited this page Apr 6, 2022 · 4 revisions

As of version 2.x, the app can be configured via the config.json file in the data/ folder.

The structure of the file is:

{
  "randomSeed" : 20,
  "port" : 8888,
  "address" : "0.0.0.0",
  "captchaExpiryTimeLimit" : 5,                          // in minutes
  "bufferCount" : 10,
  "maxAttemptsRatio": 0.01,
  "threadDelay" : 2,
  "playgroundEnabled": true,
  "corsHeader": "",
  "captchas" : [ {
      "name" : "FilterChallenge",
      "allowedLevels" : [ "medium", "hard" ],
      "allowedMedia" : [ "image/png" ],
      "allowedInputType" : [ "text" ],
      "allowedSizes" : ["350x100"],
      "config" : { }
    }, ...
  ]
}     

Descriptions

randomSeed

Seed for random number generator, to ensure it is unique per instance, and yet retained between different runs. Not a very important option currently, and maybe removed in future.

port and address

These together define the port and address that the server listens on.

captchaExpiryTimeLimit

This defines the time in minutes to allow the user to enter a response. Any response received after this interval will be considered invalid.

bufferCount

Creating a CAPTCHA requires time. Generating CAPTCHAs on the fly when a API request is received would make the response time very slow. Hence, the server maintains a buffer of CAPTCHAs that can be served. This option defines the size of the buffer. Typical values for a small to medium site would be 1000. Should be increased for sites with high traffic.

The total bufferCount is divided by the number of combinations of CAPTCHA parameters, so that each combinations gets equal amount of buffer. For example, if the bufferCount is set to 1000, and there are 10 combinations of CAPTCHA parameters, then for each parameter combination, 100 CAPTCHAs will be stored in the buffer.

maxAttemptsRatio

CAPTCHAs can be reused to save computing resources. (When they are reused, the public id is unique, so that their reuse can't be noticed by the user based on the id alone). To disable reuse, simply set the value to 0. Otherwise, the value is interpreted as a fraction of bufferCount, and each CAPTCHA is served this many times. For example, if bufferCount is 1000 and maxAttemptRatio is 0.01, then each CAPTCHA will get served 10 times before it is retired.

threadDelay

The background thread sleeps and wakes up periodically to run house-keeping activities. This option defines the sleep time in seconds, between each background activity.

playgroundEnabled

If set to true, the demo site is served.

corsHeader

String that will be served in the API response's CORS header.