Files
rotatyvote/rotatyvote/config.py
T

36 lines
1.4 KiB
Python

import os
HOST = os.environ.get("HOST", "0.0.0.0")
# SERVER_PORT is what pterodactyl/pelican hands to the container
PORT = int(os.environ.get("PORT") or os.environ.get("SERVER_PORT") or "8000")
# url encoded in the QR codes, eg https://vote.example.org
# when empty the projector's own origin is used
PUBLIC_URL = os.environ.get("PUBLIC_URL", "").rstrip("/")
TLS_CERT = os.environ.get("TLS_CERT", "")
TLS_KEY = os.environ.get("TLS_KEY", "")
DB_PATH = os.environ.get("DB_PATH", "rotatyvote.db")
# if set, creating a poll requires this password
CREATE_PASSWORD = os.environ.get("CREATE_PASSWORD", "")
# set to 1 when a TLS-terminating reverse proxy sits in front
BEHIND_PROXY = os.environ.get("BEHIND_PROXY", "") == "1"
SECURE_COOKIES = bool(TLS_CERT) or PUBLIC_URL.startswith("https://") or BEHIND_PROXY
# extra time a code stays valid after its slot ends (network + decode latency)
TOKEN_GRACE_MS = int(os.environ.get("TOKEN_GRACE_MS", "2500"))
# slack on top of scans*interval to collect all scans of one attempt
ATTEMPT_SLACK_MS = int(os.environ.get("ATTEMPT_SLACK_MS", "8000"))
# once presence is proven, how long the voter has to type an access code
CODE_ENTRY_TTL_S = 180
# keepalive for websockets, proxies drop idle ones (cloudflare ~100s)
HEARTBEAT_S = float(os.environ.get("HEARTBEAT_S", "25"))
# codes needed to confirm each vote, 0 turns the check off
DEFAULT_VOTE_SCANS = 3
MAX_VOTE_SCANS = 5
MIN_INTERVAL_MS = 300
MAX_INTERVAL_MS = 5000
MIN_SCANS = 2
MAX_SCANS = 20