// For advanced use with a custom generator and interval.
se := webrtc.SettingEngine{}
interval := 2 * time.Second
customGen := func() uint32 { return uint32(time.Now().UnixNano()) } // example
if err := se.SetICERenomination(
webrtc.WithRenominationGenerator(customGen),
webrtc.WithRenominationInterval(interval),
); err != nil {
log.Println(err)
}
The new API, SetICEAddressRewriteRules(rules ...ICEAddressRewriteRule) error, rewrites the IP addresses embedded in gathered ICE candidates.
se := webrtc.SettingEngine{}
_ = se.SetICEAddressRewriteRules(
webrtc.ICEAddressRewriteRule{
Local: "10.0.0.12",
External: []string{"203.0.113.10"},
// Mode omitted, defaults to Replace.
},
)
api := webrtc.NewAPI(webrtc.WithSettingEngine(se))
// pc, _ := api.NewPeerConnection(...)
// For more advanced use.
se := webrtc.SettingEngine{}
se.SetICEAddressRewriteRules(
// Allow eth0 (map RFC1918 to public 203.0.113.10)
webrtc.ICEAddressRewriteRule{
Iface: "eth0",
CIDR: "10.0.0.0/8",
External: []string{"203.0.113.10"},
Mode: webrtc.ICEAddressRewriteReplace,
},
// Allow eth1 (map 192.168/16 to public 198.51.100.20)
webrtc.ICEAddressRewriteRule{
Iface: "eth1",
CIDR: "192.168.0.0/16",
External: []string{"198.51.100.20"},
Mode: webrtc.ICEAddressRewriteReplace,
},
// Catch-all: drop any other IPv4 host candidates
webrtc.ICEAddressRewriteRule{
CIDR: "0.0.0.0/0",
Mode: webrtc.ICEAddressRewriteReplace,
External: nil, // drop
},
// Catch-all: drop any other IPv6 host candidates
webrtc.ICEAddressRewriteRule{
CIDR: "::/0",
Mode: webrtc.ICEAddressRewriteReplace,
External: nil, // drop
},
)
@3drx @5ur3 @aalekseevx @aankur @adeithe @alexhu-oai @amanakin @andjcoll @anshulmalik @arindamnayak @arjunshajitech @asayyah @astroza @at-wat @atoppi @bajam-genetec @berkant @boks1971 @britblue @cgojin @chaturvedishilpa @chenosaurus @cmorillas @cnderrauber @copilot @cppcoffee @debugmenot @drshrey @enobufs @frantabot @ghost @hackerman-ru @hanguyen-nuro @hexbabe @jackielii @jasmoran @jiajieli-dev @joeturki @juliapixel @kevmo314 @kmansoft @lars-sto @lidian-runner @lkang-nuro @mengelbart @mikeyg42 @miya-masa @mrpomidoro @nils-ohlmeier @olexandr88 @penhauer @philipch07 @pionbot @rg0now @ryanpotat @sean-der @setheck @sirzooro @sundenis @sunofcoder @sxmzou @theodorsm @thesyncim @tmatth @trs00 @valorzard @wrangelvid @xinze-zheng @yannismate @yzhao-nuro