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

package allocation

import (
	
	

	
)

const permissionTimeout = time.Duration(5) * time.Minute

// Permission represents a TURN permission. TURN permissions mimic the address-restricted
// filtering mechanism of NATs that comply with [RFC4787].
// See: https://tools.ietf.org/html/rfc5766#section-2.3
type Permission struct {
	Addr          net.Addr
	allocation    *Allocation
	lifetimeTimer *time.Timer
	log           logging.LeveledLogger
}

// NewPermission create a new Permission.
func ( net.Addr,  logging.LeveledLogger) *Permission {
	return &Permission{
		Addr: ,
		log:  ,
	}
}

func ( *Permission) ( time.Duration) {
	.lifetimeTimer = time.AfterFunc(, func() {
		.allocation.RemovePermission(.Addr)
	})
}

func ( *Permission) ( time.Duration) {
	if !.lifetimeTimer.Reset() {
		.log.Errorf("Failed to reset permission timer for %v %v", .Addr, .allocation.fiveTuple)
	}
}