Skip to content

edcet/netadmin-v3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

netadmin v3.0

Production-Grade WAN Management Framework for ASUSWRT-Merlin Routers

A self-scaffolding, CI/CD-integrated deployment system with hardware acceleration awareness, state machine monitoring, and observability built for the GT-AX6000 (BCM4912) and compatible Broadcom-based Merlin routers.

🎯 Features

Core Architecture

  • State Machine: 6-state model (INIT β†’ WAN_WAIT β†’ RULES_APPLY β†’ ACTIVE β†’ DEGRADED/SAFE) with timeout protection
  • Hardware Acceleration Gatekeeper: Detects CTF/Flow Accelerator/Runner and validates zapret compatibility
  • TCP Health Validation: Beyond ICMP ping - validates actual data flow with TCP handshake checks
  • Boot-Time Fallback: Automatic recovery from bad rules via watchdog mechanism
  • DHCP Lifecycle Hooks: Integrates with Merlin's dhcpc-event for reliable IP acquisition

Deployment & CI/CD

  • Semantic Versioning: Automated version bumping via Conventional Commits
  • GitHub Actions: Free public runners, GHCR container publishing
  • Artifact Management: Signed releases, changelog generation, backward compatibility checks
  • Safe Upgrade Path: NVRAM migration, dry-run validation, atomic swap

Testing & Quality

  • Embedded Systems Testing: shellspec framework for POSIX-compatible shell scripts
  • Static Analysis: ShellCheck linting, NVRAM key validation
  • Integration Tests: Simulated DHCP events, state transitions, rule application
  • Performance Benchmarks: Throughput validation (CTF enabled vs. disabled vs. zapret)

Observability

  • State Persistence: Machine-readable state files in /tmp/netadmin_*
  • Metric Export: JSON outputs for monitoring integrations
  • Boot Watchdog: Prevents infinite boot loops via counter mechanism
  • Health Checks: WAN readiness probes, rule validation, hardware acceleration status

πŸ“¦ Quick Start

Installation

# SSH to your router
ssh admin@192.168.1.1

# Download and run installer (dry-run first)
curl -fsSL https://github.com/edcet/netadmin-v3/releases/download/latest/install.sh | sh -s -- --dry-run

# Apply installation
curl -fsSL https://github.com/edcet/netadmin-v3/releases/download/latest/install.sh | sh

Profiles

# Safe mode (minimal rules)
netadmin profile safe

# Standard Verizon throttling bypass
netadmin profile verizon

# Full DPI bypass with zapret
netadmin profile verizon-bypass

# Query current state
netadmin wan-state
netadmin get-state

πŸ—οΈ Architecture

State Machine

INIT(0)
  ↓
WAN_WAIT(1) ←──────────────┐
  ↓                         β”‚ (timeout 60s)
RULES_APPLY(2)              β”‚
  ↓                         β”‚
ACTIVE(3) ─→ DEGRADED(4) β”€β”€β”€β”˜
  ↓
  └─→ SAFE(5) ← error transition

Hardware Acceleration Awareness

Mode CTF FC Runner Throughput Use Case
Stock βœ… βœ… βœ… ~2000 Mbps Normal routing
TTL Spoof ❌ ❌ ❌ ~800 Mbps Tethering bypass
DPI Bypass ❌ ❌ ❌ ~200 Mbps Full anti-throttle

πŸ”§ Configuration

NVRAM Keys (v3.0)

# Core configuration
netadmin_mode         # Current mode: safe, verizon, verizon-bypass
netadmin_state        # Current state: 0-5 (see state machine)
netadmin_ttl_mode     # TTL spoofing: off, clamp, spoof
netadmin_zapret       # DPI bypass: 0 (disabled), 1 (enabled)
netadmin_wan_primary  # WAN interface: eth0, eth1, etc.
netadmin_boot_attempts # Boot failure counter (auto-reset after safe revert)

Performance Tuning

# Check current hardware acceleration status
nvram get ctf_disable    # 0 = enabled (default), 1 = disabled
nvram get fc_disable
nvram get runner_disable

# Enable zapret (automatically disables CTF)
netadmin profile verizon-bypass
# Expects: ~200 Mbps throughput (vs. 2000 Mbps baseline)

πŸ“Š Monitoring & Observability

Health Checks

# Check WAN readiness (JSON output)
netadmin wan-state

# Output:
# {
#   "interface": "eth0",
#   "carrier": "up",
#   "ip_acquired": "192.168.100.1",
#   "gateway_reachable": true,
#   "tcp_health_1.1.1.1:443": true,
#   "state": "ACTIVE",
#   "rules_active": true,
#   "hardware_accel": {
#     "ctf_enabled": false,
#     "fc_enabled": false,
#     "runner_enabled": false
#   }
# }

State Logs

# Real-time state transitions
tail -f /tmp/netadmin_state.log

# Boot watchdog counter
cat /tmp/netadmin_boot_attempts

πŸš€ Deployment

