Skip to content

Commit

Permalink
Update SettingEngine to use named return values
Browse files Browse the repository at this point in the history
The behavior of SetInterfaceFilter and SetIPFilter isn't obvious. Name
the bool so the user understands the behavior from the function
definition.
  • Loading branch information
WofWca authored and Sean-Der committed Nov 26, 2024
1 parent 7c76e09 commit 333cc2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions settingengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type SettingEngine struct {
candidates struct {
ICELite bool
ICENetworkTypes []NetworkType
InterfaceFilter func(string) bool
IPFilter func(net.IP) bool
InterfaceFilter func(string) (keep bool)
IPFilter func(net.IP) (keep bool)
NAT1To1IPs []string
NAT1To1IPCandidateType ICECandidateType
MulticastDNSMode ice.MulticastDNSMode
Expand Down Expand Up @@ -201,15 +201,15 @@ func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType) {
// 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
// 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)) {

Check warning on line 204 in settingengine.go

View check run for this annotation

Codecov / codecov/patch

settingengine.go#L204

Added line #L204 was not covered by tests
e.candidates.InterfaceFilter = filter
}

// SetIPFilter sets the filtering functions when gathering ICE candidates
// 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
// 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)) {

Check warning on line 212 in settingengine.go

View check run for this annotation

Codecov / codecov/patch

settingengine.go#L212

Added line #L212 was not covered by tests
e.candidates.IPFilter = filter
}

Expand Down

0 comments on commit 333cc2b

Please sign in to comment.