// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage allocationimport ()// Protocol is an enum for relay protocol.typeProtocoluint8// Network protocols for relay.const (UDPProtocol = iotaTCP)// FiveTuple is the combination (client IP address and port, server IP// address and port, and transport protocol (currently one of UDP,// TCP, or TLS)) used to communicate between the client and the// server. The 5-tuple uniquely identifies this communication// stream. The 5-tuple also uniquely identifies the Allocation on// the server.typeFiveTuplestruct {Protocol SrcAddr, DstAddr net.Addr}// Equal asserts if two FiveTuples are equal.func ( *FiveTuple) ( *FiveTuple) bool {return .Fingerprint() == .Fingerprint()}// FiveTupleFingerprint is a comparable representation of a FiveTuple.typeFiveTupleFingerprintstruct { srcIP, dstIP [16]byte srcPort, dstPort uint16 protocol Protocol}// Fingerprint is the identity of a FiveTuple.func ( *FiveTuple) () ( FiveTupleFingerprint) { , := netAddrIPAndPort(.SrcAddr)copy(.srcIP[:], ) .srcPort = , := netAddrIPAndPort(.DstAddr)copy(.dstIP[:], ) .dstPort = .protocol = .Protocolreturn}func netAddrIPAndPort( net.Addr) (net.IP, uint16) {switch a := .(type) {case *net.UDPAddr:return .IP.To16(), uint16(.Port) // nolint:gosec // G115case *net.TCPAddr:return .IP.To16(), uint16(.Port) // nolint:gosec // G115default:returnnil, 0 }}
The pages are generated with Goldsv0.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.