evo-cli 0.36.6__tar.gz → 0.37.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {evo_cli-0.36.6 → evo_cli-0.37.1}/PKG-INFO +1 -1
- evo_cli-0.37.1/evo_cli/VERSION +1 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/openvpn.py +44 -1
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/openvpn.py +62 -4
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/PKG-INFO +1 -1
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_openvpn.py +139 -5
- evo_cli-0.36.6/evo_cli/VERSION +0 -1
- {evo_cli-0.36.6 → evo_cli-0.37.1}/Containerfile +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/HISTORY.md +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/LICENSE +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/MANIFEST.in +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/README.md +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/__main__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/base.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/cli.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/agent_toy.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/claude_code.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/cloudflare.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/cred.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/download.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/fix_claude.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/gdrive.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/gh.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_dag.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_git.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_hub.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_mirror.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_model.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_mutate.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_paths.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_render.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/_server.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/check.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/clone.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/edit.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/pull.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/serve.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/show.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/views.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/index-Cs7hXRPJ.css +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/index-CuNOlaH7.js +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/harness/web/index.html +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/hwid.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/hwid_reset.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/image.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/localproxy.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/mcp.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/miniconda.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/netcheck.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/ngrok.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/opencode.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/plantuml.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_dns.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_dnswatch.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_dpi.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_hosts.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_page.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_probe.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/_spoofdpi.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/check.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/fix.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/probe.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/route/status.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/serp.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/site2s.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/ssh.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/storage.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/sysmon.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/tts.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/update.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/commands/wifi.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/console.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/doctor.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/google_oauth.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/migrate.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/oauth_flow.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/registry.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/store.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/credentials/sync.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/align.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/core.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/creds.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/errors.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/gemini.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/imaging/ncnn.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/mcp_registry.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/client.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/creds.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/errors.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/install.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/serp/render.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/chunking.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/core.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/creds.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/errors.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/gemini.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/http.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/openai.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/player.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli/tts/vbee.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/SOURCES.txt +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/dependency_links.txt +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/entry_points.txt +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/requires.txt +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/evo_cli.egg-info/top_level.txt +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/pyproject.toml +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/setup.cfg +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/__init__.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/fake_evo_agents.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/fixtures/hub/contract-0.2.0.json +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/fixtures/hub/mirror-demo.yaml +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_agent_toy.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_claude_code.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_cli.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_console.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_cred.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_download.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_fix_claude.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_gdrive.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_gh.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_harness.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_harness_clone.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_harness_dag.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_harness_hub.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_harness_show.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_image.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_mcp.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_ngrok.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_opencode.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_plantuml.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_route.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_serp.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_storage.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_sysmon.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_tts.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_update.py +0 -0
- {evo_cli-0.36.6 → evo_cli-0.37.1}/tests/test_wifi.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.37.1
|
|
@@ -286,6 +286,36 @@ def credentials(name, username, password_stdin, otp, qr, otp_url):
|
|
|
286
286
|
click.echo(f"Saved credentials for {name}. Sync explicitly with: evo cred sync push")
|
|
287
287
|
|
|
288
288
|
|
|
289
|
+
@openvpn_group.command(
|
|
290
|
+
"bypass",
|
|
291
|
+
help="Hosts kept off the tunnel while the LAN reaches them. Each connect probes them first (TCP, port 443 "
|
|
292
|
+
"unless host:port) and pins those that answer to the physical gateway; elsewhere they go through the VPN.",
|
|
293
|
+
)
|
|
294
|
+
@click.argument("name")
|
|
295
|
+
@click.argument("hosts", nargs=-1)
|
|
296
|
+
@click.option("--remove", is_flag=True, help="Remove the given hosts instead of adding them.")
|
|
297
|
+
@click.option("--clear", is_flag=True, help="Remove every host.")
|
|
298
|
+
def bypass(name, hosts, remove, clear):
|
|
299
|
+
profile = _guard(vpn.get_profile, name)
|
|
300
|
+
current = list(profile.get("bypass") or [])
|
|
301
|
+
given = [_guard(vpn.parse_bypass, host) for host in hosts]
|
|
302
|
+
if clear:
|
|
303
|
+
current = []
|
|
304
|
+
elif remove:
|
|
305
|
+
current = [host for host in current if host not in given]
|
|
306
|
+
else:
|
|
307
|
+
current = list(dict.fromkeys([*current, *given]))
|
|
308
|
+
if clear or given:
|
|
309
|
+
if current:
|
|
310
|
+
profile["bypass"] = current
|
|
311
|
+
else:
|
|
312
|
+
profile.pop("bypass", None)
|
|
313
|
+
_guard(vpn.save_profile, name, profile)
|
|
314
|
+
click.echo("\n".join(current) if current else f"{name}: no bypass hosts.")
|
|
315
|
+
if (clear or given) and _guard(vpn.request, name)["state"] != "STOPPED":
|
|
316
|
+
click.echo("Reconnect for the change to apply.", err=True)
|
|
317
|
+
|
|
318
|
+
|
|
289
319
|
@openvpn_group.command("otp", help="Print the current OTP for one explicitly selected profile (sensitive output).")
|
|
290
320
|
@click.argument("name", required=False)
|
|
291
321
|
def otp_code(name):
|
|
@@ -340,6 +370,19 @@ def _disconnect(name):
|
|
|
340
370
|
click.echo(f"{name}: stopped (OpenVPN Connect profiles unchanged).")
|
|
341
371
|
|
|
342
372
|
|
|
373
|
+
def _sudo_needs_password():
|
|
374
|
+
"""Whether sudo will ask the worker for a password, checked where the worker runs: in its own session.
|
|
375
|
+
|
|
376
|
+
sudo caches a password per terminal by default, and the worker has none, so a password typed in this
|
|
377
|
+
terminal a minute ago does not reach it. Asked from here, `sudo -n` would pass and the worker would get
|
|
378
|
+
an empty password; OpenVPN would then never start.
|
|
379
|
+
"""
|
|
380
|
+
check = subprocess.run(
|
|
381
|
+
["sudo", "-n", "true"], stdin=subprocess.DEVNULL, capture_output=True, start_new_session=True, check=False
|
|
382
|
+
)
|
|
383
|
+
return check.returncode != 0
|
|
384
|
+
|
|
385
|
+
|
|
343
386
|
@openvpn_group.command(
|
|
344
387
|
"connect", help="Connect in the background (OTP-aware worker), then show live status; Ctrl-C leaves it running."
|
|
345
388
|
)
|
|
@@ -376,7 +419,7 @@ def connect(name, timeout, sudo_password_stdin, watch):
|
|
|
376
419
|
if os.geteuid() != 0:
|
|
377
420
|
if sudo_password_stdin:
|
|
378
421
|
password = sys.stdin.readline().rstrip("\n")
|
|
379
|
-
elif
|
|
422
|
+
elif _sudo_needs_password():
|
|
380
423
|
password = getpass.getpass("sudo password (not stored): ")
|
|
381
424
|
state_path = Path(str(_guard(vpn.session_path, name)) + ".json")
|
|
382
425
|
state_path.unlink(missing_ok=True)
|
|
@@ -17,6 +17,7 @@ import subprocess
|
|
|
17
17
|
import sys
|
|
18
18
|
import time
|
|
19
19
|
from collections import deque
|
|
20
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
from urllib.parse import parse_qs, urlparse
|
|
22
23
|
|
|
@@ -245,16 +246,64 @@ def default_gateway():
|
|
|
245
246
|
|
|
246
247
|
def gateway_to(address):
|
|
247
248
|
"""The gateway ``address`` is routed through now, or None when it is on-link or the lookup fails."""
|
|
249
|
+
if sys.platform == "darwin":
|
|
250
|
+
command, pattern = ["route", "-n", "get", address], r"gateway:\s*(\S+)"
|
|
251
|
+
else:
|
|
252
|
+
command, pattern = ["ip", "-4", "route", "get", address], r"\bvia\s+(\S+)"
|
|
248
253
|
try:
|
|
249
|
-
output = subprocess.run(
|
|
250
|
-
["route", "-n", "get", address], capture_output=True, text=True, timeout=5, check=False
|
|
251
|
-
).stdout
|
|
254
|
+
output = subprocess.run(command, capture_output=True, text=True, timeout=5, check=False).stdout
|
|
252
255
|
except (OSError, subprocess.TimeoutExpired):
|
|
253
256
|
return None
|
|
254
|
-
match = re.search(
|
|
257
|
+
match = re.search(pattern, output)
|
|
255
258
|
return match.group(1) if match else None
|
|
256
259
|
|
|
257
260
|
|
|
261
|
+
BYPASS_PORT = 443
|
|
262
|
+
_LABEL = r"[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?"
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def parse_bypass(value):
|
|
266
|
+
"""A host to keep off the tunnel while the LAN reaches it: "host" or "host:port" (the port its probe uses)."""
|
|
267
|
+
host, colon, port = value.strip().lower().partition(":")
|
|
268
|
+
if colon and not (port.isdigit() and 0 < int(port) < 65536):
|
|
269
|
+
raise CredentialError(f"Invalid port in '{value}'.")
|
|
270
|
+
if len(host) > 253 or not re.fullmatch(rf"{_LABEL}(?:\.{_LABEL})*", host):
|
|
271
|
+
raise CredentialError(f"'{value}' is not a host name or IPv4 address.")
|
|
272
|
+
return f"{host}:{int(port)}" if colon and int(port) != BYPASS_PORT else host
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def lan_bypass(entries, timeout=1.5):
|
|
276
|
+
"""The addresses of ``entries`` that the LAN reaches now through the physical gateway, to pin there.
|
|
277
|
+
|
|
278
|
+
Called before OpenVPN starts, so a probe that answers went over the LAN. On a network that reaches the
|
|
279
|
+
host by itself (inside the network the VPN leads to), a pushed route would only send it into a tunnel
|
|
280
|
+
that may not carry it. Elsewhere the probe fails and the host goes through the VPN as before. Names
|
|
281
|
+
resolve now, with the system's DNS; an address that changes during the session is not followed.
|
|
282
|
+
"""
|
|
283
|
+
gateway = default_gateway() if entries else None
|
|
284
|
+
if not gateway:
|
|
285
|
+
return []
|
|
286
|
+
targets = []
|
|
287
|
+
for entry in entries:
|
|
288
|
+
host, _, port = parse_bypass(entry).partition(":")
|
|
289
|
+
for address in remote_addresses([host]):
|
|
290
|
+
if (address, int(port or BYPASS_PORT)) not in targets:
|
|
291
|
+
targets.append((address, int(port or BYPASS_PORT)))
|
|
292
|
+
|
|
293
|
+
def answers(target):
|
|
294
|
+
if gateway_to(target[0]) != gateway:
|
|
295
|
+
return False
|
|
296
|
+
try:
|
|
297
|
+
with socket.create_connection(target, timeout=timeout):
|
|
298
|
+
return True
|
|
299
|
+
except OSError:
|
|
300
|
+
return False
|
|
301
|
+
|
|
302
|
+
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
303
|
+
reached = list(pool.map(answers, targets))
|
|
304
|
+
return list(dict.fromkeys(address for (address, _), ok in zip(targets, reached) if ok))
|
|
305
|
+
|
|
306
|
+
|
|
258
307
|
def lan_resolvers(path="/var/run/resolv.conf"):
|
|
259
308
|
"""The system's DNS servers that are reached through the physical gateway (macOS).
|
|
260
309
|
|
|
@@ -770,6 +819,9 @@ def worker(name, timeout):
|
|
|
770
819
|
pinned = [*pinned, urlparse(profile["otp_url"]).hostname]
|
|
771
820
|
if sys.platform == "darwin":
|
|
772
821
|
pinned = [*pinned, *lan_resolvers()]
|
|
822
|
+
if bypass := lan_bypass(profile.get("bypass") or []):
|
|
823
|
+
log.append(f"{time.strftime('%H:%M:%S')} evo: kept on the LAN: {', '.join(bypass)}")
|
|
824
|
+
pinned = [*pinned, *bypass]
|
|
773
825
|
if pinned:
|
|
774
826
|
command = pin_remotes(command, pinned)
|
|
775
827
|
if os.geteuid() != 0:
|
|
@@ -873,6 +925,12 @@ def worker(name, timeout):
|
|
|
873
925
|
publish()
|
|
874
926
|
if stopping:
|
|
875
927
|
state = {"profile": name, "state": "STOPPED"}
|
|
928
|
+
elif management is None:
|
|
929
|
+
# --management-client connects back before OpenVPN touches the network, so it never ran.
|
|
930
|
+
raise CredentialError(
|
|
931
|
+
"OpenVPN never started: sudo refused the password (run connect again and retype it), "
|
|
932
|
+
"or OpenVPN rejected its options."
|
|
933
|
+
)
|
|
876
934
|
else:
|
|
877
935
|
reason = f" ({state['last_reason']})" if state.get("last_reason") else ""
|
|
878
936
|
raise CredentialError(
|
|
@@ -44,6 +44,7 @@ def test_commands_registered():
|
|
|
44
44
|
"status",
|
|
45
45
|
"disconnect",
|
|
46
46
|
"log",
|
|
47
|
+
"bypass",
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
|
|
@@ -204,15 +205,18 @@ def test_split_tunnel_pins_its_server_around_openvpn(tmp_path, monkeypatch, plat
|
|
|
204
205
|
|
|
205
206
|
|
|
206
207
|
@pytest.mark.parametrize(
|
|
207
|
-
"output,gateway",
|
|
208
|
+
"platform,output,gateway",
|
|
208
209
|
[
|
|
209
|
-
(" route to: 192.0.2.53\n gateway: 192.0.2.1\n interface: en0\n", "192.0.2.1"),
|
|
210
|
+
("darwin", " route to: 192.0.2.53\n gateway: 192.0.2.1\n interface: en0\n", "192.0.2.1"),
|
|
210
211
|
# On-link: no gateway line.
|
|
211
|
-
(" route to: 198.51.100.1\n interface: en0\n flags: <UP,HOST,DONE,LLINFO>\n", None),
|
|
212
|
-
("", None),
|
|
212
|
+
("darwin", " route to: 198.51.100.1\n interface: en0\n flags: <UP,HOST,DONE,LLINFO>\n", None),
|
|
213
|
+
("darwin", "", None),
|
|
214
|
+
("linux", "192.0.2.53 via 192.0.2.1 dev wlan0 src 192.0.2.7 uid 1000\n cache\n", "192.0.2.1"),
|
|
215
|
+
("linux", "198.51.100.1 dev wlan0 src 198.51.100.7 uid 1000\n cache\n", None),
|
|
213
216
|
],
|
|
214
217
|
)
|
|
215
|
-
def test_gateway_to_reads_the_route(monkeypatch, output, gateway):
|
|
218
|
+
def test_gateway_to_reads_the_route(monkeypatch, platform, output, gateway):
|
|
219
|
+
monkeypatch.setattr(vpn.sys, "platform", platform)
|
|
216
220
|
monkeypatch.setattr(vpn.subprocess, "run", lambda *a, **k: subprocess.CompletedProcess(a, 0, output, ""))
|
|
217
221
|
assert vpn.gateway_to("192.0.2.53") == gateway
|
|
218
222
|
|
|
@@ -259,6 +263,87 @@ def test_worker_pins_the_lan_resolvers_on_macos(store, monkeypatch, platform, pi
|
|
|
259
263
|
assert seen == pinned
|
|
260
264
|
|
|
261
265
|
|
|
266
|
+
@pytest.mark.parametrize(
|
|
267
|
+
"value,expected",
|
|
268
|
+
[
|
|
269
|
+
("Chat.Example.com", "chat.example.com"),
|
|
270
|
+
("api-1.example.com:8443", "api-1.example.com:8443"),
|
|
271
|
+
("api.example.com:443", "api.example.com"),
|
|
272
|
+
("192.0.2.10", "192.0.2.10"),
|
|
273
|
+
("bad_host.example", None),
|
|
274
|
+
("-lead.example", None),
|
|
275
|
+
("a.example:0", None),
|
|
276
|
+
("a.example:http", None),
|
|
277
|
+
("a.example;reboot", None),
|
|
278
|
+
("", None),
|
|
279
|
+
],
|
|
280
|
+
)
|
|
281
|
+
def test_parse_bypass(value, expected):
|
|
282
|
+
if expected is None:
|
|
283
|
+
with pytest.raises(CredentialError):
|
|
284
|
+
vpn.parse_bypass(value)
|
|
285
|
+
else:
|
|
286
|
+
assert vpn.parse_bypass(value) == expected
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_lan_bypass_pins_only_what_the_lan_answers(monkeypatch):
|
|
290
|
+
names = {
|
|
291
|
+
"chat.example": ["192.0.2.10", "192.0.2.11"],
|
|
292
|
+
"api.example": ["192.0.2.20"],
|
|
293
|
+
"far.example": ["198.51.100.5"],
|
|
294
|
+
}
|
|
295
|
+
monkeypatch.setattr(vpn, "default_gateway", lambda: "192.0.2.1")
|
|
296
|
+
monkeypatch.setattr(vpn, "remote_addresses", lambda hosts: names.get(hosts[0], []))
|
|
297
|
+
# 198.51.100.5 is behind another gateway (a tunnel already up): never pinned to the LAN's.
|
|
298
|
+
monkeypatch.setattr(vpn, "gateway_to", lambda address: "10.8.0.1" if address == "198.51.100.5" else "192.0.2.1")
|
|
299
|
+
probed = []
|
|
300
|
+
|
|
301
|
+
def connect(target, timeout):
|
|
302
|
+
probed.append(target)
|
|
303
|
+
if target == ("192.0.2.11", 443) or target[0] == "198.51.100.5":
|
|
304
|
+
raise OSError("no answer")
|
|
305
|
+
return io.BytesIO()
|
|
306
|
+
|
|
307
|
+
monkeypatch.setattr(vpn.socket, "create_connection", connect)
|
|
308
|
+
found = vpn.lan_bypass(["chat.example", "api.example:8443", "far.example", "gone.example"])
|
|
309
|
+
assert found == ["192.0.2.10", "192.0.2.20"]
|
|
310
|
+
assert ("192.0.2.20", 8443) in probed and all(address != "198.51.100.5" for address, _ in probed)
|
|
311
|
+
monkeypatch.setattr(vpn, "default_gateway", lambda: None)
|
|
312
|
+
assert vpn.lan_bypass(["chat.example"]) == []
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def test_bypass_command_adds_removes_and_clears(store, monkeypatch):
|
|
316
|
+
vpn.save_profile("m1", {"config": CERT_ONLY})
|
|
317
|
+
runner = CliRunner()
|
|
318
|
+
result = runner.invoke(cli, ["openvpn", "bypass", "m1", "Chat.example", "api.example:8443", "chat.example"])
|
|
319
|
+
assert result.exit_code == 0, result.output
|
|
320
|
+
assert vpn.get_profile("m1")["bypass"] == ["chat.example", "api.example:8443"]
|
|
321
|
+
assert runner.invoke(cli, ["openvpn", "bypass", "m1"]).output.split() == ["chat.example", "api.example:8443"]
|
|
322
|
+
assert runner.invoke(cli, ["openvpn", "bypass", "m1", "bad_host"]).exit_code == 1
|
|
323
|
+
runner.invoke(cli, ["openvpn", "bypass", "m1", "--remove", "chat.example"])
|
|
324
|
+
assert vpn.get_profile("m1")["bypass"] == ["api.example:8443"]
|
|
325
|
+
assert "no bypass hosts" in runner.invoke(cli, ["openvpn", "bypass", "m1", "--clear"]).output
|
|
326
|
+
assert "bypass" not in vpn.get_profile("m1")
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def test_worker_pins_the_bypass_hosts_the_lan_reaches(store, monkeypatch):
|
|
330
|
+
vpn.save_profile("m1", {"config": CERT_ONLY, "bypass": ["chat.example"]})
|
|
331
|
+
monkeypatch.setattr(sys, "stdin", io.StringIO("\n"))
|
|
332
|
+
monkeypatch.setattr(vpn.os, "geteuid", lambda: 0)
|
|
333
|
+
monkeypatch.setattr(vpn.shutil, "which", lambda _: "/fake/openvpn")
|
|
334
|
+
monkeypatch.setattr(vpn.sys, "platform", "linux")
|
|
335
|
+
monkeypatch.setattr(vpn, "lan_bypass", lambda entries: ["192.0.2.10"] if entries == ["chat.example"] else [])
|
|
336
|
+
seen = []
|
|
337
|
+
monkeypatch.setattr(vpn, "pin_remotes", lambda command, hosts: seen.append(hosts) or command)
|
|
338
|
+
|
|
339
|
+
def popen(command, **_):
|
|
340
|
+
raise OSError("stop before running anything")
|
|
341
|
+
|
|
342
|
+
monkeypatch.setattr(vpn.subprocess, "Popen", popen)
|
|
343
|
+
vpn.worker("m1", 10)
|
|
344
|
+
assert seen == [["192.0.2.10"]]
|
|
345
|
+
|
|
346
|
+
|
|
262
347
|
def test_no_pin_without_a_physical_gateway_or_address(monkeypatch):
|
|
263
348
|
monkeypatch.setattr(vpn, "default_gateway", lambda: None)
|
|
264
349
|
assert vpn.pin_remotes(["openvpn"], ["198.51.100.7 1194"]) == ["openvpn"]
|
|
@@ -806,6 +891,55 @@ def test_connect_stacks_a_split_tunnel_beside_a_full_one_only(store, monkeypatch
|
|
|
806
891
|
assert "default route" not in result.output and started, result.output
|
|
807
892
|
|
|
808
893
|
|
|
894
|
+
def test_connect_asks_for_sudo_when_the_workers_session_has_no_cached_password(store, monkeypatch):
|
|
895
|
+
# sudo caches a password per terminal; the worker runs in its own session, where that cache does not reach.
|
|
896
|
+
vpn.save_profile("m1", {"config": CONFIG, "username": "u", "password": "p"})
|
|
897
|
+
monkeypatch.setattr("evo_cli.commands.openvpn.shutil.which", lambda _: "/fake/openvpn")
|
|
898
|
+
monkeypatch.setattr("evo_cli.commands.openvpn.os.geteuid", lambda: 501)
|
|
899
|
+
checks, written = [], []
|
|
900
|
+
run = subprocess.run
|
|
901
|
+
|
|
902
|
+
def checking(command, **kwargs):
|
|
903
|
+
if command[:2] != ["sudo", "-n"]:
|
|
904
|
+
return run(command, **kwargs)
|
|
905
|
+
checks.append(kwargs.get("start_new_session"))
|
|
906
|
+
return subprocess.CompletedProcess(command, 1)
|
|
907
|
+
|
|
908
|
+
class Exited:
|
|
909
|
+
class stdin:
|
|
910
|
+
write, close = written.append, staticmethod(lambda: None)
|
|
911
|
+
|
|
912
|
+
def poll(self):
|
|
913
|
+
return 1
|
|
914
|
+
|
|
915
|
+
monkeypatch.setattr("evo_cli.commands.openvpn.subprocess.run", checking)
|
|
916
|
+
monkeypatch.setattr("evo_cli.commands.openvpn.getpass.getpass", lambda _: "sudo-secret")
|
|
917
|
+
monkeypatch.setattr("evo_cli.commands.openvpn.subprocess.Popen", lambda command, **_: Exited())
|
|
918
|
+
result = CliRunner().invoke(cli, ["openvpn", "connect", "m1", "--no-watch"])
|
|
919
|
+
assert checks == [True] and written == [b"sudo-secret\n"], result.output
|
|
920
|
+
assert "sudo-secret" not in result.output
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
def test_worker_says_openvpn_never_started_when_sudo_refuses(store, monkeypatch):
|
|
924
|
+
vpn.save_profile("m1", {"config": CONFIG, "username": "u", "password": "p"})
|
|
925
|
+
monkeypatch.setattr(sys, "stdin", io.StringIO("wrong\n"))
|
|
926
|
+
monkeypatch.setattr(vpn.os, "geteuid", lambda: 501)
|
|
927
|
+
monkeypatch.setattr(vpn.shutil, "which", lambda _: "/fake/openvpn")
|
|
928
|
+
popen = subprocess.Popen
|
|
929
|
+
refused = "import sys; sys.stdin.read(); raise SystemExit(1)"
|
|
930
|
+
started = []
|
|
931
|
+
|
|
932
|
+
def sudo(command, **kwargs):
|
|
933
|
+
started.append(command)
|
|
934
|
+
return popen([sys.executable, "-c", refused], **kwargs)
|
|
935
|
+
|
|
936
|
+
monkeypatch.setattr(vpn.subprocess, "Popen", sudo)
|
|
937
|
+
vpn.worker("m1", 10)
|
|
938
|
+
state = json.loads(Path(str(vpn.session_path("m1")) + ".json").read_text())
|
|
939
|
+
assert started[0][:2] == ["sudo", "-S"]
|
|
940
|
+
assert state["state"] == "FAILED" and state["error"].startswith("OpenVPN never started: sudo refused")
|
|
941
|
+
|
|
942
|
+
|
|
809
943
|
def test_cert_only_profile_connects_and_lists_without_credentials(store, monkeypatch):
|
|
810
944
|
vpn.save_profile("cert", {"config": CERT_ONLY})
|
|
811
945
|
vpn.save_profile("login", {"config": CONFIG})
|
evo_cli-0.36.6/evo_cli/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.36.6
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|