// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package proto

import (
	

	
)

// PeerAddress implements XOR-PEER-ADDRESS attribute.
//
// The XOR-PEER-ADDRESS specifies the address and port of the peer as
// seen from the TURN server. (For example, the peer's server-reflexive
// transport address if the peer is behind a NAT.)
//
// RFC 5766 Section 14.3.
type PeerAddress struct {
	IP   net.IP
	Port int
}

func ( PeerAddress) () string {
	return stun.XORMappedAddress().String()
}

// AddTo adds XOR-PEER-ADDRESS to message.
func ( PeerAddress) ( *stun.Message) error {
	return stun.XORMappedAddress().AddToAs(, stun.AttrXORPeerAddress)
}

// GetFrom decodes XOR-PEER-ADDRESS from message.
func ( *PeerAddress) ( *stun.Message) error {
	return (*stun.XORMappedAddress)().GetFromAs(, stun.AttrXORPeerAddress)
}

// XORPeerAddress implements XOR-PEER-ADDRESS attribute.
//
// The XOR-PEER-ADDRESS specifies the address and port of the peer as
// seen from the TURN server. (For example, the peer's server-reflexive
// transport address if the peer is behind a NAT.)
//
// RFC 5766 Section 14.3.
type XORPeerAddress = PeerAddress