Commit graph

29 commits

Author SHA1 Message Date
abde949455
feat: show build date on agent startup
Inject build timestamp via ldflags during Docker build so the
agent logs when the binary was compiled.
2026-03-24 12:56:11 -05:00
f35be66148
fix ICMP ping in Docker by trying raw sockets before unprivileged UDP
The old code only tried unprivileged UDP ICMP (udp4), which relies on
the ping_group_range sysctl — not CAP_NET_RAW. Docker doesn't set that
sysctl, so pings always timed out and fell through to exec. Now tries
raw ICMP sockets (ip4:icmp) first, which properly uses CAP_NET_RAW.
Also sets cap_net_raw+ep on the agent binary in the Dockerfile.
2026-02-12 11:18:21 -06:00
39641b73d4
enable ping in docker container for non-root user
add libcap and setcap cap_net_raw+p on /bin/ping so ICMP works
without container-level capabilities. add NET_RAW cap_add to
docker-compose.example.yml as fallback.
2026-02-11 10:58:30 -06:00
a757bd7615
Optimize CI caching for Blacksmith runners, fix SNMP bulk walk on Mikrotik
- Dockerfile: add BuildKit cache mounts for Go module and build caches,
  pin both stages to Alpine 3.23
- CI: replace BUILDKIT_INLINE_CACHE with registry-based layer caching
  (mode=max) for branch and release builds
- .dockerignore: exclude test files, Rust legacy, nix, and other
  non-build artifacts from Docker context
- SNMP: lower MaxRepetitions from default 50 to 10 to prevent Mikrotik
  routers from timing out during bulk walks
2026-02-11 10:31:10 -06:00
769ac1f623
Full rewrite in golang 2026-02-11 10:04:30 -06:00
a9bf0b0f8b
Switch from Alpine (musl) to Debian slim (glibc) to fix SNMP SIGSEGV
musl libc has weak fork-safety guarantees in multi-threaded processes.
When Tokio's runtime is running and we fork() for SNMP operations, musl's
internal state can be inconsistent in the child, causing SIGSEGV on every
SNMP walk to Ubiquiti devices. glibc handles this via pthread_atfork.

- Dockerfile: Alpine → rust:1.93-bookworm build + debian:12-slim runtime
- CI: Remove ensure-netsnmp-base/manifest jobs, simplify build deps
- Delete Dockerfile.netsnmp and netsnmp-base.yml workflow
- Add NULL pointer guards in snmp_helper.c for fork-safety
- Add SNMP exception type handling (NoSuchObject/Instance/EndOfMibView)
- Add crash reproduction tests
2026-02-11 08:41:06 -06:00
2386f0d5a5
Upgrade net-snmp to 5.9.5.2 to fix SIGSEGV in SNMP walks
Alpine 3.23 ships net-snmp 5.9.4 which has segfault bugs in varbind
construction and buffer overflows in octet string handling. Version
5.9.5.2 fixes these issues.

Adds a pre-built base image (Dockerfile.netsnmp) compiled from source
so the net-snmp build doesn't run on every agent deploy. The base
image is built separately via the netsnmp-base workflow and referenced
in the main Dockerfile.
2026-02-10 17:58:43 -06:00
29b94c09d4
Fix segfault from Alpine version mismatch, add crash handler
The builder (rust:1.93-alpine) uses Alpine 3.23 but the runtime used
Alpine 3.19. The net-snmp-dev headers from 3.23 don't match
net-snmp-libs from 3.19, causing a segfault on the first SNMP call.

Also adds a SIGSEGV/SIGBUS/SIGABRT signal handler that prints a
diagnostic message instead of silently exiting with code 139.
2026-02-10 14:14:07 -06:00
b0f3b57671
Add restart and self-update handlers, publish standalone binaries
Handle server-initiated restart (exit for Docker restart) and
self-update (download binary, verify SHA256, replace via exec)
commands received over the WebSocket channel. Report architecture
in heartbeat so the server can select the correct binary.