Upgrade from v2.1

# Automatic migration (pre-tested on boot)
netadmin migrate --from-v2.1

# Rollback if needed
netadmin rollback

CI/CD Pipeline (GitHub Actions)

  1. On Commit (develop):

    • ShellCheck lint analysis
    • Conventional Commit validation
    • Unit tests (shellspec)
  2. On PR:

    • All above + integration tests
    • Hardware acceleration compatibility check
    • Performance regression detection
  3. On Merge to Main:

    • Semantic version bump (auto)
    • Release notes generation
    • Signed artifact creation
    • GHCR container push
    • GitHub release publication

πŸ“ˆ Performance Benchmarks

GT-AX6000 (BCM4912) - Real-World Measurements

Config WAN→LAN CPU Latency Notes
Baseline (CTF) 1.8-2.0 Gbps 5% <1ms Stock Merlin
TTL Spoof 600-900 Mbps 50% 2-5ms iptables mangle
Zapret DPI 150-300 Mbps 85% 5-20ms NFQUEUE bottleneck

See PERFORMANCE.md for detailed analysis.

πŸ› οΈ Development

Project Structure

netadmin-v3/
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/
β”‚   β”‚   β”œβ”€β”€ lint.yml              # ShellCheck, semantic validation
β”‚   β”‚   β”œβ”€β”€ test.yml              # Unit + integration tests
β”‚   β”‚   β”œβ”€β”€ release.yml           # Semantic versioning & release
β”‚   β”‚   └── publish.yml           # GHCR container publishing
β”‚   └── dependabot.yml            # Automated dependency updates
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ netadmin-lib.sh       # State machine, hardware checks
β”‚   β”‚   β”œβ”€β”€ wan-state.sh          # WAN monitoring & health checks
β”‚   β”‚   └── watchdog.sh           # Boot-time protection
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ wan-event             # Merlin WAN state hook
β”‚   β”‚   β”œβ”€β”€ dhcpc-event           # DHCP lifecycle hook
β”‚   β”‚   └── services-start        # Boot initialization
β”‚   β”œβ”€β”€ profiles/
β”‚   β”‚   β”œβ”€β”€ safe.sh               # Safe mode rules
β”‚   β”‚   β”œβ”€β”€ verizon.sh            # TTL spoofing
β”‚   β”‚   └── verizon-bypass.sh     # Full DPI bypass
β”‚   └── cli/
β”‚       └── netadmin              # Main CLI interface
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ spec/
β”‚   β”‚   β”œβ”€β”€ state_machine_spec.sh
β”‚   β”‚   β”œβ”€β”€ hardware_accel_spec.sh
β”‚   β”‚   β”œβ”€β”€ wan_health_spec.sh
β”‚   β”‚   └── integration_spec.sh
β”‚   β”œβ”€β”€ fixtures/
β”‚   β”‚   β”œβ”€β”€ nvram_mock.sh         # Mock NVRAM for testing
β”‚   β”‚   β”œβ”€β”€ ip_mock.sh            # Mock iproute2 for testing
β”‚   β”‚   └── iptables_mock.sh      # Mock iptables for testing
β”‚   └── bench/
β”‚       └── throughput_test.sh    # Performance benchmarking
β”œβ”€β”€ install/
β”‚   β”œβ”€β”€ install.sh                # Main installer with dry-run
β”‚   β”œβ”€β”€ migrate.sh                # v2.1 β†’ v3.0 migration
β”‚   └── rollback.sh               # Emergency rollback
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ ARCHITECTURE.md           # System design
β”‚   β”œβ”€β”€ PERFORMANCE.md            # Benchmark analysis
β”‚   β”œβ”€β”€ TROUBLESHOOTING.md        # Debug guide
β”‚   └── API.md                    # Script API reference
β”œβ”€β”€ .releaserc.json               # Semantic release config
β”œβ”€β”€ .shellcheckrc                 # ShellCheck rules
β”œβ”€β”€ Makefile                      # Local development targets
└── VERSION                       # Current version (semantic)

Local Development

# Install dependencies
make install-dev

# Run tests locally
make test
make lint

# Simulate router environment
make test-router  # Runs in busybox container

# Build release artifacts
make release

πŸ”’ Security & Stability

Boot Watchdog (Anti-Brick Protection)

# Automatic on first boot failure:
# 1. Increment /tmp/netadmin_boot_attempts
# 2. After 3 failures β†’ activate fallback
# 3. Load safe profile + revert to last known good
# 4. Alert user in logs

Rollback Mechanism

# Atomic NVRAM migration with checkpoint
cp -r /jffs/scripts /jffs/scripts.v3.0.backup
netadmin migrate
# On error: auto-restore from backup

πŸ“ License

MIT - See LICENSE file

🀝 Contributing

See CONTRIBUTING.md for guidelines.

πŸ“ž Support

About

Production-grade WAN management framework for ASUSWRT-Merlin routers with hardware acceleration awareness, state machine monitoring, and observability

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors