diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:19:15 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:19:15 +0200 |
| commit | d5ba9552e27bac71168178f73a4c977a4d36dc1c (patch) | |
| tree | 1f0e08edc1bbad0b419042bc35ba36c7a62897b5 /packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py | |
| parent | c3d41d1b4f042d09a637b375ce930190b7ea0d8c (diff) | |
| download | meshbay-d5ba9552e27bac71168178f73a4c977a4d36dc1c.tar.gz | |
fix(node): the answer log names its host addresses
aiortc ends a host candidate line at `typ host`, so the match on
" typ host " found none and logged `host: none` for every answer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py index fea642a5..3a9c2fa5 100644 --- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py +++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py @@ -85,6 +85,18 @@ MAX_PEER_SESSIONS_PER_ACCOUNT = MAX_PEER_SESSIONS // 2 UNAUTHENTICATED_SESSION_TIMEOUT = 60 # seconds +def _host_addresses(sdp: str) -> set[str]: + """The host addresses an SDP offers. A candidate line ends at `typ host` + when nothing follows it, as aiortc writes them: matched by field, not by + `" typ host "`, which found none and logged `host: none` for every answer.""" + addresses: set[str] = set() + for line in sdp.splitlines(): + parts = line.split() + if line.startswith("a=candidate:") and parts[6:8] == ["typ", "host"]: + addresses.add(parts[4]) + return addresses + + class WebRTCPeerSession( DispatchMixin, AdminMixin, AdmissionMixin, BlobsMixin, ChatMixin, FilesMixin, GroupOpsMixin, HandshakeMixin, NodeOpsMixin, TransferMixin, UploadMixin, @@ -404,12 +416,7 @@ class WebRTCTransport: # anything that peer could route to at all — on a NAT'd host or a VM the # only host candidate is an address no one else can reach, and the log # otherwise looks identical to a working connection. - host_addrs: set[str] = set() - for line in answer_sdp.splitlines(): - if line.startswith("a=candidate:") and " typ host " in line: - parts = line.split() - if len(parts) > 5: - host_addrs.add(parts[4]) + host_addrs = _host_addresses(answer_sdp) log.info( "WebRTC answer ready for peer=%s (ICE gather %.2fs, host: %s, %d srflx)", peer_id, time.monotonic() - gather_start, |