Update SettingEngine to use named return values

The behavior of SetInterfaceFilter and SetIPFilter isn't obvious. Name
the bool so the user understands the behavior from the function
definition.
This commit is contained in:
WofWca
2024-11-25 00:58:55 +04:00
committed by Sean DuBois
parent 7c76e0907b
commit 345d574c36

View File

@@ -48,8 +48,8 @@ type SettingEngine struct {
candidates struct { candidates struct {
ICELite bool ICELite bool
ICENetworkTypes []NetworkType ICENetworkTypes []NetworkType
InterfaceFilter func(string) bool InterfaceFilter func(string) (keep bool)
IPFilter func(net.IP) bool IPFilter func(net.IP) (keep bool)
NAT1To1IPs []string NAT1To1IPs []string
NAT1To1IPCandidateType ICECandidateType NAT1To1IPCandidateType ICECandidateType
MulticastDNSMode ice.MulticastDNSMode MulticastDNSMode ice.MulticastDNSMode
@@ -201,7 +201,7 @@ func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType) {
// This can be used to exclude certain network interfaces from ICE. Which may be // This can be used to exclude certain network interfaces from ICE. Which may be
// useful if you know a certain interface will never succeed, or if you wish to reduce // useful if you know a certain interface will never succeed, or if you wish to reduce
// the amount of information you wish to expose to the remote peer // the amount of information you wish to expose to the remote peer
func (e *SettingEngine) SetInterfaceFilter(filter func(string) bool) { func (e *SettingEngine) SetInterfaceFilter(filter func(string) (keep bool)) {
e.candidates.InterfaceFilter = filter e.candidates.InterfaceFilter = filter
} }
@@ -209,7 +209,7 @@ func (e *SettingEngine) SetInterfaceFilter(filter func(string) bool) {
// This can be used to exclude certain ip from ICE. Which may be // This can be used to exclude certain ip from ICE. Which may be
// useful if you know a certain ip will never succeed, or if you wish to reduce // useful if you know a certain ip will never succeed, or if you wish to reduce
// the amount of information you wish to expose to the remote peer // the amount of information you wish to expose to the remote peer
func (e *SettingEngine) SetIPFilter(filter func(net.IP) bool) { func (e *SettingEngine) SetIPFilter(filter func(net.IP) (keep bool)) {
e.candidates.IPFilter = filter e.candidates.IPFilter = filter
} }