https://github.com/wangwindow/campus-network-autologin
Lightweight Dr.COM campus network auto-login tool written in Rust.
https://github.com/wangwindow/campus-network-autologin
campus-network login rust-tui
Last synced: about 2 months ago
JSON representation
Lightweight Dr.COM campus network auto-login tool written in Rust.
- Host: GitHub
- URL: https://github.com/wangwindow/campus-network-autologin
- Owner: WangWindow
- Created: 2026-04-22T04:04:37.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-22T04:26:57.000Z (about 2 months ago)
- Last Synced: 2026-04-22T06:32:25.185Z (about 2 months ago)
- Topics: campus-network, login, rust-tui
- Language: Rust
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# campus-network-autologin
Lightweight Dr.COM campus network auto-login tool written in Rust.
## What it does
- Saves credentials to `campus-network/config.toml` under the platform config directory
- Linux: `~/.config/campus-network/config.toml`
- Windows: `%APPDATA%\campus-network\config.toml`
- Opens a ratatui-based terminal setup screen when run without arguments
- Supports CLI-based config updates when run with arguments
- Reproduces the observed HFUT Xuancheng Dr.COM password transform
- Only attempts campus authentication when the configured campus gateway looks reachable
- Detects captive-portal redirects and re-authenticates automatically
- Sleeps between checks to keep CPU usage negligible once the network is online
- Writes daemon logs to `campus-network/daemon.log` under the platform config directory
## Commands
```bash
# Interactive setup (no arguments)
campus-network-autologin
# Save config from the CLI
campus-network-autologin config set \
--username 2022xxxxxx \
--password your-password \
--portal-url http://172.18.3.3/0.htm \
--probe-url http://www.baidu.com/ \
--campus-gateways 172.18.3.3,172.18.2.2
# Show the redacted config
campus-network-autologin config show
# Submit one login attempt and verify internet access
campus-network-autologin login
# Check whether the network is online or captive
campus-network-autologin status
# Run the low-overhead monitor
campus-network-autologin run
# Print the config path
campus-network-autologin paths
# Install/remove user autostart entry for this executable
campus-network-autologin autostart install
campus-network-autologin autostart remove
```
## Config file
```toml
[auth]
username = "2022xxxxxx"
password = "plain-text-for-now"
portal_url = "http://172.18.3.3/0.htm"
[detect]
probe_url = "http://www.baidu.com/"
request_timeout_secs = 8
[daemon]
online_check_interval_secs = 300
offline_check_interval_secs = 15
[campus]
ipv4_cidrs = []
gateway_hosts = ["172.18.3.3", "172.18.2.2"]
```
The login form is submitted as:
```text
DDDDD=
upass=
R1=0
R2=1
para=00
0MKKey=123456
v6ip=
```
## TUI controls
- `Tab` / `Shift+Tab` / mouse wheel: move between fields and buttons
- `Enter`: jump to the next field or activate the selected button
- `Ctrl+S`: save config
- `Ctrl+T`: save config and test login immediately
- `Ctrl+A`: toggle current-user autostart
- `F2`: show or hide the password
- `?`: show or hide shortcut hints (hidden by default)
- `Esc`: quit without saving further changes
Use the `Autostart: ON/OFF` button in TUI to toggle current-user autostart.
You can toggle it by:
- selecting that button and pressing `Enter` or `Space`
- clicking it with the mouse
- pressing `Ctrl+A`
Mouse support:
- click any input field to focus and place the cursor
- click any button to trigger its action
- drag with left mouse button inside an input field to select text
## Campus network detection
Before it attempts login, the program checks whether at least one configured campus gateway is reachable.
- `gateway_hosts` is the main signal and should include your wired/wireless campus gateways
- `ipv4_cidrs` is optional; when filled, it only adds context and does not block login by itself
With the current defaults, the daemon stays idle off-campus and only tries to authenticate when a campus gateway responds.
## Autostart
Install autostart for the current user:
```bash
campus-network-autologin autostart install
```
This writes a platform-specific startup file that points to the current executable absolute path:
- Windows: Task Scheduler entry `campus-network-autologin` (runs hidden at user logon)
- Linux: `~/.config/systemd/user/campus-network-autologin.service`
- macOS: `~/Library/LaunchAgents/com.campus-network-autologin.plist`
Remove it:
```bash
campus-network-autologin autostart remove
```
## Scope
This version only covers:
- automatic login
- captive-portal detection
- connectivity verification
It does not implement self-service account queries, logout, or password management.