status-go/vendor/github.com/pion/ice/v2/stun.go

25 lines
556 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package ice
import (
"fmt"
"github.com/pion/stun"
)
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("%w expected(%x) actual(%x)", errMismatchUsername, expectedUsername, string(username))
}
return nil
}
func assertInboundMessageIntegrity(m *stun.Message, key []byte) error {
messageIntegrityAttr := stun.MessageIntegrity(key)
return messageIntegrityAttr.Check(m)
}