Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdapterSync

Automatic static-IP management for Windows Ethernet adapters

Platform Rust Latest Release License


AdapterSync Dashboard

AdapterSync is a standalone Windows app (no install, no runtime) that watches your Ethernet adapters and automatically applies static-IP rules the moment a cable is plugged in — then reverts to DHCP when it's unplugged. A system tray icon gives live status, and a clean browser UI at localhost:7474 lets you build rules, watch activity, run terminal commands, and probe subnets — all without touching ncpa.cpl or netsh manually.

v1.0.5 — Latest. WinAPI-based adapter polling (~500 ms detection), all-WinAPI enumeration (zero PowerShell), bug fixes for DHCP loop and admin detection.

Screenshots

Dashboard User Guide
Dashboard — adapters, rules, activity log, and quick actions Built-in User Guide with sidebar navigation
Settings
Settings panel — engine tuning, rule behavior, and app preferences

Features

Rule Engine

  • Adapter pattern matching — rules match by adapter name substring (e.g. Ethernet, USB LAN)
  • Static IP, subnet mask, and gateway assignment via netsh
  • Custom DNS servers (primary + alternate)
  • Optional WiFi disable on plug-in — re-enables on revert
  • Persistent routes added on apply, removed on revert
  • Hosts file entries — appended on apply, cleaned on revert
  • Run script — execute a PowerShell or batch script on apply or revert
  • Subnet scan — ping-sweeps the configured subnet on connect and logs live devices

Automatic Apply and Revert

  • Polls adapters every 5 seconds (configurable); detects plug/unplug in near-real-time
  • Rules revert to DHCP automatically on cable unplug
  • Probe-based revert — if the gateway stops responding for N consecutive probes, rule reverts even with the cable connected (guards against silent link failures)
  • Dynamic priority — when multiple rules match, the most-specific match wins
  • Auto-create rules — first time an unrecognized adapter appears, a draft rule is generated for easy editing

System Tray

  • Tray icon color reflects status: green (active rules), amber (paused), grey (idle)
  • Tooltip shows active rule names and adapter count
  • Tray menu: Open UI, Pause/Resume, Revert All, per-rule quick-apply, Quit
  • Double-click to reopen the browser

Browser UI (localhost:7474)

  • Dashboard — live adapter cards with link speed, IP, MAC, and rule status
  • Rules editor — add, edit, enable/disable, and reorder rules; copy rule to clipboard
  • Activity Log — timestamped event stream; export to .txt
  • Terminal — embedded PowerShell panel with preset command buttons (ipconfig /all, route print, netsh interface show interface, arp -a)
  • Settings — all config.json fields editable in-browser; config file path browser
  • Subnet Scanner — manual trigger; results shown inline with hostname and latency
  • User Guide — full offline documentation at /guide
  • Toast notifications and hold-to-confirm Revert All button

Quality of Life

  • Single EXE — 1.1 MB, no installer, no runtime, no admin UAC prompt on start (elevation only for netsh calls)
  • Config stored as config.json next to the exe — fully portable
  • Duplicate-instance guard: second launch opens the existing UI instead of starting a new server
  • Startup registration: optional Windows autostart via HKCU Run key (no admin needed)
  • run_while_tab_closed mode — keeps monitoring even with no browser open
  • Heartbeat watchdog — server exits cleanly if the browser tab is closed unexpectedly
  • CLI interface for scripting (see below)

Quick Start

Option 1 — Standalone EXE (Windows, no install needed)

  1. Download AdapterSync.exe and config.json from the latest release — keep them in the same folder
  2. Double-click AdapterSync.exe — a browser tab opens at http://localhost:7474
  3. Click Add Rule, set your adapter pattern and static-IP settings, click Save
  4. Plug in your Ethernet cable — the rule applies automatically

Note: applying IP changes requires the process to run as Administrator (for netsh). If you see "Access denied" in the log, right-click the exe and choose Run as administrator, or enable the startup entry so Windows launches it elevated.

Option 2 — Build from Source

Requires Rust 1.70+.

git clone https://github.com/ChrisMangin/AdapterSync
cd AdapterSync
cargo build --release
# EXE at: target/release/AdapterSync.exe

CLI Interface

AdapterSync exposes a minimal CLI for scripting and headless use:

# List all configured rules (JSON)
AdapterSync.exe --list

# Show current adapter and rule state (JSON)
AdapterSync.exe --status

# Revert all active rules immediately
AdapterSync.exe --revert

# Apply a specific rule by label
AdapterSync.exe --apply "Lab Network"

# Open the browser UI (if already running)
AdapterSync.exe --open

# Use a custom config file
AdapterSync.exe --config "D:\configs\lab.json" --status

Config Reference (config.json)

{
  "general": {
    "scan_interval_secs": 5,          // how often to poll adapter state
    "probe_interval_secs": 15,        // gateway probe interval (seconds)
    "revert_after_missed_probes": 5,  // missed probes before auto-revert
    "open_browser": true,             // open UI on launch
    "probe_timeout_ms": 800,          // gateway ping timeout
    "run_while_tab_closed": false,    // keep running with no browser tab
    "run_on_startup": true,           // HKCU autostart entry
    "auto_apply": false,              // apply rules without user confirmation
    "auto_create_rules": true,        // draft rule when new adapter appears
    "dynamic_priority": true,         // most-specific match wins on conflict
    "notify_on_event": true           // Windows toast notifications
  },
  "rules": [
    {
      "label": "Lab Network",
      "adapter_pattern": "Ethernet",  // substring match on adapter name
      "enabled": true,
      "ip": "192.168.1.100",
      "mask": "255.255.255.0",
      "gateway": "192.168.1.1",
      "dns": ["8.8.8.8", "8.8.4.4"],
      "disable_wifi": false,
      "routes": [],                   // [{"network":"10.0.0.0","mask":"255.0.0.0","gateway":"192.168.1.1"}]
      "hosts_entries": [],            // [{"ip":"192.168.1.50","hostname":"labserver"}]
      "run_script": "",               // path to .ps1 or .bat
      "scan_subnet": ""               // e.g. "192.168.1.0/24"
    }
  ]
}

Project Layout

AdapterSync/
├── Cargo.toml
├── build.rs              embeds app icon via winres
├── src/
│   ├── main.rs           entry point — tray loop, instance guard, CLI, startup
│   ├── api.rs            axum HTTP + SSE routes, all API endpoints
│   ├── engine.rs         adapter monitor loop, rule apply/revert logic
│   ├── adapter.rs        WMI/netsh adapter enumeration and link-state
│   ├── state.rs          thread-safe app state (adapters, log, config, SSE)
│   ├── config.rs         config.json load/save, rule schema
│   ├── prefs.rs          config-path override (--config flag)
│   ├── probe.rs          ICMP gateway probe
│   └── notifications.rs  Windows toast notification helpers
└── assets/
    ├── index.html        app shell
    ├── style.css         dark UI theme
    ├── app.js            all UI logic (~1 500 lines, no build step)
    └── guide.html        built-in offline User Guide

Tech Stack

Layer Technology
HTTP + SSE server axum 0.7 + tokio
Win32 / COM / Shell windows-rs 0.58
Tray icon tray-icon
Frontend embedding rust-embed 8
Frontend Vanilla HTML / CSS / JS — no framework, no build step

Requirements

  • Windows 10 / 11 (x86-64)
  • Local administrator rights for IP assignment (netsh interface ip set address)
  • No external runtime or installer needed

License

MIT — see LICENSE.

About

Automatic static-IP management for Windows Ethernet adapters — standalone Rust app with browser UI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages