1 pub mod relay_none; 2 pub mod relay_range; 3 pub mod relay_static; 4 5 use crate::error::Result; 6 7 use util::Conn; 8 9 use async_trait::async_trait; 10 use std::net::SocketAddr; 11 use std::sync::Arc; 12 13 // RelayAddressGenerator is used to generate a RelayAddress when creating an allocation. 14 // You can use one of the provided ones or provide your own. 15 #[async_trait] 16 pub trait RelayAddressGenerator { 17 // validate confirms that the RelayAddressGenerator is properly initialized validate(&self) -> Result<()>18 fn validate(&self) -> Result<()>; 19 20 // Allocate a RelayAddress allocate_conn( &self, use_ipv4: bool, requested_port: u16, ) -> Result<(Arc<dyn Conn + Send + Sync>, SocketAddr)>21 async fn allocate_conn( 22 &self, 23 use_ipv4: bool, 24 requested_port: u16, 25 ) -> Result<(Arc<dyn Conn + Send + Sync>, SocketAddr)>; 26 } 27