For reading and verification only. You may not copy, use, modify or redistribute this code. Full notice on the main page.
contracts/schemas/wire-v2.grammar.json
| 1 | { |
| 2 | "$comment": "Line grammar of tunnel protocol v2 (the contract section 3). A line is ASCII 0x20-0x7e, ends with LF (the LF counts toward the maximum), fields are separated by exactly one space, no field is empty. Verbs are upper case. `d2n` is device to node, `n2d` node to device. `max` names a policy key (bytes, LF included); lines without one use protocol.line_max_bytes. A field error is `bad_command` unless the field names its own `error`. `json` means the rest of the line after the verb and one space is one canonical JSON object (keys sorted, no whitespace, ASCII) validated against that schema.", |
| 3 | "version": 2, |
| 4 | "types": { |
| 5 | "version": {"pattern": "^[0-9]{1,3}$"}, |
| 6 | "jwt": {"pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$", "max_bytes_from": "protocol.jwt_max_bytes"}, |
| 7 | "statement": {"pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"}, |
| 8 | "nonce": {"pattern": "^[A-Za-z0-9_-]{22,64}$"}, |
| 9 | "stream_id": {"pattern": "^[0-9a-f]{32}$"}, |
| 10 | "attach_secret": {"pattern": "^[A-Za-z0-9_-]{43}$"}, |
| 11 | "ip": {"format": "ip"}, |
| 12 | "source_class": {"enum_from": "protocol.source_classes"}, |
| 13 | "close_reason": {"enum_from": "protocol.close_reasons"}, |
| 14 | "error_code": {"enum_from": "protocol.error_codes"}, |
| 15 | "seconds": {"pattern": "^(?:0|[1-9][0-9]{0,5})$"} |
| 16 | }, |
| 17 | "verbs": { |
| 18 | "HELLO": {"dir": "d2n", "fields": [ |
| 19 | {"name": "version", "type": "version", "equals": "2", "error_if_number": "unsupported_version"}, |
| 20 | {"name": "session", "type": "jwt", "error": "bad_hello"} |
| 21 | ]}, |
| 22 | "PROOF": {"dir": "d2n", "fields": [{"name": "proof", "type": "jwt", "error": "bad_proof"}]}, |
| 23 | "RENEW": {"dir": "d2n", "fields": [{"name": "session", "type": "jwt", "error": "bad_hello"}]}, |
| 24 | "PING": {"dir": "d2n", "fields": []}, |
| 25 | "HINT": {"dir": "d2n", "repeat": {"name": "address", "type": "ip", "min": 1, "max_from": "protocol.hint_max_addresses"}}, |
| 26 | "CLOSE": {"dir": "both", "optional": [{"name": "reason", "type": "close_reason"}]}, |
| 27 | "ATTACH": {"dir": "d2n", "channel": "data", "fields": [ |
| 28 | {"name": "stream_id", "type": "stream_id", "error": "bad_attach"}, |
| 29 | {"name": "secret", "type": "attach_secret", "error": "bad_attach"} |
| 30 | ]}, |
| 31 | "CHALLENGE": {"dir": "n2d", "fields": [{"name": "nonce", "type": "nonce"}]}, |
| 32 | "OK": {"dir": "n2d", "json": "ok-body.schema.json"}, |
| 33 | "ERR": {"dir": "n2d", "fields": [{"name": "code", "type": "error_code"}]}, |
| 34 | "OPEN": {"dir": "n2d", "max": "protocol.open_line_max_bytes", "fields": [ |
| 35 | {"name": "stream_id", "type": "stream_id"}, |
| 36 | {"name": "secret", "type": "attach_secret"}, |
| 37 | {"name": "peer_ip", "type": "ip"}, |
| 38 | {"name": "class", "type": "source_class"} |
| 39 | ]}, |
| 40 | "PONG": {"dir": "n2d", "fields": []}, |
| 41 | "STATEMENT": {"dir": "n2d", "max": "protocol.statement_line_max_bytes", "fields": [{"name": "statement", "type": "statement"}]}, |
| 42 | "DRAIN": {"dir": "n2d", "fields": [{"name": "quiet_s", "type": "seconds"}]} |
| 43 | } |
| 44 | } |