MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / _parse_candidate_log

Function _parse_candidate_log

tests/test_p2p.py:356–379  ·  view source on GitHub ↗

Parse a verbose log file for local and remote candidate counts. Returns (local_dict, remote_dict) mapping candidate type -> count. Local = lines containing 'LocalCandidateAdded' (candidates this peer gathered). Remote = lines containing 'Got remote candidate' (candidates received

( filename )

Source from the content-addressed store, hash-verified

354 return [ '--mock-gateway', gateway, '--mock-nat', nat_type, '--mock-adapter', internal, '--mock-latency', str(latency_ms) ]
355
356def _parse_candidate_log( filename ):
357 """
358 Parse a verbose log file for local and remote candidate counts.
359 Returns (local_dict, remote_dict) mapping candidate type -> count.
360 Local = lines containing 'LocalCandidateAdded' (candidates this peer gathered).
361 Remote = lines containing 'Got remote candidate' (candidates received from peer).
362 """
363 local, remote = {}, {}
364 try:
365 with open( filename, 'rt', errors='replace' ) as f:
366 for line in f:
367 if 'LocalCandidateAdded' in line:
368 m = re.search( r'\btyp (\w+)', line )
369 if m:
370 t = m.group(1)
371 local[t] = local.get(t, 0) + 1
372 if 'Got remote candidate' in line:
373 m = re.search( r'\btyp (\w+)', line )
374 if m:
375 t = m.group(1)
376 remote[t] = remote.get(t, 0) + 1
377 except FileNotFoundError:
378 pass
379 return local, remote
380
381
382# Address used for "server is down" tests: valid loopback IP but no STUN/TURN listening.

Callers 2

ClientServerTestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected