A Rust-based daemon that automatically authenticates against IIT Mandi's captive portal. It runs as a background service with intelligent hybrid network monitoring (netwatcher + adaptive polling), secure credential storage, and desktop notifications.
- 🚀 Automatic Login: Detects and authenticates with the captive portal instantly upon network changes
- 🔄 Hybrid Monitoring: Combines real-time network event detection with intelligent exponential backoff polling
- 🔐 Secure Credentials: Stores credentials in OS keychain (macOS Keychain / Linux Secret Service)
- 🔔 Desktop Notifications: Get notified when successfully logged in
- ⚡ Smart Retry Logic: Automatic retry with exponential backoff on login failures
- 📊 Service Status: Monitor service health and login statistics
- 🎯 Cross-Platform: Supports macOS (x86_64, ARM64) and Linux (x86_64)
- macOS or Linux
- jq (required for the installation script):
- On macOS:
brew install jq - On Linux:
apt install jq(Debian/Ubuntu) oryum install jq(CentOS/RHEL)
- On macOS:
- Rust and Cargo (only if building from source)
To install and set up the Auto Captive Portal Login service, run:
curl -fsSL https://raw.githubusercontent.com/amansikarwar/auto-captive-portal/main/install.sh | bashThis command will:
- Download the latest
acpbinary for your platform from GitHub releases - Install it to
/usr/local/bin/acp - Prompt you for your LDAP credentials
- Store credentials securely in your OS keychain
- Create and start the background service
Note: You will be prompted for your LDAP credentials during the setup process.
- Linux (x86_64) - Ubuntu, Debian, Fedora, CentOS, etc.
- macOS (x86_64) - Intel-based Macs
- macOS (ARM64) - Apple Silicon Macs (M1, M2, M3, etc.)
# Show service status and statistics
acp status
# Update stored credentials
acp update-credentials
# Perform health check (verify credentials, portal detection, connectivity)
acp health
# Show help and available commands
acp --help
# Run daemon directly (for testing)
acpThe acp status command provides comprehensive information:
╔══════════════════════════════════════════════════════╗
║ Auto Captive Portal - Service Status ║
╚══════════════════════════════════════════════════════╝
Credentials: ✓ Configured (user: your_username)
Service: ✓ Running
Internet: ✓ Connected
Portal Status: ✓ Not detected
─────────────────────────────────────────────────────
Last Check: 2 minutes ago
Last Login: 15 minutes ago
Last Portal: https://login.iitmandi.ac.in:1003/portal
The service runs as a LaunchAgent (com.user.acp) and starts automatically on login.
Manual Service Management:
# Check if service is running
launchctl list | grep com.user.acp
# Start service
launchctl load ~/Library/LaunchAgents/com.user.acp.plist
# Stop service
launchctl unload ~/Library/LaunchAgents/com.user.acp.plist
# View logs (last 5 minutes)
log show --predicate 'processImagePath contains "acp"' --last 5m
# Follow logs in real-time
log stream --predicate 'processImagePath contains "acp"'Credentials Storage: Uses macOS Keychain (security command)
The service runs as a systemd user service (acp.service).
Manual Service Management:
# Check service status
systemctl --user status acp
# Start service
systemctl --user start acp
# Stop service
systemctl --user stop acp
# Restart service
systemctl --user restart acp
# View logs (last 50 lines)
journalctl --user -u acp -n 50
# Follow logs in real-time
journalctl --user -u acp -fCredentials Storage: Uses Linux Secret Service (libsecret)
ACP uses a hybrid monitoring approach for optimal responsiveness and resource efficiency:
-
Real-time Network Event Detection (via
netwatcherlibrary)- Monitors network interface changes (new interfaces, IP address assignments)
- Triggers immediate portal check (after 3-second debounce delay)
- Detects: Wi-Fi connections, VPN changes, ethernet connections
-
Adaptive Polling (exponential backoff)
- Portal detected: Checks every 10 seconds
- Successfully logged in: Checks every 30 minutes (1800 seconds)
- No portal found: Gradually decreases interval (exponential decay to 10s minimum)
-
Portal Detection: Requests
http://clients3.google.com/generate_204- No portal: Receives 204 response → Internet accessible
- Portal present: Receives 200 redirect → Extract portal URL and magic value
-
Login Attempt: POSTs to
https://login.iitmandi.ac.in:1003/portal?with:- Username and password (from keychain)
- Magic value (extracted from portal HTML)
- Redirect URL
-
Verification: Confirms internet connectivity after login
- Success → Desktop notification + Set 30-minute poll interval
- Failure → Retry with exponential backoff (max 3 attempts)
- macOS: Stored in macOS Keychain using
securitycommand - Linux: Stored in Secret Service (GNOME Keyring, KWallet, etc.) using
libsecret - No plaintext: Credentials never stored in configuration files
- OS-level encryption: Leverages OS native secure storage
To completely remove the Auto Captive Portal service:
curl -fsSL https://raw.githubusercontent.com/amansikarwar/auto-captive-portal/main/install.sh | bash -s uninstallThis will:
- Stop and remove the background service
- Delete stored credentials from keychain
- Remove the
acpbinary from/usr/local/bin/ - Clean up all service configuration files
| Issue | Solution |
|---|---|
| "Keyring error" or "Credentials not found" | Run acp setup to store credentials |
| Service not running | Check logs (see platform-specific commands above) |
| Login failed | Run acp update-credentials to update credentials |
| Portal URL/magic extraction fails | Portal format may have changed - check captive_portal.rs |
| No notifications | Check notification permissions for the application |
# Check service health and connectivity
acp health
# View detailed service status
acp status
# Check logs
# macOS:
log show --predicate 'processImagePath contains "acp"' --last 5m
# Linux:
journalctl --user -u acp -n 50To test the service without installing:
# Build from source
cargo build --release
# Run setup (stores credentials)
./target/release/acp-script setup
# Run daemon directly
RUST_LOG=INFO ./target/release/acp-script
# Or run health check
./target/release/acp-script health# Clone repository
git clone https://github.com/amansikarwar/auto-captive-portal.git
cd auto-captive-portal
# Build release binary
cargo build --release
# Binary will be at: target/release/acp-scriptThe project uses GitHub Actions for cross-platform builds:
# Targets:
- x86_64-unknown-linux-gnu → acp-script-linux-amd64
- x86_64-apple-darwin → acp-script-macos-x86_64
- aarch64-apple-darwin → acp-script-macos-arm64For notification support on Linux:
# Debian/Ubuntu
sudo apt-get install libgtk-3-dev libayatana-appindicator3-dev
# Fedora/RHEL
sudo dnf install gtk3-devel libappindicator-gtk3-develContributions are welcome! Please feel free to submit a Pull Request.
- Support for additional captive portal formats
- Enhanced error reporting and diagnostics
- Additional platform support (Windows, BSD)
- Configuration file support for advanced settings
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Rust
- Network monitoring via netwatcher
- Secure credential storage via keyring-rs
- Desktop notifications via notify-rust