Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
f18m committed Oct 24, 2024
1 parent 0fcb433 commit 5f4aa06
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ test-docker-image:
--network host \
${IMAGETAG}:localtest

LIVE_CONTAINER_NAME:=dsnmasq-dhcp-test-live

test-docker-image-live:
docker build -f Dockerfile.live -t debug-image-live .
@echo "Starting container of image debug-image-live"
docker run \
--rm \
--name $(LIVE_CONTAINER_NAME) \
-v $(shell pwd)/test-options.json:/data/options.json \
-v $(shell pwd)/test-leases.leases:/data/dnsmasq.leases \
-v $(shell pwd)/test-db.sqlite3:/data/trackerdb.sqlite3 \
Expand All @@ -68,6 +71,18 @@ test-docker-image-live:
INPUT_SCSS:=$(shell pwd)/dhcp-clients-webapp-backend/templates/scss/
OUTPUT_CSS:=$(shell pwd)/dhcp-clients-webapp-backend/templates/

build-css:
build-css-live:
docker run -v $(INPUT_SCSS):/sass/ -v $(OUTPUT_CSS):/css/ -it michalklempa/dart-sass:latest


test-database-show:
sqlite3 test-db.sqlite3 'select * from dhcp_clients;'

test-database-drop:
sqlite3 test-db.sqlite3 'drop table dhcp_clients;'

# this target assumes that you launched 'test-docker-image-live' previously
test-database-add-entry:
docker exec -ti $(LIVE_CONTAINER_NAME) /opt/bin/dnsmasq-dhcp-script.sh add "00:11:22:33:44:57" "192.168.1.250"

test-database-del-entry:
docker exec -ti $(LIVE_CONTAINER_NAME) /opt/bin/dnsmasq-dhcp-script.sh del "00:11:22:33:44:57" "192.168.1.250"
4 changes: 3 additions & 1 deletion dhcp-clients-webapp-backend/templates/dnsmasq-dhcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function processWebSocketEvent(event) {

// clear the table
table_current.clear().draw();
table_past.clear().draw();

message.innerText = "No DHCP clients so far.";

Expand All @@ -168,11 +169,12 @@ function processWebSocketEvent(event) {

// clear the table
table_current.clear().draw();
table_past.clear().draw();

message.innerText = "Internal error. Please report upstream together with Javascript logs.";

} else {
console.log("DEBUG:" + data)
console.log("DEBUG:" + JSON.stringify(data))
console.log("Websocket connection: received " + data.current_clients.length + " current clients from websocket");
console.log("Websocket connection: received " + data.past_clients.length + " past clients from websocket");

Expand Down
4 changes: 2 additions & 2 deletions rootfs/opt/bin/dnsmasq-dhcp-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ON CONFLICT(mac_addr) DO UPDATE SET
EOF

if [[ $? -eq 0 ]]; then
log_info "Client with MAC address $mac_addr has been added/updated successfully."
log_info "Client with mac=$mac_addr, hostname=$hostname has been added/updated successfully."
else
log_error "Failed to add/update client. Expect inconsistencies."
fi
Expand All @@ -102,7 +102,7 @@ EOF
# When dnsmasq receives a HUP signal, the script will be invoked for existing leases with an "old" event.
# """
#
log_info "Triggered with mode=${MODE}, mac=${MAC_ADDRESS}, hostname=${HOSTNAME}"
log_info "*** Triggered with mode=${MODE}, mac=${MAC_ADDRESS}, hostname=${HOSTNAME} ***"
if [[ "$MODE" = "add" ]]; then
read_start_counter
last_seen=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO 8601 UTC format
Expand Down
2 changes: 1 addition & 1 deletion test-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
]
},
"log_dhcp": true,
"log_web_ui": false,
"log_web_ui": true,
"web_ui_port": 8976
}

0 comments on commit 5f4aa06

Please sign in to comment.