From 00b464105629c4ca7ec3976d09e131e7c84cd4de Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Sat, 22 Jul 2017 16:42:32 +0200 Subject: [PATCH] Fixed tests and serialization constants --- src/crypto.rs | 5 ++++- src/device.rs | 2 ++ src/tests.rs | 5 +++-- src/types.rs | 9 ++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/crypto.rs b/src/crypto.rs index b1ada1d..a64bb5d 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -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 { diff --git a/src/device.rs b/src/device.rs index bd13996..b6ba9de 100644 --- a/src/device.rs +++ b/src/device.rs @@ -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 } diff --git a/src/tests.rs b/src/tests.rs index 4331abe..7f34bb9 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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::(config_file).unwrap(), ConfigFile{ + assert_eq!(serde_yaml::from_str::(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()), diff --git a/src/types.rs b/src/types.rs index 10226dc..dfde678 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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> {