mirror of https://github.com/dswd/vpncloud.git
Fixed tests and serialization constants
This commit is contained in:
parent
0e13277911
commit
00b4641056
|
@ -121,7 +121,10 @@ extern {
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub enum CryptoMethod {
|
||||
ChaCha20, AES256
|
||||
#[serde(rename = "chacha20")]
|
||||
ChaCha20,
|
||||
#[serde(rename = "aes256")]
|
||||
AES256
|
||||
}
|
||||
|
||||
pub enum Crypto {
|
||||
|
|
|
@ -19,8 +19,10 @@ extern {
|
|||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Type {
|
||||
/// Tun interface: This interface transports IP packets.
|
||||
#[serde(rename = "tun")]
|
||||
Tun,
|
||||
/// Tap interface: This insterface transports Ethernet frames.
|
||||
#[serde(rename = "tap")]
|
||||
Tap
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ use std::str::FromStr;
|
|||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use serde_yaml;
|
||||
|
||||
use super::MAGIC;
|
||||
use super::ethernet::{Frame, SwitchTable};
|
||||
use super::ip::{RoutingTable, Packet};
|
||||
|
@ -15,7 +17,6 @@ use super::types::{Protocol, Address, Range, Table, Mode};
|
|||
use super::udpmessage::{Message, decode, encode};
|
||||
use super::crypto::{Crypto, CryptoMethod};
|
||||
use super::config::{Config, ConfigFile};
|
||||
use super::configfile;
|
||||
use super::Args;
|
||||
|
||||
|
||||
|
@ -464,7 +465,7 @@ user: nobody
|
|||
group: nogroup
|
||||
pid_file: /run/vpncloud.run
|
||||
";
|
||||
assert_eq!(configfile::parse_str::<ConfigFile>(config_file).unwrap(), ConfigFile{
|
||||
assert_eq!(serde_yaml::from_str::<ConfigFile>(config_file).unwrap(), ConfigFile{
|
||||
device_type: Some(Type::Tun),
|
||||
device_name: Some("vpncloud%d".to_string()),
|
||||
ifup: Some("ifconfig $IFNAME 10.0.1.1/16 mtu 1400 up".to_string()),
|
||||
|
|
|
@ -187,7 +187,14 @@ impl fmt::Debug for Range {
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Mode {
|
||||
Normal, Hub, Switch, Router
|
||||
#[serde(rename = "normal")]
|
||||
Normal,
|
||||
#[serde(rename = "hub")]
|
||||
Hub,
|
||||
#[serde(rename = "switch")]
|
||||
Switch,
|
||||
#[serde(rename = "router")]
|
||||
Router
|
||||
}
|
||||
impl fmt::Display for Mode {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
|
|
Loading…
Reference in New Issue