Source File
evenport.go
Belonging Package
github.com/pion/turn/v4/internal/proto
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage protoimport// EvenPort represents EVEN-PORT attribute.//// This attribute allows the client to request that the port in the// relayed transport address be even, and (optionally) that the server// reserve the next-higher port number.//// RFC 5766 Section 14.6.type EvenPort struct {// ReservePort means that the server is requested to reserve// the next-higher port number (on the same IP address)// for a subsequent allocation.ReservePort bool}func ( EvenPort) () string {if .ReservePort {return "reserve: true"}return "reserve: false"}const (evenPortSize = 1firstBitSet = (1 << 8) - 1 // 0b100000000)// AddTo adds EVEN-PORT to message.func ( EvenPort) ( *stun.Message) error {:= make([]byte, evenPortSize)if .ReservePort {// Set first bit to 1.[0] = firstBitSet}.Add(stun.AttrEvenPort, )return nil}// GetFrom decodes EVEN-PORT from message.func ( *EvenPort) ( *stun.Message) error {, := .Get(stun.AttrEvenPort)if != nil {return}if = stun.CheckSize(stun.AttrEvenPort, len(), evenPortSize); != nil {return}if [0]&firstBitSet > 0 {.ReservePort = true}return nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |