Skip to content

STUN Requests are not filtered #727

@rahulshinde11

Description

@rahulshinde11

Your environment.

  • Version: v2.3.34
  • OS: Ubuntu 22

What did you do?

Force pion/ice to use a specific network interface for ICE gathering by using

settingEngine.SetInterfaceFilter(func(iface string) bool {
        return iface == "eth0" // wlan1
})

What did you expect?

I expect not to see any IP related to the filtered list. But I see the public IPs of both adapters

Here is the full example

package main

import (
	"fmt"

	"github.com/pion/webrtc/v3"
)

func main() {

	config := webrtc.Configuration{
		ICEServers: []webrtc.ICEServer{
			{
				URLs: []string{"stun:stun.l.google.com:19302"},
			},
		},
	}
	settingEngine := webrtc.SettingEngine{}
	settingEngine.SetInterfaceFilter(func(iface string) bool {
		return iface == "eth0" // wlan1
	})
	mediaEngine := webrtc.MediaEngine{}
	mediaEngine.RegisterDefaultCodecs()
	api := webrtc.NewAPI(webrtc.WithSettingEngine(settingEngine), webrtc.WithMediaEngine(&mediaEngine))
	peerConnection, _ := api.NewPeerConnection(config)
	peerConnection.OnICEGatheringStateChange(func(webrtc.ICEGathererState) {
		fmt.Println("ICE Gathering State has changed", peerConnection.ICEGatheringState())
	})

	peerConnection.OnICECandidate(func(c *webrtc.ICECandidate) {
		if c == nil {
			return
		}
		fmt.Println("ICE", c.ToJSON())
	})
	gatherComplete := webrtc.GatheringCompletePromise(peerConnection)
	offer, err := peerConnection.CreateOffer(nil)
	if err != nil {
		panic(err)
	} else if err = peerConnection.SetLocalDescription(offer); err != nil {
		panic(err)
	}
	<-gatherComplete
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions