Skip to content

Instantly share code, notes, and snippets.

View zmstone's full-sized avatar

zmstone zmstone

View GitHub Profile
@zmstone
zmstone / emqx-config-example-generation-prompt.txt
Last active March 13, 2025 17:35
EMQX Config Example Generation Prompt
You are a helpful assistant that generates HOCON configuration examples based on a provided JSON schema specification and user inputs. Follow these instructions precisely:
Schema Specification
• Each schema is a JSON object representing a “struct” type.
• For every struct, the “fields” object describes its fields and an optional “desc” provides a human-readable description.
• The “paths” array lists dot-separated strings representing all possible configuration paths from the root.
• For each field:
 – The “kind” can be “primitive”, “array”, “struct”, “union”, or “map”.
 – For “struct” types, the “name” field references the sub-struct.
 – Complex types include “array” and “union” (oneOf).
@zmstone
zmstone / 3-emqx-nodes-cluster.sh
Last active January 15, 2025 09:25
Start 3 EMQX nodes to form a cluster
#!/usr/bin/env bash
set -euo pipefail
DEFAULT_IMAGE='emqx:5.8.4'
IMAGE="${1:-$DEFAULT_IMAGE}"
NET='emqx.io'
NODE1="node1.$NET"
NODE2="node2.$NET"
NODE3="node3.$NET"
@zmstone
zmstone / connect-with-jwt.sh
Created July 7, 2024 22:25
Test with JWT authn/authz for EMQX using RSA-public key
#!/bin/bash -e
password="$(python3 ./jwt-gen.py)"
json="$(echo $password | cut -d '.' -f 2)"
echo -n 'using: '
echo "${json}" | base64 -d 2>/dev/null || true
echo
mqttx sub -t 'a/#' -h localhost -p 1883 -i aaa -P "$password" -u pub1
@zmstone
zmstone / gist:b7b21b99b9e80f3081f2ccfeea52883e
Created April 17, 2024 14:39
emqx resource manager inconsistent_cache exception
*** System report during emqx_bridge_v1_compatibility_layer_SUITE:t_scenario_1/1 2024-04-17 16:25:18.258 ***🔗
=WARNING REPORT==== 17-Apr-2024::16:25:18.256973 ===
data: {data,<<"connector:test_bridge_type:bridgev2a">>,
<<"emqx_connector">>,emqx_bridge_v2_test_connector,
always_sync,sync,
#{ssl =>
#{depth => 10,verify => verify_none,
hibernate_after => 5000,enable => false,
log_level => notice,
versions => ['tlsv1.3','tlsv1.2'],
@zmstone
zmstone / connect-with-jwt.sh
Last active June 14, 2024 13:03
Test EMQX v5.5 JWT authentication and authorization (ACL)
#!/bin/bash -e
#password='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InB1YjEiLCJhY2wiOlt7InBlcm1pc3Npb24iOiJhbGxvdyIsImFjdGlvbiI6ImFsbCIsInRvcGljIjoiZXEgYS8jIn1dfQ.skzXjZOPU9jQLGqwvF2wh-Tr0oNN1GBc55NbSylHaQ0'
password="$(python3 ./jwt-gen-token.py)"
json="$(echo $password | cut -d '.' -f 2)"
echo "${json}" | base64 -d 2>/dev/null || true
echo
mqttx sub -t 'a/#' -h localhost -p 1883 -i aaa -P "$password" -u pub1
@zmstone
zmstone / dcd-inspect.erl
Created November 16, 2023 10:00
inspect erlang DCD file
F=fun(Path) -> {ok,Log} = disk_log:open([{file, Path}, {name, tmp}, {mode, read_only}]), {_, L,0} = disk_log:bchunk(Log, start, 100), disk_log:close(Log), [binary_to_term(I) || I <- L] end.
@zmstone
zmstone / emqx-conf-cert-md5-as-user-name.conf
Last active October 3, 2023 15:53
EMQX v5 add a new zone and link a SSL listener to it
## Verified in EMQX 5.3.0
## listeners in addition to the default ones
listeners {
ssl.certhash {
enable = true
# bind to port 8884
bind = 8884
# link it to zone named 'certhash'
zone = certhash
ssl_options {
@zmstone
zmstone / emqx-eralng-dist-on-ipv6.sh
Last active October 7, 2023 16:15
start emqx erlang distribution on ipv6
env EMQX_CLUSTER__PROTO_DIST=inet6_tcp [email protected] bin/emqx console
@zmstone
zmstone / emqx-dashboard-sso.conf
Created September 28, 2023 06:03
emqx v5.3 enable ldap and saml sso
dashboard.sso = {
ldap {
backend = ldap
base_dn = a
enable = false
filter = "(& (objectClass=person) (uid=${username}))"
pool_size = 8
query_timeout = 5000
request_timeout = 10000
server = "localhost:389"
[
{
"fields": [
{
"aliases": [],
"name": "listeners",
"type": {
"kind": "struct",
"name": "broker:listeners"
}