Compare commits

..

No commits in common. "73fd3134a56a1038ebe71e038f388e77a83ce10e" and "5be254db4ab06efa170ab6f43bbfa9795f41629e" have entirely different histories.

9 changed files with 7 additions and 141 deletions

1
.gitignore vendored
View File

@ -6,4 +6,3 @@ deb/vpncloud/vpncloud
deb/vpncloud/vpncloud.1*
Stats.ods
dist
builder/cache

View File

@ -1,2 +0,0 @@
cache
build.sh

View File

@ -1,27 +0,0 @@
FROM debian:stable
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl ruby-ronn build-essential gcc-arm-linux-gnueabihf libc6-dev-armhf-cross \
&& rm -rf /var/cache/dpkg
RUN useradd -ms /bin/bash user
USER user
WORKDIR /home/user
ENV RUST=1.32.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
ENV PATH=/home/user/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN rustup target add i686-unknown-linux-gnu \
&& rustup target add armv7-unknown-linux-gnueabihf
RUN cargo install cargo-deb \
&& rm -rf /home/user/.cargo/{git,tmp,registry}
VOLUME /home/user/.cargo/tmp
VOLUME /home/user/.cargo/git
VOLUME /home/user/.cargo/registry

View File

@ -1,32 +0,0 @@
#!/bin/bash
function docker_cmd() {
DIST=$1
CMD=$2
docker run -it --rm -v $(pwd)/..:/home/user/code \
-v $CACHE/registry:/home/user/.cargo/registry \
-v $CACHE/git:/home/user/.cargo/git \
-v $CACHE/tmp:/home/user/.cargo/tmp \
vpncloud-builder-$DIST bash -c "$CMD"
}
set -e
cd $(dirname $0)
VERSION=$(grep -e '^version =' ../Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
mkdir -p cache/{git,tmp,registry}
CACHE=$(pwd)/cache
mkdir -p ../dist
docker build --rm -f=Dockerfile-deb -t vpncloud-builder-deb .
# x86_64 deb
docker_cmd deb 'cd code && cargo deb'
cp ../target/debian/vpncloud_${VERSION}_amd64.deb ../dist/vpncloud_${VERSION}_amd64.deb
# arm7hf deb
docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf'
cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb

View File

@ -12,7 +12,7 @@ use std::marker::PhantomData;
use fnv::FnvHasher;
use super::types::{Error, Table, Protocol, Address};
use super::util::{TimeSource, Time, Duration};
use super::util::{TimeSource, Time, Duration, MockTimeSource};
/// An ethernet frame dissector
///
@ -165,7 +165,6 @@ impl<TS: TimeSource> Table for SwitchTable<TS> {
#[cfg(test)] use std::str::FromStr;
#[cfg(test)] use std::net::ToSocketAddrs;
#[cfg(test)] use super::util::MockTimeSource;
#[test]
fn decode_frame_without_vlan() {

View File

@ -90,46 +90,5 @@ fn cross_connect() {
assert_connected!(node3, node2);
// transient connections 2nd degree
assert_connected!(node2, node4);
assert_connected!(node1, node4);
}
#[test]
fn connect_via_beacons() {
//TODO
}
#[test]
fn reconnect_after_timeout() {
//TODO
}
#[test]
fn lost_init1() {
//TODO
}
#[test]
fn wrong_magic() {
//TODO
}
#[test]
fn peer_exchange() {
//TODO
}
#[test]
fn lost_peer_exchange() {
//TODO
}
#[test]
fn remove_dead_peers() {
//TODO
}
#[test]
fn update_primary_address() {
//TODO
}

View File

@ -3,11 +3,10 @@
// This software is licensed under GPL-3 or newer (see LICENSE.md)
#[macro_use] mod helper;
mod peers;
mod connect;
mod payload;
pub use std::net::SocketAddr;
use std::sync::atomic::{Ordering, AtomicUsize};
pub use super::ethernet::{self, SwitchTable};
pub use super::util::MockTimeSource;
@ -27,13 +26,9 @@ type TapTestNode = TestNode<ethernet::Frame, SwitchTable<MockTimeSource>>;
type TunTestNode = TestNode<ip::Packet, RoutingTable>;
thread_local! {
static NEXT_PORT: AtomicUsize = AtomicUsize::new(1);
}
fn create_tap_node() -> TapTestNode {
TestNode::new(
&Config { port: NEXT_PORT.with(|p| p.fetch_add(1, Ordering::Relaxed)) as u16, ..Config::default() },
&Config::default(),
MockDevice::new(),
SwitchTable::new(1800, 10),
true, true, vec![], Crypto::None, None
@ -42,7 +37,7 @@ fn create_tap_node() -> TapTestNode {
fn create_tun_node(addresses: Vec<Range>) -> TunTestNode {
TestNode::new(
&Config { port: NEXT_PORT.with(|p| p.fetch_add(1, Ordering::Relaxed)) as u16, ..Config::default() },
&Config::default(),
MockDevice::new(),
RoutingTable::new(),
false, false, addresses, Crypto::None, None

View File

@ -5,7 +5,7 @@
use super::*;
#[test]
fn ethernet_delivers() {
fn ethernet_send() {
let mut node1 = create_tap_node();
let node1_addr = addr!("1.2.3.4:5678");
let mut node2 = create_tap_node();
@ -27,7 +27,7 @@ fn ethernet_delivers() {
}
#[test]
fn switch_learns() {
fn learning_switch() {
let mut node1 = create_tap_node();
let node1_addr = addr!("1.2.3.4:5678");
let mut node2 = create_tap_node();
@ -42,8 +42,6 @@ fn switch_learns() {
let payload = vec![2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5];
// Nothing learnt so far, node1 broadcasts
node1.device().put_inbound(payload.clone());
simulate!(node1 => node1_addr, node2 => node2_addr, node3 => node3_addr);
@ -53,8 +51,6 @@ fn switch_learns() {
let payload = vec![1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 5, 4, 3, 2, 1];
// Node 2 learned the address by receiving it, does not broadcast
node2.device().put_inbound(payload.clone());
simulate!(node1 => node1_addr, node2 => node2_addr, node3 => node3_addr);
@ -63,24 +59,4 @@ fn switch_learns() {
assert_clean!(node3);
assert_clean!(node1, node2, node3);
}
#[test]
fn switch_honours_vlans() {
//TODO
}
#[test]
fn switch_forgets() {
//TODO
}
#[test]
fn router_delivers() {
//TODO
}
#[test]
fn router_drops_unknown_dest() {
//TODO
}

View File

@ -129,7 +129,6 @@ pub fn resolve<Addr: ToSocketAddrs+fmt::Debug>(addr: Addr) -> Result<Vec<SocketA
Ok(addrs)
}
#[allow(unused_macros)]
macro_rules! addr {
($addr: expr) => {
{