Table of Contents
ABT Proxy
init-abtproxy.service runs /init/abtproxy/abtproxy, a bash wrapper
around proxy_server. If the server dies the wrapper waits five seconds and
starts it again with reboot_crash in argv, so it knows that's what
happened. systemd restarts the wrapper itself after three seconds.
proxy_server is the Bytemark ABT client and the local HTTP server nx uses.
nx never talks to the cloud directly; everything goes through here.
Files in /init/abtproxy:
| file | contents |
|---|---|
config.json | operator config: OAuth, endpoints, IDs, timings, messages, log limits, agency flags |
keys.json | cached card keys |
labels.json | 79 fare products |
denylist.json | about 1.3 MB of blocked tokens |
proxyDB.db | offline queue, SQLite |
logs/ | request and sync logs, plus LOGTRACE.log and OUTFILE.log |
VERSION.info | V1.3.6 |
The logs are noisy and rotate by count and age.
HTTP
nx talks to port 80 (config: HTTP Server Port): /v1/device/keys,
/v1/device/labels, and POST /v1/device/transactions.
Going out, it's Bytemark's UVAPI. OAuth2 client credentials get a bearer token.
After that validate_now answers taps, validation_event_batches takes the
offline queue, validation_lists refreshes the denylist, and
validator_operating_data refreshes labels. Keys and tokens are separate
endpoints.
Denylist, labels, and uploads resync every five minutes here; keys have their own period.
A tap
Online: nx sends the tap to proxy_server, which asks validate_now; the answer
goes on screen. The cloud decides.
Offline: ProxyValidation uses the cached denylist and keys and queues the tap
in proxyDB.db. ProxyDecryption and ProxyKeysMapper unwrap the payload
first; ProxyPassback handles the anti-passback timeout.
SQLite database
The SQLite database is actually a stored queue, located in proxyDB.db:
CREATE TABLE OfflineTransactions (TRANSACTION_DATA TEXT NOT NULL);
A row is a tap, stored as JSON:
{"data": {
"barcode_data": {"barcode_payload": "", "barcode_timestamp": ""},
"device_identifier": "",
"device_type": "OBV",
"media_identifier": "",
"media_scheme": "BYTEMARK",
"media_type": "ENCRYPTED_PAYLOAD",
"result": "valid",
"timestamp": "",
"transit_data": {"block_id": "", "location": "", "operator_id": "",
"route": "", "vehicle_identifier": ""}
}}
Rows upload in batches to validation_event_batches and are cleared.
Cached JSON
The cached JSON is plain. labels.json is {"labels":[...]}. Each entry is
a fare product with id, type, value, group, and
additional_items. denylist.json is a Bytemark envelope: data.list_name,
data.list_version, data.mediums, errors, server_time.
keys.json is {"keys":[...]}.
Without the cloud
Serve the cached keys and labels on port 80 and nx comes up. No OAuth, no validation. See nx.
