Skip to content

Commit

Permalink
Removed unused models
Browse files Browse the repository at this point in the history
  • Loading branch information
ancwrd1 committed Feb 12, 2025
1 parent 7a40cab commit b164d5d
Showing 1 changed file with 1 addition and 83 deletions.
84 changes: 1 addition & 83 deletions snxcore/src/model/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,10 @@ use std::collections::BTreeMap;
use std::net::Ipv4Addr;

use anyhow::anyhow;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Serialize};

use crate::model::wrappers::*;

#[derive(Default, Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub enum EncryptionAlgorithm {
#[default]
Aes256Cbc,
}

impl EncryptionAlgorithm {
pub fn as_xfrm_name(&self) -> &'static str {
match self {
Self::Aes256Cbc => "aes",
}
}
}

impl<'de> Deserialize<'de> for EncryptionAlgorithm {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.to_lowercase().as_str() {
"aes-256" => Ok(Self::Aes256Cbc),
_ => Err(serde::de::Error::custom("Unsupported encryption algorithm!")),
}
}
}

impl Serialize for EncryptionAlgorithm {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::Aes256Cbc => String::from("AES-256").serialize(serializer),
}
}
}

#[derive(Default, Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub enum AuthenticationAlgorithm {
#[default]
HmacSha256,
}

impl AuthenticationAlgorithm {
pub fn as_xfrm_name(&self) -> &'static str {
match self {
Self::HmacSha256 => "sha256",
}
}

pub fn trunc_length(&self) -> u32 {
match self {
Self::HmacSha256 => 128,
}
}
}

impl<'de> Deserialize<'de> for AuthenticationAlgorithm {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.to_lowercase().as_str() {
"sha256" => Ok(Self::HmacSha256),
_ => Err(serde::de::Error::custom("Unsupported authentication algorithm!")),
}
}
}

impl Serialize for AuthenticationAlgorithm {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::HmacSha256 => String::from("SHA256").serialize(serializer),
}
}
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OfficeMode {
pub ipaddr: String,
Expand Down

0 comments on commit b164d5d

Please sign in to comment.