Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1574,15 +1574,20 @@ func (a *Agent) sendBindingSuccess(m *stun.Message, local, remote Candidate) {
return
}

if out, err := stun.Build(m, stun.BindingSuccess,
attributes := []stun.Setter{
m,
stun.BindingSuccess,
&stun.XORMappedAddress{
IP: ip.AsSlice(),
Port: port,
},
}
attributes = append(attributes,
stun.NewShortTermIntegrity(a.localPwd),
stun.Fingerprint,
); err != nil {
a.log.Warnf("Failed to handle inbound ICE from: %s to: %s error: %s", local, remote, err)
stun.Fingerprint)

if out, err := stun.Build(attributes...); err != nil {
a.log.Errorf("failed to build binding success: %w", err)
} else {
if pair := a.findPair(local, remote); pair != nil {
pair.UpdateResponseSent()
Expand Down
44 changes: 29 additions & 15 deletions selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ func (s *controllingSelector) nominatePair(pair *CandidatePair) {
// order to nominate a candidate pair (Section 8.1.1). The controlled
// agent MUST NOT include the USE-CANDIDATE attribute in a Binding
// request.
msg, err := stun.Build(stun.BindingRequest, stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag+":"+s.agent.localUfrag),
attributes := []stun.Setter{
stun.BindingRequest,
stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag + ":" + s.agent.localUfrag),
UseCandidate(),
AttrControlling(s.agent.tieBreaker),
PriorityAttr(pair.Local.Priority()),
}
attributes = append(attributes,
stun.NewShortTermIntegrity(s.agent.remotePwd),
stun.Fingerprint,
)
stun.Fingerprint)
msg, err := stun.Build(attributes...)
if err != nil {
s.log.Error(err.Error())
s.log.Errorf("failed to build binding request for nomination: %w", err)

return
}
Expand Down Expand Up @@ -191,15 +195,20 @@ func (s *controllingSelector) HandleSuccessResponse(m *stun.Message, local, remo
}

func (s *controllingSelector) PingCandidate(local, remote Candidate) {
msg, err := stun.Build(stun.BindingRequest, stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag+":"+s.agent.localUfrag),
attributes := []stun.Setter{
stun.BindingRequest,
stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag + ":" + s.agent.localUfrag),
AttrControlling(s.agent.tieBreaker),
PriorityAttr(local.Priority()),
}
attributes = append(attributes,
stun.NewShortTermIntegrity(s.agent.remotePwd),
stun.Fingerprint,
)
stun.Fingerprint)

msg, err := stun.Build(attributes...)
if err != nil {
s.log.Error(err.Error())
s.log.Errorf("failed to build binding request for ping (controlling): %w", err)

return
}
Expand Down Expand Up @@ -338,15 +347,20 @@ func (s *controlledSelector) ContactCandidates() {
}

func (s *controlledSelector) PingCandidate(local, remote Candidate) {
msg, err := stun.Build(stun.BindingRequest, stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag+":"+s.agent.localUfrag),
attributes := []stun.Setter{
stun.BindingRequest,
stun.TransactionID,
stun.NewUsername(s.agent.remoteUfrag + ":" + s.agent.localUfrag),
AttrControlled(s.agent.tieBreaker),
PriorityAttr(local.Priority()),
}
attributes = append(attributes,
stun.NewShortTermIntegrity(s.agent.remotePwd),
stun.Fingerprint,
)
stun.Fingerprint)

msg, err := stun.Build(attributes...)
if err != nil {
s.log.Error(err.Error())
s.log.Errorf("failed to build binding request for ping (controlled): %w", err)

return
}
Expand Down
Loading