shinyoshiaki / werift-webrtc

WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP/SRTP/WEBM/MP4
MIT License
482 stars 32 forks source link

interfaceAddresses should filter host addresses. #324

Closed koush closed 1 year ago

koush commented 1 year ago

I'm unsure if this is the correct way to do this: I need to filter what addresses are used in the ice gathering stage. For example, my server has 192.168.2.124 and 192.168.2.136. I would imagine that setting interfaceAddresses.udp4 to 191.168.2.124 would prevent anything but that interface address from being used. But it does not, and it sends the 192.168.2.136 candidate anyways.

As far as I can tell that option is used for STUN and TURN but not for local candidates, which seems incorrect. This fixes that issue.

koush commented 1 year ago

In any case, I think that the interface filters are very confusing currently. I think there should be a general callback function that provides interface filtering rather than a variety of options. Something like:

{
  interfaceAddressFilter:  (address: string, type = 'stun' | 'turn' | 'local') => boolean,
}

So that would start with local candidates. Then for each local candidate, it will be called again for stun and turn candidate generation.