Surge Module that automatically switches policy groups when your network location changes — so you don't have to.
Designed for people who travel or live abroad while maintaining a local proxy / home server (e.g. via Surge Ponte), and need domestic traffic to route through home when away.
When a network change is detected (Wi-Fi / Cellular switch, Airplane Mode toggle), the script checks your exit IP against your home country. It then sets your policy groups to either Home or Abroad mode:
| Group | Home | Abroad |
|---|---|---|
| Domestic | DIRECT |
Routes through your home device / Local Proxy |
| Final | Your proxy group | DIRECT |
| International | Your proxy group | DIRECT |
| Proxy (optional) | Restores previous selection | DIRECT |
You can configure every parameter in Surge Module preferences.
Install as a remote module in Surge iOS:
https://gist.githubusercontent.com/at-wr/d9ada66c397cc45d2d5e0f647f3361d8/raw/connectivityd.sgmodule
After installation, tap the module to configure parameters.
| Parameter | Description | Default |
|---|---|---|
home_country |
ISO 3166-1 country code | JP |
These must match your Surge config exactly.
| Parameter | Description | Default |
|---|---|---|
grp_domestic |
Group for domestic traffic | Domestic |
grp_final |
FINAL / catch-all group | Final |
grp_intl |
Group for international services | International |
What each group resolves to in each mode.
| Parameter | Description | Default |
|---|---|---|
home_domestic |
Domestic exit at home | DIRECT |
abroad_domestic |
Domestic exit abroad (e.g. DEVICE:PONTENAME, a proxy node, or a group) |
DIRECT |
home_final |
FINAL at home | Proxy |
abroad_final |
FINAL abroad | DIRECT |
home_intl |
International at home | Proxy |
abroad_intl |
International abroad | DIRECT |
Leave both empty to skip. Useful if your proxy group should be DIRECT abroad but restored to a specific policy when returning home.
| Parameter | Description | Default |
|---|---|---|
proxy_group |
A select-group to manage | (empty) |
home_default_proxy |
Policy to restore when returning home | (empty) |
| Parameter | Description | Default |
|---|---|---|
max_retries |
Max detection attempts | 5 |
initial_delay |
Ms before first detection | 3000 |
retry_interval |
Ms between retries | 5000 |
A user in China with a Mac mini at home running Surge Ponte, who frequently travels abroad or uses a foreign SIM (e.g. Google Fi):
| Parameter | Value |
|---|---|
home_country |
CN |
grp_domestic |
🇨🇳 China |
grp_final |
🦊 Mask |
grp_intl |
🇺🇳 International |
abroad_domestic |
DEVICE:HOMELAB |
home_final |
🧭 Primary |
home_intl |
🦊 Mask |
proxy_group |
🧭 Primary |
home_default_proxy |
💿 ProxySet |
Home (Local Cellular / Wi-Fi): domestic traffic goes direct, international goes through proxy, FINAL catches everything else through proxy.
Abroad: domestic traffic routes through Ponte back home for a Chinese IP, international and FINAL go direct since you're already overseas.
- Detection uses ipinfo.io — the module injects a
DOMAIN,ipinfo.io,DIRECTrule automatically. - After toggling airplane mode, cellular may take up to 20 seconds to reconnect. The retry mechanism (5 attempts × 5s intervals) covers this window.
- Notifications are delivered on each switch so you know which mode is active.
MIT