1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

TEST: Upgrade pion to v3.2.9. (#3567)

------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
Winlin 2023-06-05 11:25:04 +08:00 committed by GitHub
parent 104cf14d68
commit df854339ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1383 changed files with 118469 additions and 41421 deletions

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package stun
import (
@ -26,6 +29,14 @@ type AlternateServer struct {
Port int
}
// ResponseOrigin represents RESPONSE-ORIGIN attribute.
//
// RFC 5780 Section 7.3
type ResponseOrigin struct {
IP net.IP
Port int
}
// OtherAddress represents OTHER-ADDRESS attribute.
//
// RFC 5780 Section 7.4
@ -37,20 +48,21 @@ type OtherAddress struct {
// AddTo adds ALTERNATE-SERVER attribute to message.
func (s *AlternateServer) AddTo(m *Message) error {
a := (*MappedAddress)(s)
return a.addAs(m, AttrAlternateServer)
return a.AddToAs(m, AttrAlternateServer)
}
// GetFrom decodes ALTERNATE-SERVER from message.
func (s *AlternateServer) GetFrom(m *Message) error {
a := (*MappedAddress)(s)
return a.getAs(m, AttrAlternateServer)
return a.GetFromAs(m, AttrAlternateServer)
}
func (a MappedAddress) String() string {
return net.JoinHostPort(a.IP.String(), strconv.Itoa(a.Port))
}
func (a *MappedAddress) getAs(m *Message, t AttrType) error {
// GetFromAs decodes MAPPED-ADDRESS value in message m as an attribute of type t.
func (a *MappedAddress) GetFromAs(m *Message, t AttrType) error {
v, err := m.Get(t)
if err != nil {
return err
@ -84,7 +96,8 @@ func (a *MappedAddress) getAs(m *Message, t AttrType) error {
return nil
}
func (a *MappedAddress) addAs(m *Message, t AttrType) error {
// AddToAs adds MAPPED-ADDRESS value to m as t attribute.
func (a *MappedAddress) AddToAs(m *Message, t AttrType) error {
var (
family = familyIPv4
ip = a.IP
@ -109,26 +122,42 @@ func (a *MappedAddress) addAs(m *Message, t AttrType) error {
// AddTo adds MAPPED-ADDRESS to message.
func (a *MappedAddress) AddTo(m *Message) error {
return a.addAs(m, AttrMappedAddress)
return a.AddToAs(m, AttrMappedAddress)
}
// GetFrom decodes MAPPED-ADDRESS from message.
func (a *MappedAddress) GetFrom(m *Message) error {
return a.getAs(m, AttrMappedAddress)
return a.GetFromAs(m, AttrMappedAddress)
}
// AddTo adds OTHER-ADDRESS attribute to message.
func (o *OtherAddress) AddTo(m *Message) error {
a := (*MappedAddress)(o)
return a.addAs(m, AttrOtherAddress)
return a.AddToAs(m, AttrOtherAddress)
}
// GetFrom decodes OTHER-ADDRESS from message.
func (o *OtherAddress) GetFrom(m *Message) error {
a := (*MappedAddress)(o)
return a.getAs(m, AttrOtherAddress)
return a.GetFromAs(m, AttrOtherAddress)
}
func (o OtherAddress) String() string {
return net.JoinHostPort(o.IP.String(), strconv.Itoa(o.Port))
}
// AddTo adds RESPONSE-ORIGIN attribute to message.
func (o *ResponseOrigin) AddTo(m *Message) error {
a := (*MappedAddress)(o)
return a.AddToAs(m, AttrResponseOrigin)
}
// GetFrom decodes RESPONSE-ORIGIN from message.
func (o *ResponseOrigin) GetFrom(m *Message) error {
a := (*MappedAddress)(o)
return a.GetFromAs(m, AttrResponseOrigin)
}
func (o ResponseOrigin) String() string {
return net.JoinHostPort(o.IP.String(), strconv.Itoa(o.Port))
}