From 1ca84df9d168f3ae3c57965bdc0c8d988285f142 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Thu, 30 Sep 2021 08:00:34 -0700 Subject: [PATCH] Adding fetching of the schema from git --- build | 2 +- src/ConfigurationValidator.cpp | 33 +- src/Utils.cpp | 32 + src/Utils.h | 2 + test_scripts/curl/import_tree.json | 6 +- test_scripts/curl/ucentral.schema.json | 2139 ++++++++++++++++++++++++ 6 files changed, 2199 insertions(+), 15 deletions(-) create mode 100644 test_scripts/curl/ucentral.schema.json diff --git a/build b/build index eaea6f5..b6e2760 100644 --- a/build +++ b/build @@ -1 +1 @@ -240 \ No newline at end of file +242 \ No newline at end of file diff --git a/src/ConfigurationValidator.cpp b/src/ConfigurationValidator.cpp index da46e4b..1d4f8d8 100644 --- a/src/ConfigurationValidator.cpp +++ b/src/ConfigurationValidator.cpp @@ -5,10 +5,13 @@ #include #include #include "ConfigurationValidator.h" - +#include "Utils.h" #include "Daemon.h" namespace OpenWifi { + + static const std::string GitUCentralJSONSchemaFile{"https://raw.githubusercontent.com/blogic/ucentral-schema/main/ucentral.schema.json"}; + static json DefaultUCentralSchema = R"( { "$id": "https://openwrt.org/ucentral.schema.json", @@ -2158,19 +2161,23 @@ namespace OpenWifi { if(Initialized_) return; - std::string FileName{ Daemon()->DataDir() + "/ucentral.schema.json" }; - try { - std::ifstream input(FileName); - std::stringstream schema_file; - schema_file << input.rdbuf(); - input.close(); - auto schema = json::parse(schema_file.str()); - Validator_->set_root_schema(schema); - Initialized_ = Working_ = true; - } catch (const std::exception &E ) { - Validator_->set_root_schema(DefaultUCentralSchema); - Initialized_ = Working_ = true; + std::string GitSchema; + if(Utils::wgets(GitUCentralJSONSchemaFile, GitSchema)) { + + } else { + std::string FileName{ Daemon()->DataDir() + "/ucentral.schema.json" }; + try { + std::ifstream input(FileName); + std::stringstream schema_file; + schema_file << input.rdbuf(); + input.close(); + GitSchema = schema_file.str(); + } catch (const Poco::Exception &E) { + GitSchema = DefaultUCentralSchema; + } } + Validator_->set_root_schema(GitSchema); + Initialized_ = Working_ = true; } bool ConfigurationValidator::Validate(const std::string &C) { diff --git a/src/Utils.cpp b/src/Utils.cpp index ccd86bd..37d0308 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -24,6 +24,9 @@ #include "Poco/File.h" #include "Poco/StreamCopier.h" #include "Poco/Path.h" +#include "Poco/URI.h" +#include "Poco/Net/HTTPSClientSession.h" +#include "Poco/Net/HTTPResponse.h" #include "uCentralProtocol.h" #include "Daemon.h" @@ -488,4 +491,33 @@ namespace OpenWifi::Utils { return Result; } + bool wgets(const std::string &URL, std::string &Response) { + try { + Poco::URI uri(URL); + Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort()); + + // prepare path + std::string path(uri.getPathAndQuery()); + if (path.empty()) { + path = "/"; + } + + // send request + Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1); + session.sendRequest(req); + + Poco::Net::HTTPResponse res; + std::istream &is = session.receiveResponse(res); + std::ostringstream os; + + Poco::StreamCopier::copyStream(is,os); + Response = os.str(); + + return true; + } catch (...) { + + } + return false; + } + } diff --git a/src/Utils.h b/src/Utils.h index f35b648..5b84cd8 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -73,6 +73,8 @@ namespace OpenWifi::Utils { [[nodiscard]] std::string BinaryFileToHexString( const Poco::File &F); [[nodiscard]] std::string SecondsToNiceText(uint64_t Seconds); + [[nodiscard]] bool wgets(const std::string &URL, std::string &Response); + template< typename T > std::string int_to_hex( T i ) { diff --git a/test_scripts/curl/import_tree.json b/test_scripts/curl/import_tree.json index a08e7d2..c5cd796 100644 --- a/test_scripts/curl/import_tree.json +++ b/test_scripts/curl/import_tree.json @@ -42,7 +42,11 @@ { "type": "entity", "name": "BC", - "children": [], + "children": [{ + "type": "entity", + "name": "Bowen", + "children": [], + "venues": []}], "venues": [{ "type": "venue", "name": "BC Place", diff --git a/test_scripts/curl/ucentral.schema.json b/test_scripts/curl/ucentral.schema.json new file mode 100644 index 0000000..f337b4d --- /dev/null +++ b/test_scripts/curl/ucentral.schema.json @@ -0,0 +1,2139 @@ +{ + "$id": "https://openwrt.org/ucentral.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "uuid": { + "type": "integer" + }, + "unit": { + "$ref": "#/$defs/unit" + }, + "globals": { + "$ref": "#/$defs/globals" + }, + "definitions": { + "$ref": "#/$defs/definitions" + }, + "ethernet": { + "type": "array", + "items": { + "$ref": "#/$defs/ethernet" + } + }, + "switch": { + "$ref": "#/$defs/switch" + }, + "radios": { + "type": "array", + "items": { + "$ref": "#/$defs/radio" + } + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/$defs/interface" + } + }, + "services": { + "$ref": "#/$defs/service" + }, + "metrics": { + "$ref": "#/$defs/metrics" + }, + "config-raw": { + "$ref": "#/$defs/config-raw" + }, + "third-party": { + "type": "object", + "additionalProperties": true + } + }, + "$defs": { + "unit": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "location": { + "type": "string" + }, + "timezone": { + "type": "string", + "examples": [ + "UTC", + "EST5", + "CET-1CEST,M3.5.0,M10.5.0/3" + ] + }, + "leds-active": { + "type": "boolean", + "default": true + }, + "random-password": { + "type": "boolean", + "default": false + } + } + }, + "globals": { + "type": "object", + "properties": { + "ipv4-network": { + "type": "string", + "format": "uc-cidr4", + "examples": [ + "192.168.0.0/16" + ] + }, + "ipv6-network": { + "type": "string", + "format": "uc-cidr6", + "examples": [ + "fdca:1234:4567::/48" + ] + } + } + }, + "definitions": { + "type": "object", + "properties": { + "wireless-encryption": { + "type": "object", + "patternProperties": { + ".+": { + "$ref": "#/$defs/interface.ssid.encryption", + "additionalProperties": false + } + } + } + } + }, + "ethernet": { + "type": "object", + "properties": { + "select-ports": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "LAN1", + "LAN2", + "LAN3", + "LAN4", + "LAN*", + "WAN*", + "*" + ] + } + }, + "speed": { + "type": "integer", + "enum": [ + 10, + 100, + 1000, + 2500, + 5000, + 10000 + ] + }, + "duplex": { + "type": "string", + "enum": [ + "half", + "full" + ] + }, + "services": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "quality-of-service" + ] + } + } + } + }, + "switch": { + "type": "object", + "properties": { + "port-mirror": { + "type": "object", + "properties": { + "monitor-ports": { + "type": "array", + "items": { + "type": "string" + } + }, + "analysis-port": { + "type": "string" + } + } + }, + "loop-detection": { + "type": "object", + "properties": { + "protocol": { + "type": "string", + "enum": [ + "rstp" + ], + "default": "rstp" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "upstream", + "downstream" + ] + } + } + } + } + } + }, + "radio.rates": { + "type": "object", + "properties": { + "beacon": { + "type": "integer", + "default": 6000, + "enum": [ + 0, + 1000, + 2000, + 5500, + 6000, + 9000, + 11000, + 12000, + 18000, + 24000, + 36000, + 48000, + 54000 + ] + }, + "multicast": { + "type": "integer", + "default": 24000, + "enum": [ + 0, + 1000, + 2000, + 5500, + 6000, + 9000, + 11000, + 12000, + 18000, + 24000, + 36000, + 48000, + 54000 + ] + } + } + }, + "radio.he": { + "type": "object", + "properties": { + "multiple-bssid": { + "type": "boolean", + "default": false + }, + "ema": { + "type": "boolean", + "default": false + }, + "bss-color": { + "type": "integer", + "default": 64 + } + } + }, + "radio": { + "type": "object", + "properties": { + "band": { + "type": "string", + "enum": [ + "2G", + "5G", + "5G-lower", + "5G-upper", + "6G" + ] + }, + "bandwidth": { + "type": "integer", + "enum": [ + 5, + 10, + 20 + ] + }, + "channel": { + "oneOf": [ + { + "type": "integer", + "maximum": 171, + "minimum": 1 + }, + { + "type": "string", + "const": "auto" + } + ] + }, + "country": { + "type": "string", + "maxLength": 2, + "minLength": 2, + "examples": [ + "US" + ] + }, + "channel-mode": { + "type": "string", + "enum": [ + "HT", + "VHT", + "HE" + ], + "default": "HE" + }, + "channel-width": { + "type": "integer", + "enum": [ + 20, + 40, + 80, + 160, + 8080 + ], + "default": 80 + }, + "require-mode": { + "type": "string", + "enum": [ + "HT", + "VHT", + "HE" + ] + }, + "mimo": { + "type": "string", + "enum": [ + "1x1", + "2x2", + "3x3", + "4x4", + "5x5", + "6x6", + "7x7", + "8x8" + ] + }, + "tx-power": { + "type": "integer", + "maximum": 30, + "minimum": 0 + }, + "legacy-rates": { + "type": "boolean", + "default": false + }, + "beacon-interval": { + "type": "integer", + "default": 100, + "maximum": 65535, + "minimum": 15 + }, + "dtim-period": { + "type": "integer", + "default": 2, + "maximum": 255, + "minimum": 1 + }, + "maximum-clients": { + "type": "integer", + "example": 64 + }, + "rates": { + "$ref": "#/$defs/radio.rates" + }, + "he-settings": { + "$ref": "#/$defs/radio.he" + }, + "hostapd-iface-raw": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "ap_table_expiration_time=3600", + "device_type=6-0050F204-1", + "ieee80211h=1", + "rssi_ignore_probe_request=-75", + "time_zone=EST5", + "uuid=12345678-9abc-def0-1234-56789abcdef0", + "venue_url=1:http://www.example.com/info-eng", + "wpa_deny_ptk0_rekey=0" + ] + } + } + } + }, + "interface.vlan": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "maximum": 4050 + }, + "proto": { + "decription": "The L2 vlan tag that shall be added (1q,1ad)", + "type": "string", + "enum": [ + "802.1ad", + "802.1q" + ], + "default": "802.1q" + } + } + }, + "interface.bridge": { + "type": "object", + "properties": { + "mtu": { + "type": "integer", + "maximum": 65535, + "minimum": 256, + "examples": [ + 1500 + ] + }, + "tx-queue-len": { + "type": "integer", + "examples": [ + 5000 + ] + }, + "isolate-ports": { + "type": "boolean", + "default": false + } + } + }, + "interface.ethernet": { + "type": "object", + "properties": { + "select-ports": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "LAN1", + "LAN2", + "LAN3", + "LAN4", + "LAN*", + "WAN*", + "*" + ] + } + }, + "multicast": { + "type": "boolean", + "default": true + }, + "learning": { + "type": "boolean", + "default": true + }, + "isolate": { + "type": "boolean", + "default": false + }, + "macaddr": { + "type": "string", + "format": "uc-mac" + }, + "reverse-path-filter": { + "type": "boolean", + "default": false + }, + "vlan-tag": { + "type": "string", + "enum": [ + "tagged", + "un-tagged", + "auto" + ], + "default": "auto" + } + } + }, + "interface.ipv4.dhcp": { + "type": "object", + "properties": { + "lease-first": { + "type": "integer", + "examples": [ + 10 + ] + }, + "lease-count": { + "type": "integer", + "examples": [ + 100 + ] + }, + "lease-time": { + "type": "string", + "format": "uc-timeout", + "default": "6h" + }, + "relay-server": { + "type": "string", + "format": "ipv4", + "example": "192.168.2.1" + }, + "circuit-id-format": { + "type": "string", + "example": [ + "\\{Interface\\}:\\{VLAN-Id\\}:\\{SSID\\}:\\{Model\\}:\\{Name\\}:\\{AP-MAC\\}:\\{Location\\}", + "\\{AP-MAC\\};\\{SSID\\};\\{Crypto\\}", + "\\{Name\\} \\{ESSID\\}" + ] + }, + "remote-id-format": { + "type": "string", + "example": [ + "\\{Client-MAC-hex\\} \\{SSID\\}", + "\\{AP-MAC-hex\\} \\{SSID\\}" + ] + } + } + }, + "interface.ipv4.dhcp-lease": { + "type": "object", + "properties": { + "macaddr": { + "type": "string", + "format": "uc-mac", + "examples": [ + "00:11:22:33:44:55" + ] + }, + "static-lease-offset": { + "type": "integer", + "examples": [ + 10 + ] + }, + "lease-time": { + "type": "string", + "format": "uc-timeout", + "default": "6h" + }, + "publish-hostname": { + "type": "boolean", + "default": true + } + } + }, + "interface.ipv4": { + "type": "object", + "properties": { + "addressing": { + "type": "string", + "enum": [ + "dynamic", + "static" + ], + "examples": [ + "static" + ] + }, + "subnet": { + "type": "string", + "format": "uc-cidr4", + "examples": [ + "auto/24" + ] + }, + "gateway": { + "type": "string", + "format": "ipv4", + "examples": [ + "192.168.1.1" + ] + }, + "send-hostname": { + "type": "boolean", + "default": true, + "examples": [ + true + ] + }, + "use-dns": { + "type": "array", + "items": { + "type": "string", + "format": "ipv4", + "examples": [ + "8.8.8.8", + "4.4.4.4" + ] + } + }, + "dhcp": { + "$ref": "#/$defs/interface.ipv4.dhcp" + }, + "dhcp-leases": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ipv4.dhcp-lease" + } + } + } + }, + "interface.ipv6.dhcpv6": { + "type": "object", + "properties": { + "mode": { + "type": "string", + "enum": [ + "hybrid", + "stateless", + "stateful", + "relay" + ] + }, + "announce-dns": { + "type": "array", + "items": { + "type": "string", + "format": "ipv6" + } + }, + "filter-prefix": { + "type": "string", + "format": "uc-cidr6", + "default": "::/0" + } + } + }, + "interface.ipv6": { + "type": "object", + "properties": { + "addressing": { + "type": "string", + "enum": [ + "dynamic", + "static" + ] + }, + "subnet": { + "type": "string", + "format": "uc-cidr6", + "examples": [ + "auto/64" + ] + }, + "gateway": { + "type": "string", + "format": "ipv6", + "examples": [ + "2001:db8:123:456::1" + ] + }, + "prefix-size": { + "type": "integer", + "maximum": 64, + "minimum": 0 + }, + "dhcpv6": { + "$ref": "#/$defs/interface.ipv6.dhcpv6" + } + } + }, + "interface.broad-band.wwan": { + "type": "object", + "properties": { + "protocol": { + "type": "string", + "const": "wwan" + }, + "modem-type": { + "type": "string", + "enum": [ + "qmi", + "mbim", + "wwan" + ] + }, + "access-point-name": { + "type": "string" + }, + "authentication-type": { + "type": "string", + "enum": [ + "none", + "pap", + "chap", + "pap-chap" + ], + "default": "none" + }, + "pin-code": { + "type": "string" + }, + "user-name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "packet-data-protocol": { + "type": "string", + "enum": [ + "ipv4", + "ipv6", + "dual-stack" + ], + "default": "dual-stack" + } + } + }, + "interface.broad-band.pppoe": { + "type": "object", + "properties": { + "protocol": { + "type": "string", + "const": "pppoe" + }, + "user-name": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "interface.broad-band": { + "oneOf": [ + { + "$ref": "#/$defs/interface.broad-band.wwan" + }, + { + "$ref": "#/$defs/interface.broad-band.pppoe" + } + ] + }, + "interface.captive": { + "type": "object", + "properties": { + "gateway-name": { + "type": "string", + "default": "uCentral - Captive Portal" + }, + "gateway-fqdn": { + "type": "string", + "format": "fqdn", + "default": "ucentral.splash" + }, + "max-clients": { + "type": "integer", + "default": 32 + }, + "upload-rate": { + "type": "integer", + "default": 0 + }, + "download-rate": { + "type": "integer", + "default": 0 + }, + "upload-quota": { + "type": "integer", + "default": 0 + }, + "download-quota": { + "type": "integer", + "default": 0 + } + } + }, + "interface.ssid.encryption": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "enum": [ + "none", + "psk", + "psk2", + "psk-mixed", + "wpa", + "wpa2", + "wpa-mixed", + "sae", + "sae-mixed", + "wpa3", + "wpa3-mixed" + ], + "examples": [ + "psk2" + ] + }, + "key": { + "type": "string", + "maxLength": 63, + "minLength": 8 + }, + "ieee80211w": { + "type": "string", + "enum": [ + "disabled", + "optional", + "required" + ], + "default": "disabled" + } + } + }, + "interface.ssid.multi-psk": { + "type": "object", + "properties": { + "mac": { + "type": "string", + "format": "uc-mac" + }, + "key": { + "type": "string", + "maxLength": 63, + "minLength": 8 + }, + "vlan-id": { + "type": "integer", + "maximum": 4096, + "examples": [ + 3, + 100, + 200, + 4094 + ] + } + } + }, + "interface.ssid.rrm": { + "type": "object", + "properties": { + "neighbor-reporting": { + "type": "boolean", + "default": false + }, + "lci": { + "type": "string" + }, + "civic-location": { + "type": "string" + }, + "ftm-responder": { + "type": "boolean", + "default": false + }, + "stationary-ap": { + "type": "boolean", + "default": false + } + } + }, + "interface.ssid.rate-limit": { + "type": "object", + "properties": { + "ingress-rate": { + "type": "integer", + "default": 0 + }, + "egress-rate": { + "type": "integer", + "default": 0 + } + } + }, + "interface.ssid.roaming": { + "type": "object", + "properties": { + "message-exchange": { + "type": "string", + "enum": [ + "air", + "ds" + ], + "default": "ds" + }, + "generate-psk": { + "type": "boolean", + "default": false + }, + "domain-identifier": { + "type": "string", + "maxLength": 4, + "minLength": 4, + "examples": [ + "abcd" + ] + }, + "pmk-r0-key-holder": { + "type": "string", + "example": "14:DD:20:47:14:E4,14DD204714E4,00112233445566778899aabbccddeeff" + }, + "pmk-r1-key-holder": { + "type": "string", + "example": "14:DD:20:47:14:E4,14DD204714E4,00112233445566778899aabbccddeeff" + } + } + }, + "interface.ssid.radius.local-user": { + "type": "object", + "properties": { + "mac": { + "type": "string", + "format": "uc-mac" + }, + "user-name": { + "type": "string", + "minLength": 1 + }, + "password": { + "type": "string", + "maxLength": 63, + "minLength": 8 + }, + "vlan-id": { + "type": "integer", + "maximum": 4096, + "examples": [ + 3, + 100, + 200, + 4094 + ] + } + } + }, + "interface.ssid.radius.local": { + "type": "object", + "properties": { + "server-identity": { + "type": "string", + "default": "uCentral" + }, + "users": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ssid.radius.local-user" + } + } + } + }, + "interface.ssid.radius.server": { + "type": "object", + "properties": { + "host": { + "type": "string", + "format": "uc-host", + "examples": [ + "192.168.1.10" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1024, + "examples": [ + 1812 + ] + }, + "secret": { + "type": "string", + "examples": [ + "secret" + ] + }, + "request-attribute": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "maximum": 255, + "minimum": 1 + }, + "value": { + "anyOf": [ + { + "type": "integer", + "maximum": 4294967295, + "minimum": 0 + }, + { + "type": "string" + } + ] + } + }, + "examples": [ + { + "id": 27, + "value": 900 + }, + { + "id": 32, + "value": "My NAS ID" + }, + { + "id": 56, + "value": 1004 + }, + { + "id": 126, + "value": "Example Operator" + } + ] + }, + "examples": [ + "126:s:Operator" + ] + } + } + }, + "interface.ssid.radius": { + "type": "object", + "properties": { + "nas-identifier": { + "type": "string" + }, + "chargeable-user-id": { + "type": "boolean", + "default": false + }, + "local": { + "$ref": "#/$defs/interface.ssid.radius.local" + }, + "authentication": { + "$ref": "#/$defs/interface.ssid.radius.server" + }, + "accounting": { + "allOf": [ + { + "$ref": "#/$defs/interface.ssid.radius.server" + }, + { + "type": "object", + "properties": { + "interval": { + "type": "integer", + "maximum": 600, + "minimum": 60, + "default": 60 + } + } + } + ] + } + } + }, + "interface.ssid.certificates": { + "type": "object", + "properties": { + "use-local-certificates": { + "type": "boolean", + "default": false + }, + "ca-certificate": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "private-key": { + "type": "string" + }, + "private-key-password": { + "type": "string" + } + } + }, + "interface.ssid.pass-point": { + "type": "object", + "properties": { + "venue-name": { + "type": "array", + "items": { + "type": "string" + } + }, + "venue-group": { + "type": "integer", + "maximum": 32 + }, + "venue-type": { + "type": "integer", + "maximum": 32 + }, + "venue-url": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "auth-type": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "terms-and-conditions", + "online-enrollment", + "http-redirection", + "dns-redirection" + ] + }, + "uri": { + "type": "string", + "format": "uri", + "examples": [ + "https://operator.example.org/wireless-access/terms-and-conditions.html", + "http://www.example.com/redirect/me/here/" + ] + } + }, + "minLength": 2, + "maxLength": 2 + }, + "domain-name": { + "type": "string", + "format": "hostname" + }, + "nai-realm": { + "type": "array", + "items": { + "type": "string" + } + }, + "osen": { + "type": "boolean" + }, + "anqp-domain": { + "type": "integer", + "maximum": 65535, + "minimum": 0 + }, + "anqp-3gpp-cell-net": { + "type": "array", + "items": { + "type": "string" + } + }, + "friendly-name": { + "type": "array", + "items": { + "type": "string" + } + }, + "access-network-type": { + "type": "integer", + "maximum": 15, + "default": 0 + }, + "internet": { + "type": "boolean", + "default": true + }, + "asra": { + "type": "boolean", + "default": false + }, + "esr": { + "type": "boolean", + "default": false + }, + "uesa": { + "type": "boolean", + "default": false + }, + "hessid": { + "type": "string", + "example": "00:11:22:33:44:55" + }, + "roaming-consortium": { + "type": "array", + "items": { + "type": "string" + } + }, + "disable-dgaf": { + "type": "boolean", + "default": false + }, + "ipaddr-type-available": { + "type": "integer", + "maximum": 255 + }, + "connection-capability": { + "type": "array", + "items": { + "type": "string" + } + }, + "icons": { + "type": "array", + "items": { + "type": "object", + "properties": { + "width": { + "type": "integer", + "examples": [ + 64 + ] + }, + "height": { + "type": "integer", + "examples": [ + 64 + ] + }, + "type": { + "type": "string", + "examples": [ + "image/png" + ] + }, + "icon": { + "type": "string", + "format": "uc-base64" + }, + "language": { + "type": "string", + "pattern": "^[a-z][a-z][a-z]$", + "examples": [ + "eng", + "fre", + "ger", + "ita" + ] + } + }, + "examples": [ + { + "width": 32, + "height": 32, + "type": "image/png", + "language": "eng", + "icon": "R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" + } + ] + } + } + } + }, + "interface.ssid.quality-thresholds": { + "type": "object", + "properties": { + "probe-request-rssi": { + "type": "integer" + }, + "association-request-rssi": { + "type": "integer" + } + } + }, + "interface.ssid": { + "type": "object", + "properties": { + "purpose": { + "type": "string", + "enum": [ + "user-defined", + "onboarding-ap", + "onboarding-sta" + ], + "default": "user-defined" + }, + "name": { + "type": "string", + "maxLength": 32, + "minLength": 1 + }, + "wifi-bands": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "2G", + "5G", + "5G-lower", + "5G-upper", + "6G" + ] + } + }, + "bss-mode": { + "type": "string", + "enum": [ + "ap", + "sta", + "mesh", + "wds-ap", + "wds-sta", + "wds-repeater" + ], + "default": "ap" + }, + "bssid": { + "type": "string", + "format": "uc-mac" + }, + "hidden-ssid": { + "type": "boolean" + }, + "isolate-clients": { + "type": "boolean" + }, + "power-save": { + "type": "boolean" + }, + "rts-threshold": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "broadcast-time": { + "type": "boolean" + }, + "unicast-conversion": { + "type": "boolean" + }, + "services": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "wifi-steering" + ] + } + }, + "maximum-clients": { + "type": "integer", + "example": 64 + }, + "proxy-arp": { + "type": "boolean", + "default": true + }, + "disassoc-low-ack": { + "decription": "Disassociate stations based on excessive transmission failures or other indications of connection loss.", + "type": "boolean", + "default": false + }, + "vendor-elements": { + "decription": "This option allows embedding custom vendor specific IEs inside the beacons of a BSS in AP mode.", + "type": "string" + }, + "encryption": { + "$ref": "#/$defs/interface.ssid.encryption" + }, + "multi-psk": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ssid.multi-psk" + } + }, + "rrm": { + "$ref": "#/$defs/interface.ssid.rrm" + }, + "rate-limit": { + "$ref": "#/$defs/interface.ssid.rate-limit" + }, + "roaming": { + "$ref": "#/$defs/interface.ssid.roaming" + }, + "radius": { + "$ref": "#/$defs/interface.ssid.radius" + }, + "certificates": { + "$ref": "#/$defs/interface.ssid.certificates" + }, + "pass-point": { + "$ref": "#/$defs/interface.ssid.pass-point" + }, + "quality-thresholds": { + "$ref": "#/$defs/interface.ssid.quality-thresholds" + }, + "hostapd-bss-raw": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "ap_table_expiration_time=3600", + "device_type=6-0050F204-1", + "ieee80211h=1", + "rssi_ignore_probe_request=-75", + "time_zone=EST5", + "uuid=12345678-9abc-def0-1234-56789abcdef0", + "venue_url=1:http://www.example.com/info-eng", + "wpa_deny_ptk0_rekey=0" + ] + } + } + } + }, + "interface.tunnel.mesh": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "const": "mesh" + } + } + }, + "interface.tunnel.vxlan": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "const": "vxlan" + }, + "peer-address": { + "type": "string", + "format": "ipv4", + "example": "192.168.100.1" + }, + "peer-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "examples": [ + 4789 + ] + } + } + }, + "interface.tunnel.l2tp": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "const": "l2tp" + }, + "server": { + "type": "string", + "format": "ipv4", + "example": "192.168.100.1" + }, + "user-name": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "interface.tunnel.gre": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "const": "gre" + }, + "peer-address": { + "type": "string", + "format": "ipv4", + "example": "192.168.100.1" + }, + "vlan-id": { + "type": "integer", + "maximum": 4096 + } + } + }, + "interface.tunnel": { + "oneOf": [ + { + "$ref": "#/$defs/interface.tunnel.mesh" + }, + { + "$ref": "#/$defs/interface.tunnel.vxlan" + }, + { + "$ref": "#/$defs/interface.tunnel.l2tp" + }, + { + "$ref": "#/$defs/interface.tunnel.gre" + } + ] + }, + "interface": { + "type": "object", + "properties": { + "name": { + "type": "string", + "examples": [ + "LAN" + ] + }, + "role": { + "type": "string", + "enum": [ + "upstream", + "downstream" + ] + }, + "isolate-hosts": { + "type": "boolean" + }, + "metric": { + "type": "integer", + "maximum": 4294967295, + "minimum": 0 + }, + "services": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "ssh", + "lldp" + ] + } + }, + "vlan": { + "$ref": "#/$defs/interface.vlan" + }, + "bridge": { + "$ref": "#/$defs/interface.bridge" + }, + "ethernet": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ethernet" + } + }, + "ipv4": { + "$ref": "#/$defs/interface.ipv4" + }, + "ipv6": { + "$ref": "#/$defs/interface.ipv6" + }, + "broad-band": { + "$ref": "#/$defs/interface.broad-band" + }, + "captive": { + "$ref": "#/$defs/interface.captive" + }, + "ssids": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ssid" + } + }, + "tunnel": { + "$ref": "#/$defs/interface.tunnel" + } + } + }, + "service.lldp": { + "type": "object", + "properties": { + "describe": { + "type": "string", + "default": "uCentral Access Point" + }, + "location": { + "type": "string", + "default": "uCentral Network" + } + } + }, + "service.ssh": { + "type": "object", + "properties": { + "port": { + "type": "integer", + "maximum": 65535, + "default": 22 + }, + "authorized-keys": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC0ghdSd2D2y08TFowZLMZn3x1/Djw3BkNsIeHt/Z+RaXwvfV1NQAnNdaOngMT/3uf5jZtYxhpl+dbZtRhoUPRvKflKBeFHYBqjZVzD3r4ns2Ofm2UpHlbdOpMuy9oeTSCeF0IKZZ6szpkvSirQogeP2fe9KRkzQpiza6YxxaJlWw== user@example", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ4FDjyCsg+1Mh2C5G7ibR3z0Kw1dU57kfXebLRwS6CL bob@work", + "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBP/JpJ/KHtKKImzISBDwLO0/EwytIr4pGZQXcP6GCSHchLMyfjf147KNlF9gC+3FibzqKH02EiQspVhRgfuK6y0= alice@home" + ] + } + }, + "password-authentication": { + "type": "boolean", + "default": true + } + } + }, + "service.ntp": { + "type": "object", + "properties": { + "servers": { + "type": "array", + "items": { + "type": "string", + "format": "uc-host" + }, + "examples": [ + "0.openwrt.pool.ntp.org" + ] + }, + "local-server": { + "type": "boolean", + "examples": [ + true + ] + } + } + }, + "service.mdns": { + "type": "object", + "properties": { + "enable": { + "type": "boolean", + "default": false + } + } + }, + "service.rtty": { + "type": "object", + "properties": { + "host": { + "type": "string", + "format": "uc-host", + "examples": [ + "192.168.1.10" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "default": 5912 + }, + "token": { + "type": "string", + "maxLength": 32, + "minLength": 32, + "examples": [ + "01234567890123456789012345678901" + ] + } + } + }, + "service.log": { + "type": "object", + "properties": { + "host": { + "type": "string", + "format": "uc-host", + "examples": [ + "192.168.1.10" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 100, + "examples": [ + 2000 + ] + }, + "proto": { + "type": "string", + "enum": [ + "tcp", + "udp" + ], + "default": "udp" + }, + "size": { + "type": "integer", + "minimum": 32, + "default": 1000 + } + } + }, + "service.http": { + "type": "object", + "properties": { + "http-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "default": 80 + } + } + }, + "service.igmp": { + "type": "object", + "properties": { + "enable": { + "type": "boolean", + "default": false + } + } + }, + "service.ieee8021x": { + "type": "object", + "properties": { + "ca-certificate": { + "type": "string" + }, + "use-local-certificates": { + "type": "boolean", + "default": false + }, + "server-certificate": { + "type": "string" + }, + "private-key": { + "type": "string" + }, + "users": { + "type": "array", + "items": { + "$ref": "#/$defs/interface.ssid.radius.local-user" + } + } + } + }, + "service.radius-proxy": { + "type": "object", + "properties": { + "realms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "realm": { + "type": "string", + "default": "*" + }, + "auto-discover": { + "type": "boolean", + "default": false + }, + "host": { + "type": "string", + "format": "uc-host", + "examples": [ + "192.168.1.10" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "default": 2083 + }, + "secret": { + "type": "string" + }, + "use-local-certificates": { + "type": "boolean", + "default": false + }, + "ca-certificate": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "private-key": { + "type": "string" + }, + "private-key-password": { + "type": "string" + } + } + } + } + } + }, + "service.online-check": { + "type": "object", + "properties": { + "ping-hosts": { + "type": "array", + "items": { + "type": "string", + "format": "uc-host", + "examples": [ + "192.168.1.10" + ] + } + }, + "download-hosts": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "www.example.org" + ] + } + }, + "check-interval": { + "type": "number", + "default": 60 + }, + "check-threshold": { + "type": "number", + "default": 1 + }, + "action": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "wifi", + "leds" + ] + } + } + } + }, + "service.open-flow": { + "type": "object", + "properties": { + "controller": { + "type": "string", + "uc-format": "cidr", + "example": "192.168.10.1" + }, + "mode": { + "type": "string", + "enum": [ + "pssl", + "ptcp", + "ssl", + "tcp" + ] + }, + "ca-certificate": { + "type": "string" + }, + "ssl-certificate": { + "type": "string" + }, + "private-key": { + "type": "string" + } + } + }, + "service.data-plane": { + "type": "object", + "properties": { + "ingress-filters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string", + "format": "uc-base64" + } + } + } + } + } + }, + "service.wifi-steering": { + "type": "object", + "properties": { + "mode": { + "type": "string", + "enum": [ + "local", + "cloud" + ], + "examples": [ + "local" + ] + }, + "assoc-steering": { + "type": "boolean", + "default": false + }, + "required-snr": { + "type": "integer", + "default": 0 + }, + "required-probe-snr": { + "type": "integer", + "default": 0 + }, + "required-roam-snr": { + "type": "integer", + "default": 0 + }, + "load-kick-threshold": { + "type": "integer", + "default": 0 + }, + "auto-channel": { + "type": "boolean", + "default": false + } + } + }, + "service.quality-of-service": { + "type": "object", + "properties": { + "upload-rate": { + "type": "integer", + "default": 0 + }, + "download-rate": { + "type": "integer", + "default": 0 + } + } + }, + "service.facebook-wifi": { + "type": "object", + "properties": { + "vendor-id": { + "type": "string" + }, + "gateway-id": { + "type": "string" + }, + "secret": { + "type": "string" + } + } + }, + "service.airtime-policies": { + "type": "object", + "properties": { + "dns-match": { + "type": "array", + "items": { + "type": "string", + "examples": [ + "*.voice.example.com" + ] + } + }, + "dns-weight": { + "type": "integer", + "default": 256 + } + } + }, + "service": { + "type": "object", + "properties": { + "lldp": { + "$ref": "#/$defs/service.lldp" + }, + "ssh": { + "$ref": "#/$defs/service.ssh" + }, + "ntp": { + "$ref": "#/$defs/service.ntp" + }, + "mdns": { + "$ref": "#/$defs/service.mdns" + }, + "rtty": { + "$ref": "#/$defs/service.rtty" + }, + "log": { + "$ref": "#/$defs/service.log" + }, + "http": { + "$ref": "#/$defs/service.http" + }, + "igmp": { + "$ref": "#/$defs/service.igmp" + }, + "ieee8021x": { + "$ref": "#/$defs/service.ieee8021x" + }, + "radius-proxy": { + "$ref": "#/$defs/service.radius-proxy" + }, + "online-check": { + "$ref": "#/$defs/service.online-check" + }, + "open-flow": { + "$ref": "#/$defs/service.open-flow" + }, + "data-plane": { + "$ref": "#/$defs/service.data-plane" + }, + "wifi-steering": { + "$ref": "#/$defs/service.wifi-steering" + }, + "quality-of-service": { + "$ref": "#/$defs/service.quality-of-service" + }, + "facebook-wifi": { + "$ref": "#/$defs/service.facebook-wifi" + }, + "airtime-policies": { + "$ref": "#/$defs/service.airtime-policies" + } + } + }, + "metrics.statistics": { + "type": "object", + "properties": { + "interval": { + "type": "integer" + }, + "types": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "ssids", + "lldp", + "clients" + ] + } + } + } + }, + "metrics.health": { + "type": "object", + "properties": { + "interval": { + "type": "integer", + "minimum": 60 + } + } + }, + "metrics.wifi-frames": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "probe", + "auth", + "assoc", + "disassoc", + "deauth", + "local-deauth", + "inactive-deauth", + "key-mismatch", + "beacon-report", + "radar-detected" + ] + } + } + } + }, + "metrics.dhcp-snooping": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "ack", + "discover", + "offer", + "request", + "solicit", + "reply", + "renew" + ] + } + } + } + }, + "metrics": { + "type": "object", + "properties": { + "statistics": { + "$ref": "#/$defs/metrics.statistics" + }, + "health": { + "$ref": "#/$defs/metrics.health" + }, + "wifi-frames": { + "$ref": "#/$defs/metrics.wifi-frames" + }, + "dhcp-snooping": { + "$ref": "#/$defs/metrics.dhcp-snooping" + } + } + }, + "config-raw": { + "type": "array", + "items": { + "type": "array", + "minItems": 2, + "items": { + "type": "string" + }, + "examples": [ + [ + "set", + "system.@system[0].timezone", + "GMT0" + ], + [ + "delete", + "firewall.@zone[0]" + ], + [ + "delete", + "dhcp.wan" + ], + [ + "add", + "dhcp", + "dhcp" + ], + [ + "add-list", + "system.ntp.server", + "0.pool.example.org" + ], + [ + "del-list", + "system.ntp.server", + "1.openwrt.pool.ntp.org" + ] + ] + } + } + } +} \ No newline at end of file