mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-11 02:12:04 +03:00
extract NDT7 consent check into a helper function
This commit is contained in:
parent
d2ab0caafd
commit
fc37ff369d
3 changed files with 19 additions and 11 deletions
|
|
@ -493,6 +493,23 @@ async def diagnose(settings: Settings, options: Options) -> tuple[dict, list[Pat
|
|||
return report, paths
|
||||
|
||||
|
||||
def _check_ndt7_consent(settings: Settings) -> bool:
|
||||
consent_marker = Path(settings.output.cache_dir) / "ndt7_consent"
|
||||
if consent_marker.exists():
|
||||
return True
|
||||
|
||||
console.print(f"[yellow]{NDT7_CONSENT_NOTICE}[/yellow]")
|
||||
if not sys.stdin.isatty():
|
||||
return True
|
||||
|
||||
if typer.confirm("Continue with NDT7?", default=False):
|
||||
consent_marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
consent_marker.write_text("consented\n", encoding="utf-8")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@app.command()
|
||||
def run(
|
||||
full: bool = typer.Option(False, "--full", help="Full run: speedtest and full MTR cycles."),
|
||||
|
|
@ -569,15 +586,7 @@ def run(
|
|||
finally:
|
||||
probe.close()
|
||||
if ndt7:
|
||||
consent_marker = Path(settings.output.cache_dir) / "ndt7_consent"
|
||||
if not consent_marker.exists():
|
||||
console.print(f"[yellow]{NDT7_CONSENT_NOTICE}[/yellow]")
|
||||
if sys.stdin.isatty():
|
||||
if typer.confirm("Continue with NDT7?", default=False):
|
||||
consent_marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
consent_marker.write_text("consented\n", encoding="utf-8")
|
||||
else:
|
||||
options.ndt7 = False
|
||||
options.ndt7 = _check_ndt7_consent(settings)
|
||||
if tcp_trace:
|
||||
console.print(
|
||||
"[yellow]--tcp-trace needs Npcap (Windows) or root (Unix) and the `tcptrace` extra; "
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from netsleuth.bgp import (
|
||||
classify_stability,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ def test_bufferbloat_delta_needs_both_a_baseline_and_samples():
|
|||
assert bufferbloat_delta(12.0, []) is None
|
||||
|
||||
|
||||
from netsleuth.models import SpeedResult, TierAttempt
|
||||
from netsleuth.models import SpeedResult
|
||||
from netsleuth.speed import NDT7_CONSENT_NOTICE, run_speed_cascade
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue