// VpnCloud - Peer-to-Peer VPN // Copyright (C) 2015-2019 Dennis Schwerdel // This software is licensed under GPL-3 or newer (see LICENSE.md) #[macro_use] mod helper; mod payload; mod peers; pub use std::net::SocketAddr; use std::sync::atomic::{AtomicUsize, Ordering}; pub use super::{ cloud::GenericCloud, config::Config, crypto::Crypto, device::MockDevice, ethernet::{self, SwitchTable}, ip::{self, RoutingTable}, net::MockSocket, types::{Protocol, Range, Table}, udpmessage::Message, util::MockTimeSource }; type TestNode
= GenericCloud ) -> (SocketAddr, Vec ) -> (SocketAddr, Vec , from: SocketAddr, msg: Vec , from: SocketAddr, msg: Vec , SocketAddr)]) {
for (ref mut node, ref _from_addr) in nodes.iter_mut() {
while node.device().has_inbound() {
node.trigger_device_event();
}
}
let mut clean = false;
while !clean {
clean = true;
let mut msgs = Vec::new();
for (ref mut node, ref from_addr) in nodes.iter_mut() {
while let Some((to_addr, msg)) = node.socket4().pop_outbound() {
msgs.push((msg, *from_addr, to_addr));
}
}
clean &= msgs.is_empty();
for (msg, from_addr, to_addr) in msgs {
for (ref mut node, ref addr) in nodes.iter_mut() {
if *addr == to_addr {
msg4_put(node, from_addr, msg);
break
}
}
}
let mut msgs = Vec::new();
for (ref mut node, ref from_addr) in nodes.iter_mut() {
while let Some((to_addr, msg)) = node.socket6().pop_outbound() {
msgs.push((msg, *from_addr, to_addr));
}
}
clean &= msgs.is_empty();
for (msg, from_addr, to_addr) in msgs {
for (ref mut node, ref addr) in nodes.iter_mut() {
if *addr == to_addr {
msg6_put(node, from_addr, msg);
break
}
}
}
}
}