use rand::{
distributions::{Alphanumeric, DistString},
thread_rng,
};
use std::fmt;
pub(crate) const SAMV3_UDP_PORT: u16 = 7655;
pub(crate) const SAMV3_TCP_PORT: u16 = 7656;
#[derive(Clone, PartialEq, Eq)]
pub enum DestinationKind {
Transient,
Persistent {
private_key: String,
},
}
impl fmt::Debug for DestinationKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Transient => f.debug_struct("DestinationKind::Transient").finish(),
Self::Persistent { .. } =>
f.debug_struct("DestinationKind::Persistent").finish_non_exhaustive(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SessionOptions {
pub datagram_port: u16,
pub destination: DestinationKind,
pub inbound_len: usize,
pub nickname: String,
pub num_inbound: usize,
pub num_outbound: usize,
pub outbound_len: usize,
pub publish: bool,
pub samv3_tcp_port: u16,
pub samv3_udp_port: u16,
pub silent_forward: bool,
}
impl Default for SessionOptions {
fn default() -> Self {
Self {
datagram_port: 0u16,
destination: DestinationKind::Transient,
nickname: Alphanumeric.sample_string(&mut thread_rng(), 16),
publish: true,
samv3_tcp_port: SAMV3_TCP_PORT,
samv3_udp_port: SAMV3_UDP_PORT,
silent_forward: false,
num_inbound: 2usize,
inbound_len: 3usize,
num_outbound: 2usize,
outbound_len: 3usize,
}
}
}
#[derive(Debug, Default, Clone, Copy)]
pub struct StreamOptions {
pub dst_port: u16,
pub src_port: u16,
}