Reorganized files
This commit is contained in:
@@ -8,19 +8,19 @@ use tracing::trace;
|
||||
use russh::server::Handle;
|
||||
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||
|
||||
use crate::{stats::Stats, wrapper::Wrapper};
|
||||
|
||||
pub use registry::Registry;
|
||||
|
||||
use crate::io::{Stats, TrackStats};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TunnelAccess {
|
||||
pub(crate) enum TunnelAccess {
|
||||
Private(String),
|
||||
Protected,
|
||||
Public,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TunnelInner {
|
||||
pub(crate) struct TunnelInner {
|
||||
handle: Handle,
|
||||
internal_address: String,
|
||||
port: u32,
|
||||
@@ -29,7 +29,7 @@ pub struct TunnelInner {
|
||||
}
|
||||
|
||||
impl TunnelInner {
|
||||
pub async fn open(&self) -> Result<Wrapper, russh::Error> {
|
||||
pub(crate) async fn open(&self) -> Result<TrackStats, russh::Error> {
|
||||
trace!("Opening tunnel");
|
||||
self.stats.add_connection();
|
||||
let channel = self
|
||||
@@ -42,20 +42,20 @@ impl TunnelInner {
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Wrapper::new(channel.into_stream(), self.stats.clone()))
|
||||
Ok(TrackStats::new(channel.into_stream(), self.stats.clone()))
|
||||
}
|
||||
|
||||
pub async fn is_public(&self) -> bool {
|
||||
pub(crate) async fn is_public(&self) -> bool {
|
||||
matches!(*self.access.read().await, TunnelAccess::Public)
|
||||
}
|
||||
|
||||
pub async fn get_access(&self) -> RwLockReadGuard<'_, TunnelAccess> {
|
||||
pub(crate) async fn get_access(&self) -> RwLockReadGuard<'_, TunnelAccess> {
|
||||
self.access.read().await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Tunnel {
|
||||
pub(crate) struct Tunnel {
|
||||
inner: TunnelInner,
|
||||
|
||||
registry: Registry,
|
||||
|
||||
@@ -6,19 +6,19 @@ use std::{
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{Tunnel, animals::get_animal_name};
|
||||
use crate::{helper::get_animal_name, tunnel::Tunnel};
|
||||
|
||||
use super::TunnelInner;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RegistryEntry {
|
||||
pub(crate) struct RegistryEntry {
|
||||
registry: Registry,
|
||||
name: String,
|
||||
address: Option<String>,
|
||||
}
|
||||
|
||||
impl RegistryEntry {
|
||||
pub fn new(registry: Registry) -> Self {
|
||||
pub(crate) fn new(registry: Registry) -> Self {
|
||||
Self {
|
||||
registry,
|
||||
name: Default::default(),
|
||||
@@ -26,11 +26,11 @@ impl RegistryEntry {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_address(&self) -> Option<&String> {
|
||||
pub(crate) fn get_address(&self) -> Option<&String> {
|
||||
self.address.as_ref()
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> &str {
|
||||
pub(crate) fn get_name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ impl Registry {
|
||||
self.register(tunnel).await;
|
||||
}
|
||||
|
||||
pub async fn get(&self, address: &str) -> Option<TunnelInner> {
|
||||
pub(crate) async fn get(&self, address: &str) -> Option<TunnelInner> {
|
||||
self.tunnels.read().await.get(address).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user