Some more documentation and fixed tests

pull/16/head
Dennis Schwerdel 2016-11-25 07:15:19 +01:00
parent 88f5272023
commit 6d9fdddb7c
4 changed files with 39 additions and 3 deletions

View File

@ -1 +1,4 @@
# Warning: This file is ignored on systemd systems
# Please use instantiated services (vpncloud@NAME) instead
NETWORKS="default"

View File

@ -1,5 +1,12 @@
# This configuration file uses the YAML format.
# This configuration can be enabled/disabled and controlled by adding the
# network to `/etc/default/vpncloud` and starting/stopping it via
# `/etc/init.d/vpncloud start/stop` on non-systemd systems and via
# `systemctl enable/disable vpncloud@NAME` and
# `service vpncloud@NAME start/stop` on systemd systems.
# The port number on which to listen for data.
# Note: Every VPN needs a different port number.
#port: 3210
@ -68,3 +75,14 @@
# The name of the allocated device will be available via the environment
# variable `IFNAME`.
#ifdown: ""
# Store the process id in this file when running in the background. If set,
# the given file will be created containing the process id of the new
# background process. This option is only used when running in background.
#pid_file: ""
# Change the user and/or group of the process once all the setup has been
# done and before spawning the background process. This option is only used
# when running in background.
#user: ""
#group: ""

View File

@ -116,7 +116,7 @@ impl log::Log for DualLogger {
if self.enabled(record.metadata()) {
println!("{} - {}", record.level(), record.args());
let mut file = self.file.lock().expect("Lock poisoned");
if let &mut Some(ref mut file) = &mut file as &mut Option<File> {
if let Some(ref mut file) = *file {
let time = time::strftime("%F %T", &time::now()).expect("Failed to format timestamp");
writeln!(file, "{} - {} - {}", time, record.level(), record.args()).expect("Failed to write to logfile");
}

View File

@ -412,6 +412,9 @@ mode: normal
subnets:
- 10.0.1.0/24
port_forwarding: true
user: nobody
group: nogroup
pid_file: /run/vpncloud.run
";
assert_eq!(configfile::parse_str::<ConfigFile>(config_file).unwrap(), ConfigFile{
device_type: Some(Type::Tun),
@ -427,7 +430,10 @@ port_forwarding: true
mode: Some(Mode::Normal),
dst_timeout: None,
subnets: Some(vec!["10.0.1.0/24".to_string()]),
port_forwarding: Some(true)
port_forwarding: Some(true),
user: Some("nobody".to_string()),
group: Some("nogroup".to_string()),
pid_file: Some("/run/vpncloud.run".to_string())
})
}
@ -448,7 +454,10 @@ fn config_merge() {
mode: Some(Mode::Normal),
dst_timeout: None,
subnets: Some(vec!["10.0.1.0/24".to_string()]),
port_forwarding: None
port_forwarding: None,
user: Some("nobody".to_string()),
group: Some("nogroup".to_string()),
pid_file: Some("/run/vpncloud.run".to_string())
});
assert_eq!(config, Config{
device_type: Type::Tun,
@ -461,6 +470,9 @@ fn config_merge() {
peer_timeout: 1800,
mode: Mode::Normal,
subnets: vec!["10.0.1.0/24".to_string()],
user: Some("nobody".to_string()),
group: Some("nogroup".to_string()),
pid_file: Some("/run/vpncloud.run".to_string()),
..Default::default()
});
config.merge_args(Args{
@ -482,6 +494,9 @@ fn config_merge() {
peer_timeout: 1800,
mode: Mode::Normal,
subnets: vec!["10.0.1.0/24".to_string()],
user: Some("nobody".to_string()),
group: Some("nogroup".to_string()),
pid_file: Some("/run/vpncloud.run".to_string()),
..Default::default()
});
}