# Hour Advantage setup file: the input to `hourctl apply`. # # This is NOT a config file the gateway reads. The gateway keeps its # listeners, endpoints, sinks and settings in Postgres; this file describes # some of them, and `hourctl apply` makes the running gateway match it through # the admin API: # # hourctl apply setup.toml --dry-run # say what would change # hourctl apply setup.toml # hourctl export > setup.toml # the current setup, in this layout # # apply creates what is missing and updates what differs. It never removes # anything: a listener, endpoint or sink left out of the file stays as it is. # Secrets are named by environment variable (password_env, secret_env) and # read on the machine running `hourctl apply`; their values are sent to the # gateway and kept in the database, never shown again. # # As written this sets up one HTTP listener with clocks on /office, using # the ZK PUSH package as the example (`hourctl pkg list` lists the # packages pushed to the gateway, and `hourctl pkg show --json` the # options each takes). Every package an endpoint names must have been # pushed first (`hourctl pkg push`, see Packages in the docs). Events are stored and readable with # `hourctl events` (or GET /api/events); the commented sections show # the rest, an MQTT-connected example protocol among them. # Proxies (load balancers) in front of the device listeners. Only from these # is X-Forwarded-For believed. Must come before the first [section]. # trusted_proxies = ["10.0.0.0/8"] # Finished commands, finished jobs and delivered events are removed after # this many days. An event a sink has not taken is never removed for its age: # it waits for the sink, however long, and a sink that falls behind is told # so (sink.behind). Lowering it removes delivered events sooner and is never # refused. Audit entries are kept for ever, or for `audit_retention_days` # when that is set (`hourctl settings set audit_retention_days=365`). Must # come before the first [section]. # retention_days = 30 # ---------------------------------------------------------------- listeners # HTTP listeners only serve device traffic; anything that matches no # endpoint gets a bare 404. They speak plain HTTP (many clocks cannot do TLS). [[listener]] id = "public" type = "http" listen = "0.0.0.0:8080" # A second port, for firmware that can only be given host and port: # [[listener]] # id = "legacy" # type = "http" # listen = "0.0.0.0:8081" # MQTT listeners connect out to a broker: # [[listener]] # id = "broker" # type = "mqtt" # broker = "mqtt://127.0.0.1:1883" # mqtts:// for TLS # username = "houradvantage" # password_env = "HOURADVANTAGE_MQTT_PASSWORD" # ---------------------------------------------------------------- endpoints # An endpoint: traffic on this listener under this path # (or topic) uses this package, these options and these sinks. The longest # matching path prefix wins, and the prefix is stripped before the package # sees the request. # # new_devices says what happens to a device nobody has registered: # "hold" it registers itself as pending and is refused until allowed # (hourctl device allow ) # "allow" it registers itself and is let in # "refuse" it is turned away; only devices registered ahead of time get in # A device that registers itself is announced with a device.new event. # # Device ids (serial numbers, MAC addresses) are easy to guess: give devices # keys (see Devices in the docs) and use a path that cannot be guessed # (path = "/office-3f9c2a71"). # # options.biometrics = true lets the endpoint collect fingerprint, face and palm # templates and photos; without it the gateway drops them whatever the # package does (see Events in the docs, "Biometric data and photos"). [[endpoint]] id = "office" listener = "public" path = "/office" package = "zk-push@3.4" # ZK clocks send times without an offset, so their package needs the zone # (see ZKTeco PUSH in the docs). options = { timezone = "America/Chicago" } # sinks = ["payroll"] # the systems that are sent its events # new_devices = "hold" # "allow" | "hold" | "refuse" # ZK: pick the package for the pushver the clocks report: zk-push@3.4, # zk-push@2.4 or zk-push@2.0. # # [[endpoint]] # id = "warehouse" # listener = "public" # path = "/warehouse" # package = "zk-push@2.0" # options = { timezone = "America/Chicago", upload_users = false, delay = 60 } # One group per site: {site} reaches the package as req.params.site. # [[endpoint]] # id = "sites" # listener = "public" # path = "/site/{site}" # package = "zk-push@3.4" # options = { timezone = "America/Chicago" } # A whole port for one group (no path): # [[endpoint]] # id = "legacy-zk" # listener = "legacy" # package = "zk-push@2.0" # options = { timezone = "Europe/Berlin" } # Clocks on an MQTT broker (the bundled example protocol, JSON envelopes; # the device id is the {device} topic segment, and the devices state the # offset in every timestamp, so no zone is needed): # [[endpoint]] # id = "cloud" # listener = "broker" # topic = "clocks/{device}/events" # reply_topic = "clocks/{device}/commands" # package = "brightlink-cloud" # new_devices = "allow" # ---------------------------------------------------------------- sinks # A webhook sink is POSTed {"events": [...]} and must answer 2xx. It is sent # the events of the endpoints that name it, in order, again until it accepts # them: it can see an event twice (same id), so it should ignore ids it has # seen. With secret_env set, each request is signed (see Events in the docs). # Without an `events` filter it is sent everything, including biometric # templates and photos where an endpoint collects them. # # [[sink]] # id = "payroll" # type = "webhook" # url = "https://example.com/hooks/clock" # secret_env = "HOURADVANTAGE_WEBHOOK_SECRET" # events = ["punch", "command.result"] # ---------------------------------------------------------------- settings # Shared by every instance. Package calls at once are not a setting: they # follow each instance's processors (four per CPU; HOURADVANTAGE_CPUS). # [limits] # max_body_bytes = 4194304 # largest device message # max_pending_devices = 100 # devices waiting to be allowed, per endpoint # traffic_body_bytes = 16384 # bytes of each body kept in the traffic log; # # 0 keeps none (bodies can hold credentials # # and biometric data) # The gateway's log level, on every instance. The log itself goes to stdout: # text at a terminal, else one JSON object per line for a log collector. # The wire capture (every byte the HTTP listeners receive and send) is not a # setting either: `hourctl wire --for 15m [--device DEVICE]` shows it # live, from every instance, for a while; it is never stored or logged. # [log] # level = "info" # RUST_LOG syntax; RUST_LOG, when set, wins at startup