Skip to content

Commit

Permalink
chore: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Feb 20, 2025
1 parent 20e8844 commit cc7fcfe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/transport-webrtc/src/private-to-public/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export class WebRTCDirectListener extends TypedEventEmitter<ListenerEvents> impl
// if the server has not been started yet, or the port is a wildcard port
// and there is already a wildcard port for this address family, start a new
// UDP mux server
if (existingServer == null || (port === 0 && existingServer.port === 0 && ((existingServer.isIPv4 && isIPv4(host)) || (existingServer.isIPv6 && isIPv6(host))))) {
const wildcardPorts = port === 0 && existingServer?.port === 0
const sameAddressFamily = (existingServer?.isIPv4 === true && isIPv4(host)) || (existingServer?.isIPv6 === true && isIPv6(host))

if (existingServer == null || (wildcardPorts && sameAddressFamily)) {
existingServer = this.startUDPMuxServer(host, port)
this.servers.push(existingServer)
}
Expand Down

0 comments on commit cc7fcfe

Please sign in to comment.