From b327db84847dd2cbf50db2cd84c13eb5656cbb2a Mon Sep 17 00:00:00 2001 From: travisladuke Date: Fri, 25 Oct 2024 15:03:27 -0700 Subject: [PATCH] wip --- local.conf/main.tsp | 38 ++++++++++--------- local.conf/tests/physical-bad.json | 1 + .../physical.json} | 0 local.conf/tests/settings-bad.json | 1 + local.conf/tests/test-port-mapping.json | 1 + local.conf/tests/test-ports.json | 1 + local.conf/tests/test-secondary.json | 1 + local.conf/tests/virtual-bad.json | 2 + local.conf/tests/virtual.json | 2 + local.conf/tspconfig.yaml | 1 - 10 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 local.conf/tests/physical-bad.json rename local.conf/{test-physical.json => tests/physical.json} (100%) create mode 100644 local.conf/tests/settings-bad.json create mode 100644 local.conf/tests/test-port-mapping.json create mode 100644 local.conf/tests/test-ports.json create mode 100644 local.conf/tests/test-secondary.json create mode 100644 local.conf/tests/virtual-bad.json create mode 100644 local.conf/tests/virtual.json diff --git a/local.conf/main.tsp b/local.conf/main.tsp index db2d72f..5c191af 100644 --- a/local.conf/main.tsp +++ b/local.conf/main.tsp @@ -2,55 +2,59 @@ import "@typespec/json-schema"; using TypeSpec.JsonSchema; +@extension("additionalProperties", Json) @jsonSchema -model LocalConf { +model local_conf { settings?: Settings; physical?: Physical; virtual?: Virtual; } -model Physical is Record>; +model Physical is Record<_Physical>; @extension("additionalProperties", Json) model _Physical{ - blacklist: boolean = false; - trustedPathId: uint16; + blacklist?: boolean = false; + trustedPathId?: uint16; // mtu: uint16; not implemented } -model Virtual is Record>; +model Virtual is Record<_Virtual>; @extension("additionalProperties", Json) model _Virtual { @summary("Hints on where to reach this peer if no upstreams/roots are online") - try: Array; + try?: Array; @summary("Blacklist a physical path for only this peer. ") - blacklist: Array; + blacklist?: Array; } -model Settings is OptionalProperties<_Settings>; -model _Settings { +@extension("additionalProperties", Json) +model Settings { @summary("Override default port of 9993 and any command line port. It's preferred to override secondaryPort instead.") - primaryPort: Port; + primaryPort?: Port; @summary("Override default randomly selected secondary port.") - secondaryPort: Port; + secondaryPort?: Port; @summary("Override third randomly selected port. This port is used for mapping") - tertiaryPort: Port; + tertiaryPort?: Port; - @summary("Enable UPnP and NAT-PMP. Default: True") - portMappingEnabled: boolean = true; + @summary("false will also disable secondary port. Default: true") + allowSecondaryPort?: boolean = true; + + @summary("Enable UPnP and NAT-PMP. Default: true") + portMappingEnabled?: boolean = true; @summary("Array of interface name prefixes (e.g. eth for eth#) to blacklist for ZT traffic") - interfacePrefixBlacklist: Array; + interfacePrefixBlacklist?: Array; @summary("If non-NULL, allow JSON/HTTP management from this IP network. Default is 127.0.0.1 only.") - allowManagementFrom: Array; + allowManagementFrom?: Array; @summary("bind to these IPs instead of to each interface") - bind: Array; + bind?: Array; } scalar IPSlashPort extends string; diff --git a/local.conf/tests/physical-bad.json b/local.conf/tests/physical-bad.json new file mode 100644 index 0000000..5b789c6 --- /dev/null +++ b/local.conf/tests/physical-bad.json @@ -0,0 +1 @@ +{"physical2": {"10.0.0.0/24": {"blacklist2": "ok"}}} diff --git a/local.conf/test-physical.json b/local.conf/tests/physical.json similarity index 100% rename from local.conf/test-physical.json rename to local.conf/tests/physical.json diff --git a/local.conf/tests/settings-bad.json b/local.conf/tests/settings-bad.json new file mode 100644 index 0000000..4cbca65 --- /dev/null +++ b/local.conf/tests/settings-bad.json @@ -0,0 +1 @@ +{ "settings2": { "portMappingEnabled2": 1 }} diff --git a/local.conf/tests/test-port-mapping.json b/local.conf/tests/test-port-mapping.json new file mode 100644 index 0000000..c94c22b --- /dev/null +++ b/local.conf/tests/test-port-mapping.json @@ -0,0 +1 @@ +{ "settings": { "portMappingEnabled": false }} diff --git a/local.conf/tests/test-ports.json b/local.conf/tests/test-ports.json new file mode 100644 index 0000000..d460e3c --- /dev/null +++ b/local.conf/tests/test-ports.json @@ -0,0 +1 @@ +{ "settings": { "allowSecondaryPort": false, "portMappingEnabled": false }} \ No newline at end of file diff --git a/local.conf/tests/test-secondary.json b/local.conf/tests/test-secondary.json new file mode 100644 index 0000000..96310e0 --- /dev/null +++ b/local.conf/tests/test-secondary.json @@ -0,0 +1 @@ +{ "settings": { "secondaryPort": 19991 }} \ No newline at end of file diff --git a/local.conf/tests/virtual-bad.json b/local.conf/tests/virtual-bad.json new file mode 100644 index 0000000..8cdb68d --- /dev/null +++ b/local.conf/tests/virtual-bad.json @@ -0,0 +1,2 @@ + +{"virtual2": {"feedbeef11": {"try": ["198.51.100.17/9993"], "blacklist": ["195.51.128.0/30"]}}} diff --git a/local.conf/tests/virtual.json b/local.conf/tests/virtual.json new file mode 100644 index 0000000..8f223ea --- /dev/null +++ b/local.conf/tests/virtual.json @@ -0,0 +1,2 @@ + +{"virtual": {"feedbeef11": {"try": ["198.51.100.17/9993"], "blacklist": ["195.51.128.0/30"]}}} diff --git a/local.conf/tspconfig.yaml b/local.conf/tspconfig.yaml index 9103c4e..68fcd31 100644 --- a/local.conf/tspconfig.yaml +++ b/local.conf/tspconfig.yaml @@ -4,4 +4,3 @@ emit: options: "@typespec/json-schema": file-type: "json" - bundleId: local.conf.schema.json