How It Works
Execution Flow
AutoDialer follows a small, predictable flow:
- Resolve the default gateway IP for the current operating system.
- Send an HTTP request to the router homepage and infer the vendor from response fingerprints.
- Load the matching router API class from
src/autodialer/apis/routers/. - Query the current WAN protocol.
- Run the protocol-specific reconnect action.
- Verify the resulting ISP/org string with
ipinfo.io.
The CLI entry point for reconnection lives in src/autodialer/reconnection.py, and the device listing entry point lives in src/autodialer/get_devices.py.
Gateway Detection
Gateway detection is implemented in src/autodialer/apis/utils/get_gateway.py.
- Windows uses
route print -4. - Linux reads
/proc/net/routefirst, then falls back toip -4 route show default. - macOS, FreeBSD, OpenBSD, and NetBSD use
route -n get default, then fall back tonetstat -rn.
The helper also normalizes IPv4 and IPv6 addresses so they can be used safely in router URLs.
Vendor Detection
Vendor detection is implemented in src/autodialer/apis/utils/check_vendor.py.
The current logic:
- requests
http://<gateway>, - checks the HTML
<title>when present, - falls back to redirect URLs and
Locationheaders, - scans response headers and the HTML body for known vendor markers, and
- returns the first matching vendor name.
The registry lookup in src/autodialer/apis/utils/get_vendor_api.py then discovers router implementations dynamically by scanning *_api.py files and reading each class's SUPPORTED_VENDORS.
Reconnection Modes
--force
autodialer --force reconnects once, then checks the ISP/org string and logs the result if the check succeeds.
--asn <ASN>
autodialer --asn <ASN> first checks whether the current ISP already matches the requested ASN. If it does, the process exits successfully immediately. If not, AutoDialer reconnects and retries the ISP check until either:
- the target ASN is reached, or
- 5 reconnection attempts have been exhausted.
Router Support Status
The repository currently contains these router API modules:
| Router module | Status | Notes |
|---|---|---|
asus/asus_api.py |
Implemented | Used for ASUS and ASUS AiMesh fingerprints. |
tplink/tplink_api.py |
Implemented | Handles PPPoE, DHCP, and device listing. |
zte/zte_api.py |
Implemented | Handles PPPoE, DHCP, and device listing. |
Support is best understood as "implemented against known request/response shapes," not as a guarantee for every firmware revision from a vendor.
Extending AutoDialer
To add a new router integration:
- Create a new
*_api.pymodule undersrc/autodialer/apis/routers/. - Add a class with a
SUPPORTED_VENDORSattribute. - Implement the methods expected by
RouterAPIinsrc/autodialer/apis/routers/base_api.py. - Add or update vendor fingerprints in
src/autodialer/apis/utils/check_vendor.py. - Add unit tests for the new behavior under
tests/.
Because router APIs are vendor- and firmware-specific, keep request payloads isolated to the router module and prefer tests that mock network calls rather than reaching real devices.