- Add restart and update handlers in websocket_client.rs
- Add self_update() with download, checksum verification, and exec
- Add arch field to AgentHeartbeat protobuf
- Add reqwest and sha2 dependencies
- chown binary in Dockerfile for non-root self-update
- Extract standalone binaries from Docker images in CI
- Create GitHub Releases with binary assets on version tags
2026-02-10 13:06:23 -06:00
2d94f82832
Change Dockerfile to use CMD instead of ENTRYPOINT for Dokku compatibility 2026-02-09 13:29:55 -06:00
71489a709a
copy new native code in to docker build 2026-02-09 12:46:34 -06:00
792825f682
major overhaul to use more C for snmp, may not be stable 2026-02-09 12:31:41 -06:00
5811bed1b1
Add needed packages to Dockerfile 2026-02-04 08:02:59 -06:00
6f1261b0ce
bump rust version and crates 2026-02-04 07:54:12 -06:00
0f19518065
snmpv3 first stab 2026-02-03 16:46:19 -06:00
d24c712ed8
bump rust version 2026-02-02 17:14:28 -06:00
be054323a6
more caching in github ci 2026-01-31 16:53:25 -06:00
cf08b0589b
cleanup 2026-01-24 12:43:24 -06:00
ee7ce7fe00
feat: use system ping instead of raw ICMP sockets
- Replace raw ICMP socket implementation with system ping command
- Add regex-lite dependency for parsing ping output
- Add tokio process feature for async command execution
- Support macOS and Linux ping output formats
- Add iputils to Dockerfile for setuid-root ping
- Remove socket2 dependency (no longer needed)

This eliminates the need for CAP_NET_RAW capability in containers.
2026-01-21 13:11:24 -06:00
c0fe57cd44
fix: properly inject version into Docker image builds
The agent version was always showing 0.1.0 because build.rs tried to
run 'git describe' inside the Docker build, but .git directory wasn't
copied into the image.

Changes:
- Add VERSION build arg to Dockerfile
- Pass VERSION as env var to cargo build commands
- Update GitLab CI to pass --build-arg VERSION
- Modify build.rs to prefer BUILD_VERSION env var over git commands

This ensures the version displayed by the agent matches the Docker
image tag it was built with.
2026-01-19 15:31:26 -06:00
570a37ffc0
Switch from native-tls to rustls for WebSocket TLS
- Removes OpenSSL dependency entirely
- Uses pure Rust TLS implementation (rustls)
- Simplifies Docker build (no OpenSSL packages needed)
- Fixes Alpine musl build compatibility issues
2026-01-16 17:43:53 -06:00
677c948f31
Add OpenSSL build dependencies to Dockerfile
Fixes build failure caused by missing openssl-dev and openssl-libs-static
packages needed for compiling tokio-tungstenite with native-tls feature
2026-01-16 17:41:11 -06:00
824f4388eb
Add automatic self-update capability to agent
The agent now checks for updates every hour and automatically updates
itself when a new version is available on Docker Hub.

Features:
- Periodic update checks (hourly via scheduler)
- Automatic Docker image pull when update available
- Graceful exit and restart with new version
- Non-blocking, runs in background task
- Requires Docker socket mount for self-update

Changes:
- Add UpdateInfo struct and get_update_info() function
- Add perform_self_update() to pull new image and restart
- Add update check ticker to scheduler (hourly)
- Include docker-cli in Dockerfile runtime stage
- Update docker-compose.example.yml with socket mount
- Update README and CLAUDE.md with auto-update docs

The agent will log update status:
- "Already running latest version" - no action
- "Performing self-update: X -> Y" - pulling new image
- "Exiting to allow restart with new version" - restarting

Requires:
- Docker socket mounted: /var/run/docker.sock:/var/run/docker.sock
- restart: unless-stopped in docker-compose (to restart after exit)
2026-01-14 16:50:32 -06:00
7e2e50a764
Fix Docker permissions with automatic entrypoint script
The Docker container now handles data directory permissions automatically
without requiring manual user setup.

Changes:
- Added entrypoint.sh script that runs as root, fixes /data permissions,
  then drops to non-root user (towerops) using su-exec
- Updated Dockerfile to install su-exec and use the entrypoint script
- Container starts as root but immediately drops privileges after fixing
  permissions

The agent will now start successfully with just 'docker-compose up -d'
without users needing to run chown commands manually.
2026-01-14 09:36:45 -06:00
2b1d779279
Add multi-architecture build support (amd64, arm64) 2026-01-13 14:07:21 -06:00
82f97deeb2
Add protobuf compiler to CI and Docker build 2026-01-13 13:55:12 -06:00
fd1b02a6ea
update ci rust version 2026-01-09 13:36:10 -06:00
125b0f427e
update ci rust version 2026-01-09 13:34:43 -06:00
0f8cfc34e7
init 2026-01-09 13:22:15 -06:00