summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/ice/v2/stun.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/pion/ice/v2/stun.go')
-rw-r--r--vendor/github.com/pion/ice/v2/stun.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/pion/ice/v2/stun.go b/vendor/github.com/pion/ice/v2/stun.go
new file mode 100644
index 0000000..bef7c87
--- /dev/null
+++ b/vendor/github.com/pion/ice/v2/stun.go
@@ -0,0 +1,24 @@
+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)
+}