### Start Zenoh Router (Windows) Source: https://zenoh.io/docs/getting-started/installation Navigate to the Zenoh installation directory and start the Zenoh router executable on Windows. ```batch > cd C:\path\to\zenoh\dir > zenohd.exe ``` -------------------------------- ### Start First Peer with QUIC Source: https://zenoh.io/docs/manual/quic Initialize the first peer in a peer-to-peer setup using QUIC. The peer.json5 configuration should be used, and the listen address set to 'quic/localhost:7447'. ```bash $ z_sub -c peer.json5 -l quic/localhost:7447 ``` -------------------------------- ### Start Second Peer with QUIC Source: https://zenoh.io/docs/manual/quic Launch the second peer in a peer-to-peer setup, connecting to the first peer via QUIC. Specify the listen address and the peer's endpoint in the peer.json5 configuration. ```bash $ z_pub -c peer.json5 -l quic/localhost:7448 -e quic/localhost:7447 ``` -------------------------------- ### Start Zenoh Router (macOS) Source: https://zenoh.io/docs/getting-started/installation Command to start the Zenoh router after installation on macOS. ```bash zenohd ``` -------------------------------- ### Start Zenoh Router with Configuration Source: https://zenoh.io/docs/getting-started/first-app Command to start the Zenoh router using a specified configuration file. This enables storage capabilities. ```bash zenohd -c zenoh-myhome.json5 ``` -------------------------------- ### Install Zenoh via apt Source: https://zenoh.io/docs/getting-started/installation Install the Zenoh package using apt on Debian/Ubuntu. ```bash sudo apt install zenoh ``` -------------------------------- ### Start Zenoh Publisher in Client Mode Source: https://zenoh.io/docs/manual/user-password Initialize a Zenoh publisher as a client, using a client configuration file for authentication. ```bash $ z_pub -c client.json5 ``` -------------------------------- ### Start Zenoh Publisher Source: https://zenoh.io/docs/getting-started/first-app Command to run the Python Zenoh publisher script. This starts the process that sends data. ```bash python3 z_sensor.py ``` -------------------------------- ### Start Zenoh Subscriber in Client Mode Source: https://zenoh.io/docs/manual/user-password Initialize a Zenoh subscriber as a client, using a client configuration file for authentication. ```bash $ z_sub -c client.json5 ``` -------------------------------- ### Install Zenoh via Homebrew Source: https://zenoh.io/docs/getting-started/installation Install the Zenoh package using Homebrew on macOS. ```bash brew install zenoh ``` -------------------------------- ### Install Zenoh Python Library Source: https://zenoh.io/docs/getting-started/first-app Install the necessary Python library for Zenoh. This command should be run before using the Zenoh Python API. ```bash pip install eclipse-zenoh ``` -------------------------------- ### Start Zenoh Subscriber Source: https://zenoh.io/docs/getting-started/first-app Command to run the Python Zenoh subscriber script. This starts the process that listens for data. ```bash python3 z_subscriber.py ``` -------------------------------- ### Display Zenohd Help Information Source: https://zenoh.io/docs/getting-started/installation Execute this command to display the help message for the zenohd router. This confirms the installation and shows available configuration options. ```bash $ zenohd --help ``` ```text 2024-08-12T13:27:29.724708Z INFO main ThreadId(01) zenohd: zenohd v0.11.0-dev-965-g764be602d built with rustc 1.75.0 (82e1608df 2023-12-21) The zenoh router Usage: zenohd [OPTIONS] Options: -c, --config The configuration file. Currently, this file must be a valid JSON5 or YAML file -l, --listen Locators on which this router will listen for incoming sessions. Repeat this option to open several listeners -e, --connect A peer locator this router will try to connect to. Repeat this option to connect to several peers -i, --id The identifier (as an hexadecimal string, with odd number of chars - e.g.: A0B23...) that zenohd must use. If not set, a random unsigned 128bit integer will be used. WARNING: this identifier must be unique in the system and must be 16 bytes maximum (32 chars)! -P, --plugin A plugin that MUST be loaded. You can give just the name of the plugin, zenohd will search for a library named 'libzenoh_plugin_.so' (exact name depending the OS). Or you can give such a string: ":" Repeat this option to load several plugins. If loading failed, zenohd will exit --plugin-search-dir Directory where to search for plugins libraries to load. Repeat this option to specify several search directories --no-timestamp By default zenohd adds a HLC-generated Timestamp to each routed Data if there isn't already one. This option disables this feature --no-multicast-scouting By default zenohd replies to multicast scouting messages for being discovered by peers and clients. This option disables this feature --rest-http-port Configures HTTP interface for the REST API (enabled by default on port 8000). Accepted values: - a port number - a string with format `:` (to bind the HTTP server to a specific interface) - `none` to disable the REST API --cfg Allows arbitrary configuration changes as column-separated KEY:VALUE pairs, where: - KEY must be a valid config path. - VALUE must be a valid JSON5 string that can be deserialized to the expected type for the KEY field. Examples: - `--cfg='startup/subscribe:["demo/**"]'` - `--cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'` --adminspace-permissions <[r|w|rw|none]> Configure the read and/or write permissions on the admin space. Default is read only -h, --help Print help (see a summary with '-h') -V, --version Print version ``` -------------------------------- ### Zenoh ACL Configuration Example Source: https://zenoh.io/docs/manual/access-control This is an example of the complete ACL configuration for Zenoh, including enabled status, default permission, rules, subjects, and policies. ACL configuration cannot be updated at runtime and requires a restart. ```json { "access_control": { "enabled": true, "default_permission": "allow", "rules": [ { "id": "deny pub/sub", "permission": "deny", "flows": ["ingress", "egress"], "messages": [ "declare_subscriber", "put", "delete", ], "key_exprs": [ "demo/example/**", ], } ], "subjects": [ { "id": "example subject", "interfaces": [ "lo0", "en0", ], "cert_common_names": [ "example.zenoh.io" ], "usernames": [ "zenoh-example1", "zenoh-example2", ], } ], "policies": [ { "rules": [ "deny pub/sub" ], "subjects": [ "example subject" ], }, ] } } ``` -------------------------------- ### Zenoh Router Plugin Loading Logs Source: https://zenoh.io/docs/getting-started/troubleshooting Example logs showing successfully loaded plugins by the Zenoh router. Check plugin Zenoh versions for compatibility. ```log [2022-03-28T15:23:36Z INFO zenohd] Successfully started plugin rest from "/Users/test/.zenoh/lib/libzplugin_rest.dylib" [2022-03-28T15:23:36Z INFO zenohd] Successfully started plugin storage_manager from "/Users/test/.zenoh/lib/libzplugin_storage_manager.dylib" [2022-03-28T15:23:36Z INFO zenohd] Successfully started plugin webserver from "/Users/test/.zenoh/lib/libzplugin_webserver.dylib" ``` -------------------------------- ### Start First Zenoh Peer in Peer Mode (TLS) Source: https://zenoh.io/docs/manual/tls Initiates the first Zenoh peer in peer mode, listening on a TLS endpoint. ```bash $ z_sub -c peer.json5 -l tls/localhost:7447 ``` -------------------------------- ### Zenoh Selector Syntax Example Source: https://zenoh.io/docs/manual/abstractions Illustrates the structure of a Zenoh selector, separating the key expression from its parameters. ```text path/**/something?arg1=val1;arg2=value%202 ^ ^ ^ ^ |Key Expression-| |----- parameters -----| ``` -------------------------------- ### Zenoh Policy Configuration Source: https://zenoh.io/docs/manual/access-control Associates access control rules with subjects. This example applies the 'deny pub/sub' rule to the 'example subject'. Both rules and subjects are lists, allowing for multiple associations within a single policy. ```json { "rules": [ "deny pub/sub" ], "subjects": [ "example subject" ], } ``` -------------------------------- ### Start Second Zenoh Peer in Peer Mode (TLS) Source: https://zenoh.io/docs/manual/tls Initiates the second Zenoh peer in peer mode, connecting to a remote TLS endpoint. ```bash $ z_pub -c peer.json5 -l tls/localhost:7448 -e tls/localhost:7447 ``` -------------------------------- ### Python Zenoh Publisher Source: https://zenoh.io/docs/getting-started/first-app This script publishes temperature measurements to a specified key every second. Ensure the Zenoh library is installed. ```python import zenoh, random, time random.seed() def read_temp(): return random.randint(15, 30) if __name__ == "__main__": with zenoh.open(zenoh.Config()) as session: key = 'myhome/kitchen/temp' pub = session.declare_publisher(key) while True: t = read_temp() buf = f"{t}" print(f"Putting Data ('{key}': '{buf}')...") pub.put(buf) time.sleep(1) ``` -------------------------------- ### Zenoh Subject Configuration Example Source: https://zenoh.io/docs/manual/access-control Defines a subject with specific interfaces, certificate common names, and usernames. This configuration demonstrates how Zenoh internally translates these to a series of logical AND/OR conditions for matching connecting instances. ```json { "id": "example subject", "interfaces": [ "lo0", "en0", ], "cert_common_names": [ "example.zenoh.io" ], "usernames": [ "zenoh-example1", "zenoh-example2", ], // This instance translates internally to this filter: // (interface="lo0" AND cert_common_name="example.zenoh.io" AND username="zenoh-example1") OR // (interface="lo0" AND cert_common_name="example.zenoh.io" AND username="zenoh-example2") OR // (interface="en0" AND cert_common_name="example.zenoh.io" AND username="zenoh-example1") OR // (interface="en0" AND cert_common_name="example.zenoh.io" AND username="zenoh-example2") } ``` -------------------------------- ### Zenoh Selector Deserialization Example Source: https://zenoh.io/docs/manual/abstractions Shows how a Zenoh selector string is deserialized into a structured object with key expression and parameters. ```json { "key_expr": "path/**/something", "parameters": {"arg1": "val1", "arg2": "value 2"} } ``` -------------------------------- ### Enable REST Plugin with -P Shorthand Source: https://zenoh.io/docs/manual/configuration The -P argument is a shorthand for --cfg='plugins//__required__:true'. This example enables the REST plugin. ```bash zenohd -P rest ``` -------------------------------- ### GET Data with Curl Source: https://zenoh.io/docs/apis/rest Use curl to perform GET requests to retrieve keys and values matching a selector. The results are returned as a JSON array. ```bash # Get the keys/values matching demo/** $ curl http://localhost:8000/demo/** [ { "key": "demo/example/zenoh-python-put", "value": "Put from Python!", "encoding": "text/plain", "time": "2022-03-29T10:19:38.988830998Z/BC99B84DD73D449FB7B5C03506934604" }, { "key": "demo/example/zenoh-c-put", "value": "Put from Python!", "encoding": "text/plain", "time": "2022-03-29T10:19:40.031682968Z/BC99B84DD73D449FB7B5C03506934604" }, { "key": "demo/example/zenoh-rs-put", "value": "Put from Python!", "encoding": "text/plain", "time": "2022-03-29T10:19:45.879540920Z/BC99B84DD73D449FB7B5C03506934604" } ] # Get the keys/values matching demo/example/*eval (i.e. the Zenoh eval examples) # with property name=Bob $ curl http://localhost:8000/demo/example/*eval?(name=Bob) [ { "key": "demo/example/zenoh-rs-eval", "value": "Eval from Bob", "encoding": "text/plain", "time": "None" } ] # Get the list of storages via a Get on admin space (@/...) $ curl -g http://localhost:8000/@/**/storages/** [ { "key": "@/router/BC99B84DD73D449FB7B5C03506934604/status/plugins/storage_manager/storages/demo", "value": {"key_expr":"demo/example/**","volume":"memory"}, "encoding": "application/json", "time": "None" } ] ``` -------------------------------- ### TLS Client Configuration with Certificate Expiration Monitoring Source: https://zenoh.io/docs/manual/tls Example configuration for a TLS client to monitor remote certificate expiration. Ensure `root_ca_certificate` is correctly set. ```json { "mode": "client", "connect": { "endpoints": ["tls/localhost:7447"] }, "transport": { "link": { "tls": { "root_ca_certificate": "/home/user/server/minica.pem", "close_link_on_expiration": true } } } } ``` -------------------------------- ### Zenoh ACL Rule Example Source: https://zenoh.io/docs/manual/access-control This rule denies all incoming and outgoing subscriptions, publications, and deletions on key expressions matching 'demo/example/**'. Rules can be applied to specific message types and flows. ```json { "id": "deny pub/sub", "permission": "deny", "flows": ["ingress", "egress"], "messages": [ "declare_subscriber", "put", "delete", ], "key_exprs": [ "demo/example/**", ], } ``` -------------------------------- ### Tap Zenoh Homebrew Repository Source: https://zenoh.io/docs/getting-started/installation Add the Eclipse Zenoh package repository to your Homebrew installation on macOS. ```bash brew tap eclipse-zenoh/homebrew-zenoh ``` -------------------------------- ### GET Operation Source: https://zenoh.io/docs/apis/rest Binds to the get(selector) operation on Zenoh. Retrieves keys/values matching a given selector. Results are returned as a JSON array of objects containing key, value, encoding, and time. ```APIDOC ## GET ### Description Binds to the **get(selector)** operation on Zenoh. Retrieves keys/values matching a given selector. ### Method GET ### Endpoint `http://host:8000/` ### Parameters #### Path Parameters - **selector** (string) - Required - The Zenoh key expression to match. ### Request Body none ### Response #### Success Response (200) - **key** (string) - The key of the data. - **value** (string) - The value of the data. - **encoding** (string) - The encoding of the value. - **time** (string) - The timestamp associated with the data. ### Response Example ```json [ { "key": "demo/example/zenoh-python-put", "value": "Put from Python!", "encoding": "text/plain", "time": "2022-03-29T10:19:38.988830998Z/BC99B84DD73D449FB7B5C03506934604" } ] ``` ``` -------------------------------- ### Get Router Storages via REST Source: https://zenoh.io/docs/getting-started/quick-test Query the local Zenoh router's status to list configured storages, verifying the recently added memory storage. ```bash curl 'http://localhost:8000/@/local/router/status/plugins/storage_manager/storages/*' ``` -------------------------------- ### TLS Server (Router) Configuration with mTLS and Certificate Expiration Monitoring Source: https://zenoh.io/docs/manual/tls Example configuration for a router acting as a TLS server with mTLS enabled, monitoring remote certificate expiration. Requires `listen_private_key` and `listen_certificate`. ```json { "mode": "router", "listen": { "endpoints": ["tls/localhost:7447"] }, "transport": { "link": { "tls": { "root_ca_certificate": "/home/user/client/minica.pem", "listen_private_key": "/home/user/server/localhost/key.pem", "listen_certificate": "/home/user/server/localhost/cert.pem", "enable_mtls": true, "close_link_on_expiration": true } } } } ``` -------------------------------- ### Long-lived GET with Server-Sent Events Source: https://zenoh.io/docs/apis/rest Use the `Accept: text/event-stream` header to establish a long-lived connection for receiving updates matching a key expression. ```bash # Example not provided in source, but the concept is described. ``` -------------------------------- ### Python Zenoh Get Query Source: https://zenoh.io/docs/getting-started/first-app This script retrieves the latest stored value for a specific key expression from Zenoh. It handles both successful replies and errors. ```python import zenoh if __name__ == "__main__": with zenoh.open(zenoh.Config()) as session: replies = session.get('myhome/kitchen/temp') for reply in replies: try: print("Received ('{}': '{}')" .format(reply.ok.key_expr, reply.ok.payload.to_string())) except: print("Received (ERROR: '{}')" .format(reply.err.payload.to_string())) ``` -------------------------------- ### Peer TLS Configuration Source: https://zenoh.io/docs/manual/tls Configure a peer with TLS settings, including a root CA certificate for authenticating other peers and certificates for its own incoming TLS sessions. This setup is crucial for secure peer-to-peer communication. ```json { /// The node's mode (router, peer or client) "mode": "peer", "transport": { "link": { "tls": { "root_ca_certificate": "/home/user/tls/minica.pem", "listen_private_key": "/home/user/tls/localhost/key.pem", "listen_certificate": "/home/user/tls/localhost/cert.pem" } } } } ``` -------------------------------- ### Get Local Zenoh Router Info via REST Source: https://zenoh.io/docs/getting-started/quick-test Retrieve information about the local Zenoh router using its REST API. This is useful for verifying the router is running and accessible. ```bash curl http://localhost:8000/@/local/router ``` -------------------------------- ### Update Storage Manager Configuration via REST Source: https://zenoh.io/docs/manual/configuration Use cURL to send a PUT request to the Zenoh REST API to update the storage manager configuration. This example adds a new storage with a specified key expression and memory volume. ```bash curl -X PUT http://localhost:8000/@/local/router/config/plugins/storage_manager/storages/my-storage -d '{key_expr:"demo/mystore/**", volume:{id:"memory"}}' ``` -------------------------------- ### Create TLS Certificates Directory Source: https://zenoh.io/docs/manual/tls Creates a directory to store TLS certificates for Zenoh. ```bash $/home/user: mkdir tls ``` ```bash $/home/user: cd tls ``` ```bash $/home/user/tls: pwd /home/user/tls ``` -------------------------------- ### List TLS Certificate Files Source: https://zenoh.io/docs/manual/tls Lists the generated TLS certificate and key files. ```bash $/home/user/tls: ls localhost minica-key.pem minica.pem ``` -------------------------------- ### Configure QUIC Multistream Source: https://zenoh.io/docs/manual/quic Enable QUIC multistream by setting `multistream=[auto|0|1]` in endpoint parameters. `auto` allows negotiation, while `1` forces multistream usage. This optimizes resource usage by mapping Zenoh priorities to QUIC streams. ```json { "connect": { "endpoints": ["quic/localhost:7447?multistream=1"] }, } ``` -------------------------------- ### Python Zenoh Subscriber Source: https://zenoh.io/docs/getting-started/first-app This script subscribes to temperature measurements and prints received data. It listens on the 'myhome/kitchen/temp' key. ```python import zenoh, time def listener(sample): print(f"Received {sample.kind} ('{sample.key_expr}': '{sample.payload.to_string()}')") if __name__ == "__main__": with zenoh.open(zenoh.Config()) as session: sub = session.declare_subscriber('myhome/kitchen/temp', listener) time.sleep(60) ``` -------------------------------- ### Enable REST Plugin with --rest-http-port Source: https://zenoh.io/docs/manual/configuration Use the --rest-http-port argument to enable the REST plugin and specify the HTTP port. ```bash zenohd --rest-http-port=8000 ``` -------------------------------- ### List Localhost Specific TLS Certificate Files Source: https://zenoh.io/docs/manual/tls Lists the server certificate and private key files within the 'localhost' directory. ```bash $/home/user/tls: ls localhost cert.pem key.pem ``` -------------------------------- ### Mount Zenoh Plugins/Backends in Docker Source: https://zenoh.io/docs/getting-started/quick-test Run a Zenoh router in Docker and mount a local directory for plugins and backends. Libraries must be compiled for `x86_64-unknown-linux-musl`. ```bash docker run --init -p 7447:7447/tcp -p 8000:8000/tcp -v $(pwd)/zenoh-docker:/root/.zenoh eclipse/zenoh ``` -------------------------------- ### Client Mode with Scouting Configuration Source: https://zenoh.io/docs/getting-started/deployment Configure Zenoh in client mode with explicit endpoints for connecting to specific Zenoh nodes, in addition to multicast scouting. ```json { "mode": "client", "connect": { "endpoints": ["tcp/192.168.1.1:7447", "tcp/192.168.1.2:7447"], }, } ``` -------------------------------- ### Add Zenoh apt Repository Source: https://zenoh.io/docs/getting-started/installation Add the Eclipse Zenoh private repository to your apt sources list on Debian/Ubuntu. ```bash echo "deb [signed-by=/etc/apt/keyrings/zenoh-public-key.gpg] https://download.eclipse.org/zenoh/debian-repo/ /" | sudo tee -a /etc/apt/sources.list > /dev/null sudo apt update ``` -------------------------------- ### List IP Address Specific TLS Certificate Files Source: https://zenoh.io/docs/manual/tls Lists the generated TLS certificate and key files for an IP address. ```bash $/home/user/server/tls: ls 127.0.0.1 minica-key.pem minica.pem ``` -------------------------------- ### Long-lived (SSE) GET Operation Source: https://zenoh.io/docs/apis/rest Binds to the declare_subscriber(key_expression) operation on Zenoh. Establishes a Server-Sent Events connection to receive continuous updates for matching key expressions. ```APIDOC ## Long-lived (SSE) GET ### Description Binds to the **declare_subscriber(key_expression)** operation on Zenoh. Establishes a Server-Sent Events connection to receive continuous updates for matching key expressions. ### Method GET ### Endpoint `http://host:8000/` ### Headers - **Accept**: `text/event-stream` ### Response - The connection will be upgraded to an SSE (Server-Sent Events), letting Zenoh keep on forwarding samples matching your key expressions in JSON format. ``` -------------------------------- ### Add Memory Storage via REST Source: https://zenoh.io/docs/getting-started/quick-test Configure a memory storage for a specific key expression (`demo/example/**`) on the local Zenoh router using the REST API. ```bash curl -X PUT -H 'content-type:application/json' -d '{key_expr:"demo/example/**", volume: "memory"}' http://localhost:8000/@/local/router/config/plugins/storage_manager/storages/demo ``` -------------------------------- ### Client Mode Configuration Source: https://zenoh.io/docs/getting-started/deployment Configure Zenoh to operate in client mode, maintaining a single session with a Zenoh daemon for system connectivity. ```json { "mode": "client", } ``` -------------------------------- ### Run Zenoh Router with Host Networking Source: https://zenoh.io/docs/getting-started/quick-test Deploy a Zenoh router in a Docker container using host networking. This is necessary for UDP multicast support on Linux. ```bash docker run --init --net=host eclipse/zenoh ``` -------------------------------- ### Router/Peer Configuration for User-Password Auth Source: https://zenoh.io/docs/manual/user-password Configure routers or peers with user credentials and a dictionary file for authenticating incoming connections. ```json { /// The node's mode (router, peer or client) mode: "router", transport: { auth: { /// The configuration of authentication. usrpwd: { user: "routerusername", password: "routerpassword", /// The path to a file containing the user password dictionary dictionary_file: "credentials.txt", }, }, }, } ``` -------------------------------- ### Run Zenoh Router in Docker Source: https://zenoh.io/docs/getting-started/quick-test Deploy a Zenoh router instance in a Docker container. This command exposes the Zenoh protocol (TCP) and REST API ports. ```bash docker run --init -p 7447:7447/tcp -p 8000:8000/tcp eclipse/zenoh ``` -------------------------------- ### Configure Multicast Scouting in Peer Mode Source: https://zenoh.io/docs/getting-started/deployment Enable and configure multicast scouting for Zenoh applications in 'peer' mode. This allows applications to discover and connect to local peers and routers using a specified multicast address and port. ```json { "mode": "peer", "scouting": { "multicast": { "enabled": true, "address": "224.0.0.224:7446", "interface": "auto", "autoconnect": { "router": [], "peer": ["router", "peer"] }, "listen": true, }, }, } ``` -------------------------------- ### Add Zenoh GPG Key for apt Source: https://zenoh.io/docs/getting-started/installation Add the Eclipse Zenoh public GPG key to your system's apt keyring for secure package management on Debian/Ubuntu. ```bash curl -L https://download.eclipse.org/zenoh/debian-repo/zenoh-public-key | sudo gpg --dearmor --yes --output /etc/apt/keyrings/zenoh-public-key.gpg ``` -------------------------------- ### Configure Adminspace Permissions in File Source: https://zenoh.io/docs/manual/configuration Set read and write permissions for the admin space in the configuration file. This allows runtime modifications to the Zenoh router's configuration. ```json { adminspace: { permissions: { read: true, write: true } } } ``` -------------------------------- ### Zenoh Router Docker Compose Configuration Source: https://zenoh.io/docs/getting-started/quick-test A Docker Compose file to configure and run the Zenoh router, including volume mounting for plugins and setting the log level to debug. ```yaml version: "3.9" services: zenoh: image: eclipse/zenoh restart: unless-stopped ports: - 7447:7447 - 8000:8000 volumes: - ./zenoh_docker:/root/.zenoh environment: - RUST_LOG=debug ``` -------------------------------- ### Configure Gossip Scouting with Connection Endpoints Source: https://zenoh.io/docs/getting-started/deployment Enable gossip scouting in 'peer' mode and specify connection endpoints for initial discovery. This is useful when multicast is unavailable, requiring an entry point to discover the network. ```json { "mode": "peer", "connect": { "endpoints": ["tcp/192.168.1.1:7447", "tcp/192.168.1.2:7447"], }, "scouting": { "gossip": { "enabled": true, "multihop": false, "autoconnect": { "router": [], "peer": ["router", "peer"] }, }, }, } ``` -------------------------------- ### Hashing Passwords with SHA-256 Source: https://zenoh.io/docs/manual/user-password Compute SHA-256 hashes for client and router passwords to enhance security. ```bash $ echo clientpassword | sha256sum 92df0d4f39c218607e3200bf93ccac87a80cb910e811d84b286bebe0a8860724 $ echo routerpassword | sha256sum 2ce01a11893f276a4064f586f24b8f1868008e2e623f6c4e74ef381247e49df1 ``` -------------------------------- ### Configure Zenoh for Peer-to-Peer Mode Source: https://zenoh.io/docs/getting-started/deployment Set the Zenoh communication mode to 'peer' for direct application-to-application communication within a local network. ```json { "mode": "peer", } ``` -------------------------------- ### Credentials File with Hashed Passwords Source: https://zenoh.io/docs/manual/user-password Update the credentials file to contain user and their corresponding hashed passwords. ```text clientusername:92df0d4f39c218607e3200bf93ccac87a80cb910e811d84b286bebe0a8860724 ``` -------------------------------- ### Generate TLS Certificate for Localhost Domain Source: https://zenoh.io/docs/manual/tls Generates a TLS certificate for the 'localhost' domain using minica. ```bash $/home/user/tls: minica --domains localhost ``` -------------------------------- ### Make a generic PUT request with fetch Source: https://zenoh.io/docs/manual/plugin-storage-manager This JavaScript snippet demonstrates how to make a generic PUT request using the fetch API. It sets the method, headers, and body, including stringifying the JSON data. ```javascript fetch('http://hostname:8000/key/expression', { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({some: ["json", "data"]}) }) ``` -------------------------------- ### Client Configuration for User-Password Auth Source: https://zenoh.io/docs/manual/user-password Use this configuration for Zenoh clients to authenticate with a router or peer using provided username and password. ```json { /// The node's mode (router, peer or client) mode: "client", transport: { auth: { /// The configuration of authentication. /// A password implies a username is required. usrpwd: { user: "clientusername", password: "clientpassword", }, }, }, } ``` -------------------------------- ### Client Configuration with Hashed Password Source: https://zenoh.io/docs/manual/user-password Update client configuration to use a hashed password for authentication. ```json { /// The node's mode (router, peer or client) mode: "client", transport: { auth: { /// The configuration of authentication. /// A password implies a username is required. usrpwd: { user: "clientusername", password: "92df0d4f39c218607e3200bf93ccac87a80cb910e811d84b286bebe0a8860724", }, }, }, } ``` -------------------------------- ### Zenoh Router Configuration for Storage Source: https://zenoh.io/docs/getting-started/first-app JSON5 configuration file to enable and configure the storage manager plugin for Zenoh router. This allows data to be stored. ```json { plugins: { rest: { // activate and configure the REST plugin http_port: 8000 // with HTTP server listening on port 8000 }, storage_manager: { // activate and configure the storage_manager plugin storages: { myhome: { // configure a "myhome" storage key_expr: "myhome/**", // which subscribes and replies to query on myhome/** volume: { // and using the "memory" volume (always present by default) id: "memory" } } } } } } ``` -------------------------------- ### Storage Manager Configuration Schema Source: https://zenoh.io/docs/manual/plugin-storage-manager Defines the structure for configuring storage backends and volumes. Use this schema to set up unique volume names, specify backend associations, and configure storage key expressions and volume dependencies. ```json { // Search directories when backends are requested by name backend_search_dirs?: string | string[], // The list of volumes that must be created volumes: { // All volumes on a Zenoh node must have unique names "": { // The name of the backend this volume should run on. If unspecified, it defaults to the name of the volume. backend?: string, // Much like for plugins, if a list of paths is configured, the backend will be run using the first path pointing to a loadable library. // If unspecified, name-based lookup will be used instead. __path__?: string | string[], // backends may have options specific to them, such as `url` for the influxdb backends ...backend_specifics: any, } }, storages: { // All storages must also have unique names. "": { // The key expression that the storage should be set up for, such as "demo/storage/**" key_expr: string, // A prefix of `key_expr` that should be stripped from it when storing keys in the storage strip_prefix?: string, // Storages depend on a volume to do the actual storing of data. // `volume: "memory"` is equivalent to `volume: {id: "memory"}`, but some volumes may require additional configuration. For example, a volume running on the `filesystem` backend needs each storage to specify a `base_dir`. volume: string | { id: string, ...configuration: any} } } } ``` -------------------------------- ### Authorized Credentials File Format Source: https://zenoh.io/docs/manual/user-password Define authorized user credentials in a text file, with each line containing a 'user:password' pair. ```text clientusername:clientpassword ``` -------------------------------- ### Add a storage to the memory volume with curl Source: https://zenoh.io/docs/manual/plugin-storage-manager This command adds a storage named 'my-storage' that uses the integrated 'memory' volume. It maps the key expression 'demo/my-storage/**' to this volume. ```bash curl -X PUT 'http://hostname:8000/@/local/router/config/plugins/storage_manager/storages/my-storage' -H 'content-type:application/json' -d '{"key_expr": "demo/my-storage/**", "volume": "memory"}' ``` -------------------------------- ### Activate Zenoh Logging with RUST_LOG Source: https://zenoh.io/docs/getting-started/troubleshooting Control Zenoh logging levels using the RUST_LOG environment variable. Logs are written to stderr. ```bash export RUST_LOG=trace ``` -------------------------------- ### Router TLS Configuration Source: https://zenoh.io/docs/manual/tls Configure a router to use specific TLS certificates for incoming connections. Ensure the private key and certificate files are correctly specified. ```json { /// The node's mode (router, peer or client) "mode": "router", "listen": { "endpoints": ["tls/localhost:7447"] }, "transport": { "link": { "tls": { "listen_private_key": "/home/user/tls/localhost/key.pem", "listen_certificate": "/home/user/tls/localhost/cert.pem" } } } } ``` -------------------------------- ### Generate TLS Certificate for IP Address Source: https://zenoh.io/docs/manual/tls Generates TLS certificates associated with an IP address using minica. ```bash $/home/user/server/tls: minica --ip-addresses 127.0.0.1 ``` -------------------------------- ### Configure Unsecure QUIC Endpoint Source: https://zenoh.io/docs/manual/quic Use this configuration to expose an unsecure QUIC endpoint by setting the UDP endpoint's reliability parameter to '1'. No TLS certificates or keys are required. ```json { "connect": { "endpoints": ["udp/localhost:7447?rel=1"] }, } ``` -------------------------------- ### PUT Data with Curl Source: https://zenoh.io/docs/apis/rest Use curl with the -X PUT option to publish data to a specified key expression. The `content-type` header determines how the value is encoded. ```bash # Put a string value in demo/example/test curl -X PUT -H "content-type:text/plain" -d 'Hello World!' http://localhost:8000/demo/example/test # Put a JSON value in demo/example/json curl -X PUT -H "content-type:application/json" -d '{"value": "Hello World!"}' http://localhost:8000/demo/example/test # Create a Memory storage on demo/test/** via a Put on admin space (@/...) curl -X PUT -H 'content-type:application/json' http://localhost:8000/@/local/router/config/plugins/storage_manager/storages/demo -d '{key_expr:"demo/test/**", volume:"memory"}' ``` -------------------------------- ### Make a generic PUT request with curl Source: https://zenoh.io/docs/manual/plugin-storage-manager Use this command to make a generic PUT request to a target URL. It includes a JSON content type header and a JSON data payload. ```bash curl -X PUT 'http://hostname:8000/key/expression' -H 'content-type:application/json' -d '{"some": ["json", "data"]}' ``` -------------------------------- ### Adding a Storage Source: https://zenoh.io/docs/manual/plugin-storage-manager Use a PUT request to add a new storage to a volume. You can specify the key expression and volume details. ```APIDOC ## PUT /@/local/router/config/plugins/storage_manager/storages/{storage_name} ### Description Adds a new storage to the storage manager configuration. ### Method PUT ### Endpoint `/@/local/router/config/plugins/storage_manager/storages/{storage_name}` ### Parameters #### Path Parameters - **storage_name** (string) - Required - The name of the storage to add. #### Request Body - **key_expr** (string) - Required - The key expression that this storage will handle. - **volume** (object|string) - Required - Specifies the volume to use for this storage. Can be a string representing the volume ID (e.g., "memory") or an object with volume details like `id` and `db` for more complex configurations. ### Request Example (using memory volume) ```json { "key_expr": "demo/my-storage/**", "volume": "memory" } ``` ### Request Example (using a configured volume) ```json { "key_expr": "demo/my-other-storage/**", "volume": { "id": "my-volume", "db": "MyOtherStorage" } } ``` ### Response #### Success Response (200) Indicates the storage was successfully added or updated. ``` -------------------------------- ### Router Configuration with Hashed Password Source: https://zenoh.io/docs/manual/user-password Update router configuration to use a hashed password and a credentials file with hashed passwords. ```json { /// The node's mode (router, peer or client) mode: "router", transport: { auth: { /// The configuration of authentication. usrpwd: { user: "routerusername", password: "2ce01a11893f276a4064f586f24b8f1868008e2e623f6c4e74ef381247e49df1", /// The path to a file containing the user password dictionary dictionary_file: "credentials.txt", }, }, }, } ``` -------------------------------- ### Edit zenohd Configuration with --cfg Source: https://zenoh.io/docs/manual/configuration Use the --cfg argument to modify specific configuration values without creating a new file. Values must be JSON5-deserializable. Enclose the PATH:VALUE pair in single quotes to prevent parsing errors. ```bash zenohd --cfg='plugins/example-plugin/example/path:"some_value"' ``` ```bash zenohd --cfg='net/addresses/0:"tcp/127.0.0.1:7443"' ``` -------------------------------- ### Zenoh Wildcard Subject Configuration Source: https://zenoh.io/docs/manual/access-control An empty subject configuration that acts as a wildcard, matching any Zenoh instance. This is achieved by omitting the lists for interfaces, certificate common names, and usernames. ```json { "id": "subject that matches all zenoh instances", } ``` -------------------------------- ### Configure QUIC Unreliable Datagrams Source: https://zenoh.io/docs/manual/quic Set `rel=0` in QUIC endpoints to enable unreliable datagrams. The `initial_mtu` can be configured to optimize datagram size. Ensure both endpoints use the same mode (datagram or streamed). ```json { "connect": { "endpoints": ["quic/localhost:7447?rel=0#initial_mtu=1200"] }, } ``` -------------------------------- ### Enable Mixed Reliability and Multistream QUIC Source: https://zenoh.io/docs/manual/quic Combine mixed reliability with multistream QUIC by including both `multistream=1` and `mixed_rel=1` in the endpoint configuration. This allows for advanced QUIC features alongside selective message reliability. ```json { "connect": { "endpoints": ["quic/localhost:7447?multistream=1;mixed_rel=1"] }, } ``` -------------------------------- ### Client Configuration for mTLS Source: https://zenoh.io/docs/manual/tls Configure the client for mutual TLS by setting 'enable_mtls' to true. Provide the CA certificate for server validation and the client's own certificate and key for authentication. ```json { "mode": "client", "connect": { "endpoints": ["tls/localhost:7447"] }, "transport": { "link": { "tls": { "root_ca_certificate": "/home/user/server/minica.pem", "enable_mtls": true, "connect_private_key": "/home/user/client/localhost/key.pem", "connect_certificate": "/home/user/client/localhost/cert.pem" } } } } ``` -------------------------------- ### Put Key/Value into Zenoh via REST Source: https://zenoh.io/docs/getting-started/quick-test Store a plain text key/value pair into Zenoh using the REST API. This assumes a storage has been configured for the target key expression. ```bash curl -X PUT -H 'content-type:text/plain' -d 'Hello World!' http://localhost:8000/demo/example/test ``` -------------------------------- ### Configure Zenoh to Use Only TLS Protocols Source: https://zenoh.io/docs/manual/tls To ensure all connections use TLS, configure the protocols filter to whitelist only 'tls'. This setting applies to both accepting and opening sessions. ```json { "transport": { "link": { "protocols": ["tls"] } } } ``` -------------------------------- ### Adding a Volume Source: https://zenoh.io/docs/manual/plugin-storage-manager Use a PUT request to add a new volume to the storage manager configuration. You can specify the backend and URL for the volume. ```APIDOC ## PUT /@/local/router/config/plugins/storage_manager/volumes/{volume_name} ### Description Adds a new volume to the storage manager configuration. ### Method PUT ### Endpoint `/@/local/router/config/plugins/storage_manager/volumes/{volume_name}` ### Parameters #### Path Parameters - **volume_name** (string) - Required - The name of the volume to add. #### Request Body - **backend** (string) - Optional - The type of backend for the volume (e.g., "influxdb", "memory"). If omitted for certain backends like influxdb, it might be inferred from the volume name. - **url** (string) - Required - The URL of the storage backend. ### Request Example ```json { "backend": "influxdb", "url": "http://localhost:8086" } ``` ### Response #### Success Response (200) Indicates the volume was successfully added or updated. ```