Files
via-core/crates/roads/src/rules.rs
T
mnovak 69e3a9377d [roads] QA F-01: a service road grants only that service
A firewall sees an address and a port, never a hostname, so a road to
photos.home.arpa compiled to home-server:443 and also opened git.home.arpa
there. Rules are now per service:

- devices.json services may carry their own mesh address (same rules as a
  device address, unique among all of them). A road to such a service compiles
  to that address only; the hosting device's plan lists it in the new field
  services[] so it answers on it, and DNS points there.
- A road to a service that shares its address and a port with another service
  is refused (service.shared), naming the others, instead of opening both.
  Narrowing ports: to a port nobody else serves on that address is allowed.
- A device: road reaches the whole device: its own address and its services'
  own addresses.

No Ianitor identity check is needed for this. The home fixture gives photos
its own address (100.96.1.2); tests that encoded the old host:port model are
updated, three new snapshot fixtures cover the address rules, and the golden
plans and pinned digest are regenerated. Mutation-checked: dropping the
refusal, or ignoring the service address, each fails an F-01 test.
2026-11-25 09:01:18 +01:00

142 lines
4.6 KiB
Rust

//! Every rule code a [`crate::Problem`] can carry (docs/FORMATS.md). The validation test fails if one of
//! these has no failing fixture.
// Road files
pub const FILE_KIND: &str = "file.kind";
pub const FILE_NAME: &str = "file.name";
pub const FILE_SIZE: &str = "file.size";
pub const FILE_ENCODING: &str = "file.encoding";
pub const FILE_HEADER: &str = "file.header";
pub const FILE_COUNT: &str = "file.count";
pub const STORE_ROADS: &str = "store.roads";
pub const YAML_REFUSED: &str = "yaml.refused";
pub const YAML_SYNTAX: &str = "yaml.syntax";
pub const KEY_UNKNOWN: &str = "key.unknown";
pub const KEY_DUPLICATE: &str = "key.duplicate";
pub const KEY_MISSING: &str = "key.missing";
pub const KEY_FORBIDDEN: &str = "key.forbidden";
pub const KEY_TYPE: &str = "key.type";
pub const KEY_EMPTY: &str = "key.empty";
pub const ID_FORMAT: &str = "id.format";
pub const ID_FILE_NAME: &str = "id.file-name";
pub const ID_DUPLICATE: &str = "id.duplicate";
pub const VERB_UNKNOWN: &str = "verb.unknown";
pub const REF_FORMAT: &str = "ref.format";
pub const SUBJECT_KIND: &str = "subject.kind";
pub const SUBJECT_UNKNOWN: &str = "subject.unknown";
pub const OBJECT_KIND: &str = "object.kind";
pub const OBJECT_UNKNOWN: &str = "object.unknown";
pub const OBJECT_NOT_EXIT: &str = "object.not-exit";
pub const SUBNET_NOT_CANONICAL: &str = "subnet.not-canonical";
pub const SUBNET_UNROUTED: &str = "subnet.unrouted";
pub const DIRECT_MESH: &str = "direct.mesh";
pub const UNTIL_FORMAT: &str = "until.format";
pub const CREATED_FORMAT: &str = "created.format";
pub const PORTS_FORMAT: &str = "ports.format";
pub const PORTS_NOT_SERVED: &str = "ports.not-served";
pub const SERVICE_SHARED: &str = "service.shared";
pub const VIA_FORMAT: &str = "via.format";
pub const VIA_UNKNOWN: &str = "via.unknown";
pub const VIA_NOT_RELAY: &str = "via.not-relay";
pub const CLASSIC_FORMAT: &str = "classic.format";
pub const CLASSIC_UNACKNOWLEDGED: &str = "classic.unacknowledged";
pub const BODY_RAW_MISSING: &str = "body.raw-missing";
pub const BODY_RAW_OUTSIDE_CUSTOM: &str = "body.raw-outside-custom";
pub const BODY_RAW_HOOK: &str = "body.raw-hook";
// Inactive roads
pub const ROAD_EXPIRED: &str = "road.expired";
pub const ROAD_NO_DEVICES: &str = "road.no-devices";
pub const ROAD_SELF: &str = "road.self";
pub const EXIT_CONFLICT: &str = "exit.conflict";
pub const DIRECT_KILL_SWITCH: &str = "direct.kill-switch";
pub const ROAD_FAMILY: &str = "road.family";
pub const DIRECT_TUNNELLED: &str = "direct.tunnelled";
// Snapshots
pub const SNAPSHOT_JSON: &str = "snapshot.json";
pub const SNAPSHOT_FORMAT: &str = "snapshot.format";
pub const DIRECTORY_ID: &str = "directory.id";
pub const DIRECTORY_DUPLICATE: &str = "directory.duplicate";
pub const DIRECTORY_NAME: &str = "directory.name";
pub const DIRECTORY_MEMBER: &str = "directory.member";
pub const DIRECTORY_MEMBER_UNKNOWN: &str = "directory.member-unknown";
pub const DEVICES_KEY: &str = "devices.key";
pub const DEVICES_DUPLICATE: &str = "devices.duplicate";
pub const DEVICES_NAME: &str = "devices.name";
pub const DEVICES_OWNER: &str = "devices.owner";
pub const DEVICES_OWNER_UNKNOWN: &str = "devices.owner-unknown";
pub const DEVICES_ADDRESS: &str = "devices.address";
pub const DEVICES_ROUTE: &str = "devices.route";
pub const DEVICES_OVERLAP: &str = "devices.overlap";
pub const DEVICES_SERVICE: &str = "devices.service";
pub const DEVICES_PORTS: &str = "devices.ports";
pub const ALL: &[&str] = &[
FILE_KIND,
FILE_NAME,
FILE_SIZE,
FILE_ENCODING,
FILE_HEADER,
FILE_COUNT,
STORE_ROADS,
YAML_REFUSED,
YAML_SYNTAX,
KEY_UNKNOWN,
KEY_DUPLICATE,
KEY_MISSING,
KEY_FORBIDDEN,
KEY_TYPE,
KEY_EMPTY,
ID_FORMAT,
ID_FILE_NAME,
ID_DUPLICATE,
VERB_UNKNOWN,
REF_FORMAT,
SUBJECT_KIND,
SUBJECT_UNKNOWN,
OBJECT_KIND,
OBJECT_UNKNOWN,
OBJECT_NOT_EXIT,
SUBNET_NOT_CANONICAL,
SUBNET_UNROUTED,
DIRECT_MESH,
UNTIL_FORMAT,
CREATED_FORMAT,
PORTS_FORMAT,
PORTS_NOT_SERVED,
SERVICE_SHARED,
VIA_FORMAT,
VIA_UNKNOWN,
VIA_NOT_RELAY,
CLASSIC_FORMAT,
CLASSIC_UNACKNOWLEDGED,
BODY_RAW_MISSING,
BODY_RAW_OUTSIDE_CUSTOM,
BODY_RAW_HOOK,
ROAD_EXPIRED,
ROAD_NO_DEVICES,
ROAD_SELF,
EXIT_CONFLICT,
DIRECT_KILL_SWITCH,
ROAD_FAMILY,
DIRECT_TUNNELLED,
SNAPSHOT_JSON,
SNAPSHOT_FORMAT,
DIRECTORY_ID,
DIRECTORY_DUPLICATE,
DIRECTORY_NAME,
DIRECTORY_MEMBER,
DIRECTORY_MEMBER_UNKNOWN,
DEVICES_KEY,
DEVICES_DUPLICATE,
DEVICES_NAME,
DEVICES_OWNER,
DEVICES_OWNER_UNKNOWN,
DEVICES_ADDRESS,
DEVICES_ROUTE,
DEVICES_OVERLAP,
DEVICES_SERVICE,
DEVICES_PORTS,
];