Skip to content

Commit

Permalink
Update module github.com/pion/ice/v2 to v2.3.24
Browse files Browse the repository at this point in the history
Generated by renovateBot
  • Loading branch information
renovate[bot] authored and Sean-Der committed May 2, 2024
1 parent e7cf3ba commit 7cad104
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/pion/datachannel v1.5.5
github.com/pion/dtls/v2 v2.2.7
github.com/pion/ice/v2 v2.3.15
github.com/pion/ice/v2 v2.3.24
github.com/pion/interceptor v0.1.25
github.com/pion/logging v0.2.2
github.com/pion/randutil v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew
github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0=
github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8=
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
github.com/pion/ice/v2 v2.3.15 h1:oCGVqnd6OWmJr4I6eQwSWn8VJDF45wIXFTjV3tyyris=
github.com/pion/ice/v2 v2.3.15/go.mod h1:KXJJcZK7E8WzrBEYnV4UtqEZsGeWfHxsNqhVcVvgjxw=
github.com/pion/ice/v2 v2.3.24 h1:RYgzhH/u5lH0XO+ABatVKCtRd+4U1GEaCXSMjNr13tI=
github.com/pion/ice/v2 v2.3.24/go.mod h1:KXJJcZK7E8WzrBEYnV4UtqEZsGeWfHxsNqhVcVvgjxw=
github.com/pion/interceptor v0.1.25 h1:pwY9r7P6ToQ3+IF0bajN0xmk/fNw/suTgaTdlwTDmhc=
github.com/pion/interceptor v0.1.25/go.mod h1:wkbPYAak5zKsfpVDYMtEfWEy8D4zL+rpxCxPImLOg3Y=
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
Expand Down
1 change: 1 addition & 0 deletions icegatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (g *ICEGatherer) createAgent() error {
UDPMux: g.api.settingEngine.iceUDPMux,
ProxyDialer: g.api.settingEngine.iceProxyDialer,
DisableActiveTCP: g.api.settingEngine.iceDisableActiveTCP,
BindingRequestHandler: g.api.settingEngine.iceBindingRequestHandler,
}

requestedNetworkTypes := g.api.settingEngine.candidates.ICENetworkTypes
Expand Down
11 changes: 11 additions & 0 deletions settingengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
dtlsElliptic "github.com/pion/dtls/v2/pkg/crypto/elliptic"
"github.com/pion/ice/v2"
"github.com/pion/logging"
"github.com/pion/stun"
"github.com/pion/transport/v2"
"github.com/pion/transport/v2/packetio"
"github.com/pion/transport/v2/vnet"
Expand Down Expand Up @@ -89,6 +90,7 @@ type SettingEngine struct {
iceUDPMux ice.UDPMux
iceProxyDialer proxy.Dialer
iceDisableActiveTCP bool
iceBindingRequestHandler func(m *stun.Message, local, remote ice.Candidate, pair *ice.CandidatePair) bool
disableMediaEngineCopy bool
srtpProtectionProfiles []dtls.SRTPProtectionProfile
receiveMTU uint
Expand Down Expand Up @@ -442,3 +444,12 @@ func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32)
func (e *SettingEngine) EnableSCTPZeroChecksum(isEnabled bool) {
e.sctp.enableZeroChecksum = isEnabled
}

// SetICEBindingRequestHandler sets a callback that is fired on a STUN BindingRequest
// This allows users to do things like
// - Log incoming Binding Requests for debugging
// - Implement draft-thatcher-ice-renomination
// - Implement custom CandidatePair switching logic
func (e *SettingEngine) SetICEBindingRequestHandler(bindingRequestHandler func(m *stun.Message, local, remote ice.Candidate, pair *ice.CandidatePair) bool) {
e.iceBindingRequestHandler = bindingRequestHandler
}
31 changes: 31 additions & 0 deletions settingengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"time"

"github.com/pion/dtls/v2/pkg/crypto/elliptic"
"github.com/pion/ice/v2"
"github.com/pion/stun"
"github.com/pion/transport/v2/test"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -269,3 +271,32 @@ func TestSetSCTPMaxReceiverBufferSize(t *testing.T) {
s.SetSCTPMaxReceiveBufferSize(expSize)
assert.Equal(t, expSize, s.sctp.maxReceiveBufferSize)
}

func TestSetICEBindingRequestHandler(t *testing.T) {
seenICEControlled, seenICEControlledCancel := context.WithCancel(context.Background())
seenICEControlling, seenICEControllingCancel := context.WithCancel(context.Background())

s := SettingEngine{}
s.SetICEBindingRequestHandler(func(m *stun.Message, _, _ ice.Candidate, _ *ice.CandidatePair) bool {
for _, a := range m.Attributes {
switch a.Type {
case stun.AttrICEControlled:
seenICEControlledCancel()
case stun.AttrICEControlling:
seenICEControllingCancel()
default:
}
}

return false
})

pcOffer, pcAnswer, err := NewAPI(WithSettingEngine(s)).newPair(Configuration{})
assert.NoError(t, err)

assert.NoError(t, signalPair(pcOffer, pcAnswer))

<-seenICEControlled.Done()
<-seenICEControlling.Done()
closePairNow(t, pcOffer, pcAnswer)
}

0 comments on commit 7cad104

Please sign in to comment.