mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-11 01:02:10 +03:00
docs: add docstrings to score_vpn and assess_vpn
This commit is contained in:
parent
d4b4ffb1fe
commit
eac946d9b9
1 changed files with 23 additions and 0 deletions
|
|
@ -283,6 +283,17 @@ def gather_vpn_signals(ctx: VpnContext) -> list[Signal]:
|
||||||
|
|
||||||
|
|
||||||
def score_vpn(signals: list[Signal], bands: VpnBands) -> tuple[str, float]:
|
def score_vpn(signals: list[Signal], bands: VpnBands) -> tuple[str, float]:
|
||||||
|
"""Calculate VPN confidence score from observed signals.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
signals: List of Signal objects with weights and observed flags.
|
||||||
|
bands: VpnBands with 'likely' and 'confirmed' thresholds.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A tuple of (verdict, confidence) where verdict is one of
|
||||||
|
'confirmed', 'likely', or 'none', and confidence is a float
|
||||||
|
between 0.0 and 1.0 representing the accumulated weight.
|
||||||
|
"""
|
||||||
total = 0.0
|
total = 0.0
|
||||||
for s in signals:
|
for s in signals:
|
||||||
if not s.observed:
|
if not s.observed:
|
||||||
|
|
@ -302,6 +313,18 @@ def assess_vpn(
|
||||||
tunnel_iface: str | None,
|
tunnel_iface: str | None,
|
||||||
dns_leak: DnsLeak | None,
|
dns_leak: DnsLeak | None,
|
||||||
) -> VpnAssessment:
|
) -> VpnAssessment:
|
||||||
|
"""Build a VPN assessment from signals and context.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
signals: List of Signal objects from gather_vpn_signals.
|
||||||
|
bands: VpnBands containing verdict thresholds.
|
||||||
|
tunnel_iface: Name of the tunnel interface if detected.
|
||||||
|
dns_leak: DnsLeak object if DNS leak testing was performed.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A VpnAssessment object with verdict, confidence score,
|
||||||
|
all signals, tunnel interface name, and DNS leak data.
|
||||||
|
"""
|
||||||
verdict, confidence = score_vpn(signals, bands)
|
verdict, confidence = score_vpn(signals, bands)
|
||||||
return VpnAssessment(
|
return VpnAssessment(
|
||||||
verdict=verdict,
|
verdict=verdict,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue