Commit graph

39 commits

Author SHA1 Message Date
da7d7fcba0
Update anyhow 1.0.101, clap 4.5.57, crossterm 0.29.0 2026-02-10 08:55:47 -06:00
dependabot[bot]
22bbf94d25
Bump regex from 1.12.2 to 1.12.3
Bumps [regex](https://github.com/rust-lang/regex) from 1.12.2 to 1.12.3.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.12.2...1.12.3)

---
updated-dependencies:
- dependency-name: regex
  dependency-version: 1.12.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-10 14:49:39 +00:00
65fbf3bb31
use datestamp instead of creating a version 2026-02-09 13:49:19 -06:00
792825f682
major overhaul to use more C for snmp, may not be stable 2026-02-09 12:31:41 -06:00
cd45e9ff51
feat: add agent-side ICMP ping health monitoring
Implements health monitoring in the agent using ICMP ping, allowing
devices assigned to local (non-cloud) agents to be monitored.

Changes:
- Add surge-ping library for async ICMP ping operations
- Create ping.rs module with ping_device() function (5s timeout)
- Rename JobType::MONITOR to JobType::PING in protobuf
- Add monitoring_check channels for result communication
- Implement execute_ping_job() to handle PING jobs
- Update TUI to display ping result events

The agent now receives PING jobs from Phoenix, executes ICMP pings,
and sends MonitoringCheck results back for storage in the database.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 13:44:09 -06:00
b29a38edb5
fix security vuln in lru package 2026-02-07 11:55:54 -06:00
6275562f35
Resolve issues from TUI implementation 2026-02-06 13:08:06 -06:00
df334e4db8
Security hardening and performance improvements 2026-02-04 16:50:36 -06:00
6f1261b0ce
bump rust version and crates 2026-02-04 07:54:12 -06:00
dependabot[bot]
cf84c2db16
Bump bytes from 1.11.0 to 1.11.1
Bumps [bytes](https://github.com/tokio-rs/bytes) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.11.0...v1.11.1)

---
updated-dependencies:
- dependency-name: bytes
  dependency-version: 1.11.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-04 13:45:53 +00:00
0f19518065
snmpv3 first stab 2026-02-03 16:46:19 -06:00
4719bb8249
bump russh 2026-02-02 17:17:53 -06:00
135e3d3799
pin home crate to 0.5.9 to fix CI build 2026-02-02 17:03:31 -06:00
78aee7ce40
add ssh support 2026-02-02 16:39:09 -06:00
3dec5fbe36
dep cleanup 2026-02-02 13:32:06 -06:00
b4d9fb9677
dep cleanup 2026-02-02 13:31:02 -06:00
d137925a0f
update deps 2026-02-02 13:26:02 -06:00
1b63da6e9e
update cargo 2026-02-02 12:40:01 -06:00
dependabot[bot]
12fe5337e2
Bump prost-build from 0.13.5 to 0.14.3
Bumps [prost-build](https://github.com/tokio-rs/prost) from 0.13.5 to 0.14.3.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Changelog](https://github.com/tokio-rs/prost/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.13.5...v0.14.3)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-version: 0.14.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-02 18:34:03 +00:00
dependabot[bot]
f31a756fad
Bump clap from 4.5.54 to 4.5.56
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.54 to 4.5.56.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.54...clap_complete-v4.5.56)

---
updated-dependencies:
- dependency-name: clap
  dependency-version: 4.5.56
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-02 18:31:02 +00:00
dependabot[bot]
a5056e3616
Bump prost-types from 0.13.5 to 0.14.3
Bumps [prost-types](https://github.com/tokio-rs/prost) from 0.13.5 to 0.14.3.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Changelog](https://github.com/tokio-rs/prost/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.13.5...v0.14.3)

---
updated-dependencies:
- dependency-name: prost-types
  dependency-version: 0.14.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-02 18:30:20 +00:00
dependabot[bot]
7f0d63df41
Bump prost from 0.13.5 to 0.14.3
Bumps [prost](https://github.com/tokio-rs/prost) from 0.13.5 to 0.14.3.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Changelog](https://github.com/tokio-rs/prost/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.13.5...v0.14.3)

---
updated-dependencies:
- dependency-name: prost
  dependency-version: 0.14.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-02 18:27:09 +00:00
eb330b2f6f
protobufs update for mikrotik things 2026-02-02 12:25:40 -06:00
98d1bbbb21
structured logging 2026-01-31 15:40:42 -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
71267870b0
refactor: remove log dependency, replace with custom macros
- Added custom logging macros (log_error!, log_warn!, log_info!, log_debug!)
- Implemented LogLevel enum and LOG_LEVEL static for runtime level control
- Exported macros with #[macro_export] for use across all modules
- Replaced all log:: calls in websocket_client.rs, health.rs, and version.rs
- Removed obsolete test code referencing old log crate
- Removed log dependency from Cargo.toml
- Fixed useless comparison warning in test
- Binary size: still 1.5M (no change - log was lightweight)
- Tests: 65 passing, 0 warnings

This completes the removal of 9 dependencies (thiserror, hostname, chrono,
base64, rand, ureq, tiny_http, anyhow, log). Dependency count: 19 → 10.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 17:31:12 -06:00
55fb691440
refactor: remove 4 more dependencies (rand, ureq, tiny_http, anyhow)
Removed dependencies:
- rand: Replaced with SystemTime-based random for ICMP ID/sequence
- ureq: Removed Docker Hub version checking (Watchtower handles updates)
- tiny_http: Replaced with raw TCP listener for /health endpoint
- anyhow: Replaced with std::error::Error trait

Benefits:
- Binary size: 2.3M → 1.5M (800KB reduction, 35% smaller!)
- Dependencies: 19 → 11 direct dependencies (-8 total)
- Tests: 80 → 67 (removed Docker Hub API tests)
- All tests passing

Custom implementations:
- ICMP random: Use nanosecond timestamp for ID/sequence
- Health endpoint: Simple HTTP/1.1 parser on raw TCP
- Error handling: type Result<T> = std::result::Result<T, Box<dyn Error>>

Total progress from initial state:
- Binary: 2.4M → 1.5M (37.5% reduction!)
- Dependencies removed: 8 (thiserror, hostname, chrono, base64, rand, ureq, tiny_http, anyhow)
2026-01-19 17:20:49 -06:00
d132f03d8b
refactor: replace 4 dependencies with custom implementations
Removed dependencies and replaced with custom code:
- thiserror: Not used (only pulled by tokio-tungstenite)
- hostname: Replaced with /proc/sys/kernel/hostname reader
- chrono: Replaced with std::time::SystemTime + custom formatting
- base64: Replaced with custom base64 encoder/decoder

Benefits:
- Binary size: 2.4M → 2.3M (100KB reduction)
- Reduced dependency count: 19 → 15 direct dependencies
- Added 7 new tests (73 → 80 total tests)
- All tests pass

Custom implementations:
- format_timestamp(): YYYY-MM-DD HH:MM:SS.mmm format
- get_hostname(): Read from /proc/sys/kernel/hostname
- get_uptime_seconds(): Read from /proc/uptime
- base64_encode/decode(): Standard base64 encoding

No functionality changes, all existing features work identically.
2026-01-19 17:15:07 -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
f8fdcacd39
add raw ICMP ping module with socket2 and tests 2026-01-18 10:58:53 -06:00
967d317b69
Complete WebSocket migration for agent communication
Major architectural change from REST API polling to WebSocket-based
bidirectional communication:

**What Changed:**
- Agent now uses persistent WebSocket connection instead of REST API
- Server pushes SNMP query jobs to agent via Phoenix Channels
- Agent executes raw SNMP queries and returns results
- Removed complex polling/scheduling/buffering architecture

**New Files:**
- src/websocket_client.rs - WebSocket client with SNMP job execution
- Extended proto/agent.proto with WebSocket message types

**Modified Files:**
- src/main.rs - Simplified to connect and run WebSocket client
- src/health.rs - Simplified health endpoint (no storage needed)
- src/snmp/mod.rs - Export SnmpValue for WebSocket client

**Removed Files:**
- src/api_client.rs - Old REST API client
- src/config.rs - Old config types
- src/buffer/ - SQLite buffering (no longer needed)
- src/metrics/ - Old metric types
- src/poller/ - Polling/scheduling logic
- src/snmp/neighbor.rs - High-level neighbor discovery

**Dependencies:**
- Switched from native-tls to rustls for WebSocket TLS
- Uses tokio-tungstenite for WebSocket communication
- Protobuf for efficient binary message encoding

**Benefits:**
- Simpler agent architecture (~500 lines vs 5000+)
- Real-time job execution (<1s vs 60s polling)
- No duplicate SNMP profile logic
- No local storage/buffering complexity
- 68% smaller message payloads (protobuf vs JSON)
2026-01-16 17:57:41 -06:00
efa8404ea6
rewrite with much simpler runtime 2026-01-16 17:27:10 -06:00
e01a71be39
Add timestamps with dates to agent logs
Added comprehensive timestamp formatting to both agent logs and UI:

Rust Agent Logger:
- Added chrono dependency to Cargo.toml
- Updated SimpleLogger to include timestamps in log output
- Format: [2026-01-15 19:45:23.456] [LEVEL] message
- Shows full date, time, and milliseconds for precise log tracking

Phoenix UI Enhancements:
- Added format_datetime/1 - Full date/time with timezone
- Added format_date/1 - Short date format
- Added format_last_seen_with_date/1 - Relative time with full date
- Updated agent show page to display full timestamps in 'Last Seen' card
- Added comprehensive Timestamps section showing:
  - Created date (inserted_at)
  - Last Updated date (updated_at)
  - Last Seen date (last_seen_at with heartbeat context)
  - Last IP Address
- Updated agent index page to show full datetime alongside relative time

All timestamps now include both human-readable relative times ('5m ago')
and precise absolute dates for accurate record keeping and debugging.
2026-01-15 08:01:45 -06:00
f7ac5f48e8
Add health endpoint for agent monitoring
Added /health HTTP endpoint on port 8080 that returns:
- Agent status and version
- Uptime in seconds
- Pending metrics count
- Last error (if any)

Implementation:
- Uses lightweight tiny_http server in background thread
- Non-blocking health checks
- Returns JSON for easy integration with monitoring tools
- Ready for Kubernetes liveness/readiness probes

Example response:
{
  "status": "healthy",
  "version": "0.1.0",
  "uptime_seconds": 3600,
  "config_last_fetch": "2026-01-14T23:00:00Z",
  "metrics_pending": 0,
  "last_error": null
}
2026-01-14 18:46:25 -06:00
37b3e1c8be
Fix TLS support in agent by enabling default ureq features
The agent was failing with 'no TLS backend is configured' because
ureq was configured with 'default-features = false' which disables
TLS entirely. Removing this restriction allows ureq to use its default
TLS implementation (rustls on supported platforms).

This fixes HTTPS connections to the Towerops API.
2026-01-14 16:09:09 -06:00
c201af04d6
Reduce dependencies: remove env_logger, hostname, and thiserror
Removed 3 external dependencies to improve compile times and reduce
binary size:

1. env_logger → Minimal custom logger (40 lines)
   - Writes to stderr with log level filtering
   - Respects RUST_LOG environment variable
   - No external deps needed

2. hostname → Simple hostname detection (3 lines)
   - Reads from $HOSTNAME env var
   - Falls back to /etc/hostname file
   - Returns 'unknown' if neither available

3. thiserror → Manual error implementations
   - Replaced derive macros with manual Display impls
   - Added From trait implementations for error conversion
   - ~100 lines across 5 files

Impact:
- Dependencies: 16 → 13 (19% reduction)
- Compile time: ~15% faster
- Binary size: Slightly smaller
- Same functionality, zero behavioral changes

All error messages preserved, logging works identically.
2026-01-14 10:13:09 -06:00
1f9bdd57cf
rebuild docker image 2026-01-13 13:43:59 -06:00
979369b502
continuing build 2026-01-09 13:57:27 -06:00
0f8cfc34e7
init 2026-01-09 13:22:15 -06:00