Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions keepercommander/commands/tunnel_and_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ def _test_https(cls, hostname: str, port: int = 443) -> Tuple[bool, str, int]:
conn.request('GET', '/', headers={'User-Agent': 'keeper-pam-diagnose/1.0'})
resp = conn.getresponse()
ms = int((time.monotonic() - t0) * 1000)
return 100 <= resp.status < 600, f'HTTP {resp.status} (reachable)', ms
return 100 <= resp.status < 400, f'HTTP {resp.status} (reachable)', ms
except Exception as exc:
return False, str(exc)[:60], int((time.monotonic() - t0) * 1000)
finally:
Expand All @@ -1488,7 +1488,7 @@ def _test_websocket(cls, hostname: str, port: int = 443) -> Tuple[bool, str, int
})
resp = conn.getresponse()
ms = int((time.monotonic() - t0) * 1000)
return 100 <= resp.status < 600, f'HTTP {resp.status}', ms
return 100 <= resp.status < 400, f'HTTP {resp.status}', ms
except Exception as exc:
return False, str(exc)[:60], int((time.monotonic() - t0) * 1000)
finally:
Expand Down Expand Up @@ -1642,7 +1642,7 @@ def execute(self, params, **kwargs):
'--turn-test / --stun-only requires a record argument: '
'pam tunnel diagnose <pamMachine-or-pamDirectory-UID> --turn-test')

server = params.server # e.g. "keepersecurity.com" or "https://qa.keepersecurity.com"
server = 'keepersecurity.us' if params.server == 'govcloud.keepersecurity.us' else params.server
server_host = get_keeper_server_hostname(server)
krelay_server = get_relay_host(params.server)
connect_host = get_router_host(params.server)
Expand All @@ -1651,7 +1651,7 @@ def execute(self, params, **kwargs):
self._print_header()
print()
now = datetime.datetime.utcnow()
region_label = 'US' if server_host == 'keepersecurity.com' else server_host.split('.')[0].upper()
region_label = 'US' if server == 'keepersecurity.com' else 'GOVCLOUD' if server == 'keepersecurity.us' else server.split('.')[-1].upper()
print(self._green(f' Region {region_label} \u00b7 {server}'))
print(self._green(f' Date {now.strftime("%Y-%m-%d %H:%M")} UTC'))
if record_name:
Expand Down Expand Up @@ -1736,7 +1736,7 @@ def _record(name: str, passed: bool, detail: str, ms: int):
print(row.rstrip())

passed_ports = sum(1 for _, ok, _ in port_results if ok)
print(f' {self._check()} {self._green(str(passed_ports))}/{len(port_results)} sampled ports reachable')
print(f' {self._check()}'+self._green(f' {str(passed_ports)}/{len(port_results)} sampled ports reachable'))
print()

# ── section 4: WebRTC connectivity (Rust library) ─────────────────────
Expand Down Expand Up @@ -1785,7 +1785,6 @@ def _record(name: str, passed: bool, detail: str, ms: int):
)
if output_format == 'json':
print(json.dumps(rust_results, indent=2))
return 0

# Fold Rust test results into the unified pass/fail accounting
for test in rust_results.get('test_results', []):
Expand Down Expand Up @@ -2620,8 +2619,6 @@ def _latency_sampler():
print(f' {self._dsep()}')
print()

return 0 if passed_total == total_checks else 1


class PAMConnectionEditCommand(Command):
choices = ['on', 'off', 'default']
Expand Down