mirror of https://github.com/dswd/vpncloud.git
Compare commits
No commits in common. "73fd3134a56a1038ebe71e038f388e77a83ce10e" and "5be254db4ab06efa170ab6f43bbfa9795f41629e" have entirely different histories.
73fd3134a5
...
5be254db4a
|
@ -6,4 +6,3 @@ deb/vpncloud/vpncloud
|
||||||
deb/vpncloud/vpncloud.1*
|
deb/vpncloud/vpncloud.1*
|
||||||
Stats.ods
|
Stats.ods
|
||||||
dist
|
dist
|
||||||
builder/cache
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
cache
|
|
||||||
build.sh
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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
|
|
|
@ -12,7 +12,7 @@ use std::marker::PhantomData;
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
|
|
||||||
use super::types::{Error, Table, Protocol, Address};
|
use super::types::{Error, Table, Protocol, Address};
|
||||||
use super::util::{TimeSource, Time, Duration};
|
use super::util::{TimeSource, Time, Duration, MockTimeSource};
|
||||||
|
|
||||||
/// An ethernet frame dissector
|
/// 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::str::FromStr;
|
||||||
#[cfg(test)] use std::net::ToSocketAddrs;
|
#[cfg(test)] use std::net::ToSocketAddrs;
|
||||||
#[cfg(test)] use super::util::MockTimeSource;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn decode_frame_without_vlan() {
|
fn decode_frame_without_vlan() {
|
||||||
|
|
|
@ -90,46 +90,5 @@ fn cross_connect() {
|
||||||
assert_connected!(node3, node2);
|
assert_connected!(node3, node2);
|
||||||
|
|
||||||
// transient connections 2nd degree
|
// 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
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
// This software is licensed under GPL-3 or newer (see LICENSE.md)
|
// This software is licensed under GPL-3 or newer (see LICENSE.md)
|
||||||
|
|
||||||
#[macro_use] mod helper;
|
#[macro_use] mod helper;
|
||||||
mod peers;
|
mod connect;
|
||||||
mod payload;
|
mod payload;
|
||||||
|
|
||||||
pub use std::net::SocketAddr;
|
pub use std::net::SocketAddr;
|
||||||
use std::sync::atomic::{Ordering, AtomicUsize};
|
|
||||||
|
|
||||||
pub use super::ethernet::{self, SwitchTable};
|
pub use super::ethernet::{self, SwitchTable};
|
||||||
pub use super::util::MockTimeSource;
|
pub use super::util::MockTimeSource;
|
||||||
|
@ -27,13 +26,9 @@ type TapTestNode = TestNode<ethernet::Frame, SwitchTable<MockTimeSource>>;
|
||||||
type TunTestNode = TestNode<ip::Packet, RoutingTable>;
|
type TunTestNode = TestNode<ip::Packet, RoutingTable>;
|
||||||
|
|
||||||
|
|
||||||
thread_local! {
|
|
||||||
static NEXT_PORT: AtomicUsize = AtomicUsize::new(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_tap_node() -> TapTestNode {
|
fn create_tap_node() -> TapTestNode {
|
||||||
TestNode::new(
|
TestNode::new(
|
||||||
&Config { port: NEXT_PORT.with(|p| p.fetch_add(1, Ordering::Relaxed)) as u16, ..Config::default() },
|
&Config::default(),
|
||||||
MockDevice::new(),
|
MockDevice::new(),
|
||||||
SwitchTable::new(1800, 10),
|
SwitchTable::new(1800, 10),
|
||||||
true, true, vec![], Crypto::None, None
|
true, true, vec![], Crypto::None, None
|
||||||
|
@ -42,7 +37,7 @@ fn create_tap_node() -> TapTestNode {
|
||||||
|
|
||||||
fn create_tun_node(addresses: Vec<Range>) -> TunTestNode {
|
fn create_tun_node(addresses: Vec<Range>) -> TunTestNode {
|
||||||
TestNode::new(
|
TestNode::new(
|
||||||
&Config { port: NEXT_PORT.with(|p| p.fetch_add(1, Ordering::Relaxed)) as u16, ..Config::default() },
|
&Config::default(),
|
||||||
MockDevice::new(),
|
MockDevice::new(),
|
||||||
RoutingTable::new(),
|
RoutingTable::new(),
|
||||||
false, false, addresses, Crypto::None, None
|
false, false, addresses, Crypto::None, None
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ethernet_delivers() {
|
fn ethernet_send() {
|
||||||
let mut node1 = create_tap_node();
|
let mut node1 = create_tap_node();
|
||||||
let node1_addr = addr!("1.2.3.4:5678");
|
let node1_addr = addr!("1.2.3.4:5678");
|
||||||
let mut node2 = create_tap_node();
|
let mut node2 = create_tap_node();
|
||||||
|
@ -27,7 +27,7 @@ fn ethernet_delivers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn switch_learns() {
|
fn learning_switch() {
|
||||||
let mut node1 = create_tap_node();
|
let mut node1 = create_tap_node();
|
||||||
let node1_addr = addr!("1.2.3.4:5678");
|
let node1_addr = addr!("1.2.3.4:5678");
|
||||||
let mut node2 = create_tap_node();
|
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];
|
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());
|
node1.device().put_inbound(payload.clone());
|
||||||
|
|
||||||
simulate!(node1 => node1_addr, node2 => node2_addr, node3 => node3_addr);
|
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];
|
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());
|
node2.device().put_inbound(payload.clone());
|
||||||
|
|
||||||
simulate!(node1 => node1_addr, node2 => node2_addr, node3 => node3_addr);
|
simulate!(node1 => node1_addr, node2 => node2_addr, node3 => node3_addr);
|
||||||
|
@ -64,23 +60,3 @@ fn switch_learns() {
|
||||||
|
|
||||||
assert_clean!(node1, node2, 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
|
|
||||||
}
|
|
|
@ -129,7 +129,6 @@ pub fn resolve<Addr: ToSocketAddrs+fmt::Debug>(addr: Addr) -> Result<Vec<SocketA
|
||||||
Ok(addrs)
|
Ok(addrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_macros)]
|
|
||||||
macro_rules! addr {
|
macro_rules! addr {
|
||||||
($addr: expr) => {
|
($addr: expr) => {
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue