Use binding request for keepalive

instead of indication (to support consent refreshness)
This commit is contained in:
Hugo Arregui
2019-06-03 21:48:44 -07:00
committed by Sean DuBois
parent 3a5460c76b
commit 165d04e58f
2 changed files with 3 additions and 17 deletions
+3 -1
View File
@@ -549,7 +549,9 @@ func (a *Agent) checkKeepalive() {
if (a.keepaliveInterval != 0) &&
(time.Since(a.selectedPair.local.LastSent()) > a.keepaliveInterval) {
a.keepaliveCandidate(a.selectedPair.local, a.selectedPair.remote)
// we use binding request instead of indication to support refresh consent schemas
// see https://tools.ietf.org/html/rfc7675
a.selector.PingCandidate(a.selectedPair.local, a.selectedPair.remote)
}
}
-16
View File
@@ -105,22 +105,6 @@ func (p *candidatePair) Write(b []byte) (int, error) {
return p.local.writeTo(b, p.remote)
}
// keepaliveCandidate sends a STUN Binding Indication to the remote candidate
func (a *Agent) keepaliveCandidate(local, remote Candidate) {
msg, err := stun.Build(stun.NewType(stun.MethodBinding, stun.ClassIndication), stun.TransactionID,
stun.NewUsername(a.remoteUfrag+":"+a.localUfrag),
stun.NewShortTermIntegrity(a.remotePwd),
stun.Fingerprint,
)
if err != nil {
a.log.Error(err.Error())
return
}
a.sendSTUN(msg, local, remote)
}
func (a *Agent) sendSTUN(msg *stun.Message, local, remote Candidate) {
_, err := local.writeTo(msg.Raw, remote)
if err != nil {