|
@@ -8,6 +8,7 @@ use crate::server::client::client_worker::{ClientEvent, ServerEvent};
|
|
|
use crate::storage::{Guest, SessionData, Storage};
|
|
|
use log::error;
|
|
|
use ring::pbkdf2;
|
|
|
+use std::fmt;
|
|
|
use std::num::NonZeroU32;
|
|
|
use std::sync::Arc;
|
|
|
use tokio::sync::mpsc::error::SendError;
|
|
@@ -61,6 +62,25 @@ pub enum ConnectionSetupError {
|
|
|
WrongPacket,
|
|
|
}
|
|
|
|
|
|
+impl fmt::Display for ConnectionSetupError {
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
+ match &self {
|
|
|
+ ConnectionSetupError::IO(e) => {
|
|
|
+ write!(f, "{}", e)
|
|
|
+ }
|
|
|
+ ConnectionSetupError::PacketParsing(e) => {
|
|
|
+ write!(f, "{:?}", e)
|
|
|
+ }
|
|
|
+ ConnectionSetupError::Reject(r) => {
|
|
|
+ write!(f, "Reject: {}", r)
|
|
|
+ }
|
|
|
+ ConnectionSetupError::WrongPacket => {
|
|
|
+ write!(f, "Wrong packet")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
pub enum Reject {
|
|
|
InvalidUsername,
|
|
|
UsernameInUse,
|
|
@@ -70,6 +90,19 @@ pub enum Reject {
|
|
|
_NoCertificate,
|
|
|
}
|
|
|
|
|
|
+impl fmt::Display for Reject {
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
+ match self {
|
|
|
+ Reject::InvalidUsername => write!(f, "Invalid username"),
|
|
|
+ Reject::UsernameInUse => write!(f, "Username already in use"),
|
|
|
+ Reject::_WrongVersion => write!(f, "Wrong version"),
|
|
|
+ Reject::WrongUserPassword => write!(f, "Wrong user password"),
|
|
|
+ Reject::_WrongServerPassword => write!(f, "Wrong server password"),
|
|
|
+ Reject::_NoCertificate => write!(f, "No TLS certificate"),
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
impl<C: ControlChannel, A: AudioChannel> Handler<C, A> {
|
|
|
pub fn new(
|
|
|
storage: Arc<Storage>,
|