blob: bef7c87e5e1e673c9df491bd0fb7242002a2501e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
}
|