From 05a28b3ee3db3cc4a68627d80c639055e08d796d Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Fri, 3 May 2019 09:33:50 -0300 Subject: [PATCH] Handle INDICATION messages Handle keepAlive messages --- agent.go | 13 +++++++++---- candidatepair.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/agent.go b/agent.go index 8b594e6..a735da1 100644 --- a/agent.go +++ b/agent.go @@ -612,8 +612,11 @@ func (a *Agent) handleInbound(m *stun.Message, local *Candidate, remote net.Addr return } - if m.Method != stun.MethodBinding || !(m.Class == stun.ClassSuccessResponse || m.Class == stun.ClassRequest) { - a.log.Tracef("unhandled STUN from %s to %s class(%s) method(%s)", remote.String(), local.String(), m.Method.String(), m.Class.String()) + if m.Method != stun.MethodBinding || + !(m.Class == stun.ClassSuccessResponse || + m.Class == stun.ClassRequest || + m.Class == stun.ClassIndication) { + a.log.Tracef("unhandled STUN from %s to %s class(%s) method(%s)", remote.String(), local.String(), m.Class.String(), m.Method.String()) return } @@ -645,7 +648,7 @@ func (a *Agent) handleInbound(m *stun.Message, local *Candidate, remote net.Addr } a.selector.HandleSucessResponse(m, local, remoteCandidate, remote) - } else { + } else if m.Class == stun.ClassRequest { if err = assertInboundUsername(m, a.localUfrag+":"+a.remoteUfrag); err != nil { a.log.Warnf("discard message from (%s), %v", remote, err) return @@ -677,7 +680,9 @@ func (a *Agent) handleInbound(m *stun.Message, local *Candidate, remote net.Addr a.selector.HandleBindingRequest(m, local, remoteCandidate) } - remoteCandidate.seen(false) + if remoteCandidate != nil { + remoteCandidate.seen(false) + } } // noSTUNSeen processes non STUN traffic from a remote candidate, diff --git a/candidatepair.go b/candidatepair.go index 1e9670a..4a3ce0b 100644 --- a/candidatepair.go +++ b/candidatepair.go @@ -93,7 +93,7 @@ func (a *Agent) keepaliveCandidate(local, remote *Candidate) { ) if err != nil { - a.log.Warn(err.Error()) + a.log.Error(err.Error()) return }