Files
ice/stun.go
Aleksandr Razumov 35330ae9e7 Use merged pion/stun instead of gortc/stun
The only thing that should be changed after complete merge is version
2019-05-21 15:53:04 -07:00

29 lines
632 B
Go

package ice
import (
"encoding/binary"
"fmt"
"github.com/pion/stun"
)
// bin is shorthand for BigEndian.
var bin = binary.BigEndian
func assertInboundUsername(m *stun.Message, expectedUsername string) error {
var username stun.Username
if err := username.GetFrom(m); err != nil {
return err
}
if string(username) != expectedUsername {
return fmt.Errorf("username mismatch expected(%x) actual(%x)", expectedUsername, string(username))
}
return nil
}
func assertInboundMessageIntegrity(m *stun.Message, key []byte) error {
messageIntegrityAttr := stun.MessageIntegrity(key)
return messageIntegrityAttr.Check(m)
}