Platform detection and CDP discovery utilities. Pure functions with no dependency on daemon state, browser sessions, or SCI context.
Extracted from daemon.clj to break the circular dependency between sci_env.clj (which needs WSL + CDP functions for the spel namespace) and daemon.clj (which requires sci_env.clj for evaluation).
Both daemon.clj and sci_env.clj can safely require this namespace.
Platform detection and CDP discovery utilities. Pure functions with no dependency on daemon state, browser sessions, or SCI context. Extracted from daemon.clj to break the circular dependency between sci_env.clj (which needs WSL + CDP functions for the spel namespace) and daemon.clj (which requires sci_env.clj for evaluation). Both daemon.clj and sci_env.clj can safely require this namespace.
(cdp-candidate-hosts)Returns the list of hosts to probe for CDP endpoints. Default: ["127.0.0.1"]. Under WSL with a resolvable gateway: ["127.0.0.1" "<gateway-ip>"] — loopback first for the fast path on mirrored networking, gateway second for NAT fallback.
Returns the list of hosts to probe for CDP endpoints. Default: ["127.0.0.1"]. Under WSL with a resolvable gateway: ["127.0.0.1" "<gateway-ip>"] — loopback first for the fast path on mirrored networking, gateway second for NAT fallback.
(discover-cdp)(discover-cdp ports timeout-ms)Auto-discovers a running CDP browser by probing candidate hosts and common ports. Returns the first successful probe result (a map with :host :port :browser :ws-url), or nil if no browser is found.
Probes [hosts] × [ports] with the given timeout per probe. Hosts
are determined by cdp-candidate-hosts (WSL-aware). Default ports
are 9222 and 9229.
Auto-discovers a running CDP browser by probing candidate hosts and common ports. Returns the first successful probe result (a map with :host :port :browser :ws-url), or nil if no browser is found. Probes [hosts] × [ports] with the given timeout per probe. Hosts are determined by `cdp-candidate-hosts` (WSL-aware). Default ports are 9222 and 9229.
(probe-cdp host port timeout-ms)Probes http://<host>:<port>/json/version and returns a map with :host, :port, :browser, :ws-url on success, or nil on failure.
This is the canonical CDP liveness check used by both the daemon's auto-discovery and SCI's cdp-connect. Having it in one place prevents probe logic from drifting between the two call-sites.
Probes http://<host>:<port>/json/version and returns a map with :host, :port, :browser, :ws-url on success, or nil on failure. This is the canonical CDP liveness check used by both the daemon's auto-discovery and SCI's cdp-connect. Having it in one place prevents probe logic from drifting between the two call-sites.
(wsl-default-gateway-ip)Returns the default-gateway IP as seen from inside WSL (which under classic NAT networking IS the Windows host), or nil if we're not in WSL / can't determine it.
Reads /proc/net/route directly instead of shelling out to ip route,
so the call is pure-file and GraalVM-native-image friendly. The kernel
stores the gateway as a little-endian 32-bit hex string; reversing the
byte pairs and joining with dots yields the dotted-quad form.
Returns the default-gateway IP as seen from inside WSL (which under classic NAT networking IS the Windows host), or nil if we're not in WSL / can't determine it. Reads `/proc/net/route` directly instead of shelling out to `ip route`, so the call is pure-file and GraalVM-native-image friendly. The kernel stores the gateway as a little-endian 32-bit hex string; reversing the byte pairs and joining with dots yields the dotted-quad form.
(wsl?)Returns true when running inside Windows Subsystem for Linux. Checks /proc/version for "microsoft"/"WSL" markers and the WSL_DISTRO_NAME env var set by wsl.exe — either is sufficient.
Returns true when running inside Windows Subsystem for Linux. Checks /proc/version for "microsoft"/"WSL" markers and the WSL_DISTRO_NAME env var set by wsl.exe — either is sufficient.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |