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

package proto

import (
	

	
)

// RelayedAddress implements XOR-RELAYED-ADDRESS attribute.
//
// It specifies the address and port that the server allocated to the
// client. It is encoded in the same way as XOR-MAPPED-ADDRESS.
//
// RFC 5766 Section 14.5.
type RelayedAddress struct {
	IP   net.IP
	Port int
}

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

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

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

// XORRelayedAddress implements XOR-RELAYED-ADDRESS attribute.
//
// It specifies the address and port that the server allocated to the
// client. It is encoded in the same way as XOR-MAPPED-ADDRESS.
//
// RFC 5766 Section 14.5.
type XORRelayedAddress = RelayedAddress