Added local-dev broker and golang lib
parent
6d291906e7
commit
34e2dd11b2
@ -0,0 +1 @@
|
|||||||
|
passwd
|
@ -0,0 +1,2 @@
|
|||||||
|
allow_anonymous false
|
||||||
|
password_file /etc/mosquitto/passwd
|
@ -0,0 +1,11 @@
|
|||||||
|
start-dev:
|
||||||
|
docker compose up -d
|
||||||
|
.PHONEY: start-dev
|
||||||
|
|
||||||
|
stop-dev:
|
||||||
|
docker compose down
|
||||||
|
.PHONEY: stop-dev
|
||||||
|
|
||||||
|
install-dev-deps:
|
||||||
|
python3 -m pip install pre-commit
|
||||||
|
.PHONEY: install-dev-dep
|
@ -0,0 +1,14 @@
|
|||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
mosquitto:
|
||||||
|
image: eclipse-mosquitto:latest
|
||||||
|
hostname: mosquitto
|
||||||
|
container_name: mosquitto
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "1883:1883"
|
||||||
|
- "9001:9001"
|
||||||
|
volumes:
|
||||||
|
- ./.mosquitto:/etc/mosquitto
|
||||||
|
- ./.mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
|
@ -1,3 +1,10 @@
|
|||||||
module git.runcible.io/learning/learn_mqtt_go
|
module git.runcible.io/learning/learn_mqtt_go
|
||||||
|
|
||||||
go 1.23.1
|
go 1.23.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/eclipse/paho.mqtt.golang v1.5.0 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
|
golang.org/x/net v0.27.0 // indirect
|
||||||
|
golang.org/x/sync v0.7.0 // indirect
|
||||||
|
)
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
github.com/eclipse/paho.mqtt.golang v1.5.0 h1:EH+bUVJNgttidWFkLLVKaQPGmkTUfQQqjOsyvMGvD6o=
|
||||||
|
github.com/eclipse/paho.mqtt.golang v1.5.0/go.mod h1:du/2qNQVqJf/Sqs4MEL77kR8QTqANF7XU7Fk0aOTAgk=
|
||||||
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||||
|
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||||
|
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||||
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$(dirname "$0")/common.sh"
|
||||||
|
|
||||||
|
USER="$1"
|
||||||
|
PASSWD="$2"
|
||||||
|
|
||||||
|
if [ -z "$USER" ]; then
|
||||||
|
echo "Error must provide a user name as first argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PASSWD" ]; then
|
||||||
|
echo "Error must provide a user name as first argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking Mosquitto is running..."
|
||||||
|
if ! check_port 1883 || ! check_port 9001; then
|
||||||
|
echo "Mosquitto port 1883 or 9001 not found running"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Adding Mosquitto user ${USER}"
|
||||||
|
docker exec mosquitto mosquitto_passwd -b /etc/mosquitto/passwd "${USER}" "${PASSWD}"
|
||||||
|
|
||||||
|
echo "User added!"
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
check_port(){
|
||||||
|
port=$1
|
||||||
|
if ss -tuln | grep -q ":$port ";then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$(dirname "$0")/common.sh"
|
||||||
|
|
||||||
|
echo "Checking Mosquitto is running..."
|
||||||
|
if ! check_port 1883 || ! check_port 9001; then
|
||||||
|
echo "Mosquitto port 1883 or 9001 not found running"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Updating ./.mosquitto/passwd plaintext to use hashed passwords"
|
||||||
|
docker exec mosquitto mosquitto_passwd -U /etc/mosquitto/passwd
|
||||||
|
|
||||||
|
echo "Update complete please restart Mosquitto service"
|
Loading…
Reference in New Issue