mirror of https://github.com/dswd/vpncloud.git
Fix warings
This commit is contained in:
parent
39ea4dad9e
commit
d8d18a2aae
|
@ -206,12 +206,12 @@ fn switch() {
|
||||||
let peer2 = "1.2.3.5:7890".to_socket_addrs().unwrap().next().unwrap();
|
let peer2 = "1.2.3.5:7890".to_socket_addrs().unwrap().next().unwrap();
|
||||||
assert!(table.lookup(&addr).is_none());
|
assert!(table.lookup(&addr).is_none());
|
||||||
MockTimeSource::set_time(1000);
|
MockTimeSource::set_time(1000);
|
||||||
table.learn(addr.clone(), None, peer.clone());
|
table.learn(addr, None, peer);
|
||||||
assert_eq!(table.lookup(&addr), Some(peer));
|
assert_eq!(table.lookup(&addr), Some(peer));
|
||||||
MockTimeSource::set_time(1000);
|
MockTimeSource::set_time(1000);
|
||||||
table.learn(addr.clone(), None, peer2.clone());
|
table.learn(addr, None, peer2);
|
||||||
assert_eq!(table.lookup(&addr), Some(peer));
|
assert_eq!(table.lookup(&addr), Some(peer));
|
||||||
MockTimeSource::set_time(1010);
|
MockTimeSource::set_time(1010);
|
||||||
table.learn(addr.clone(), None, peer2.clone());
|
table.learn(addr, None, peer2);
|
||||||
assert_eq!(table.lookup(&addr), Some(peer2));
|
assert_eq!(table.lookup(&addr), Some(peer2));
|
||||||
}
|
}
|
||||||
|
|
28
src/ip.rs
28
src/ip.rs
|
@ -231,30 +231,30 @@ fn routing_table_ipv4() {
|
||||||
let peer2 = "1.2.3.4:2".to_socket_addrs().unwrap().next().unwrap();
|
let peer2 = "1.2.3.4:2".to_socket_addrs().unwrap().next().unwrap();
|
||||||
let peer3 = "1.2.3.4:3".to_socket_addrs().unwrap().next().unwrap();
|
let peer3 = "1.2.3.4:3".to_socket_addrs().unwrap().next().unwrap();
|
||||||
assert!(table.lookup(&Address::from_str("192.168.1.1").unwrap()).is_none());
|
assert!(table.lookup(&Address::from_str("192.168.1.1").unwrap()).is_none());
|
||||||
table.learn(Address::from_str("192.168.1.1").unwrap(), Some(32), peer1.clone());
|
table.learn(Address::from_str("192.168.1.1").unwrap(), Some(32), peer1);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
||||||
table.learn(Address::from_str("192.168.1.2").unwrap(), None, peer2.clone());
|
table.learn(Address::from_str("192.168.1.2").unwrap(), None, peer2);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
||||||
table.learn(Address::from_str("192.168.1.0").unwrap(), Some(24), peer3.clone());
|
table.learn(Address::from_str("192.168.1.0").unwrap(), Some(24), peer3);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
||||||
table.learn(Address::from_str("192.168.0.0").unwrap(), Some(16), peer1.clone());
|
table.learn(Address::from_str("192.168.0.0").unwrap(), Some(16), peer1);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
||||||
table.learn(Address::from_str("0.0.0.0").unwrap(), Some(0), peer2.clone());
|
table.learn(Address::from_str("0.0.0.0").unwrap(), Some(0), peer2);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("192.168.1.3").unwrap()), Some(peer3));
|
||||||
assert_eq!(table.lookup(&Address::from_str("1.2.3.4").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("1.2.3.4").unwrap()), Some(peer2));
|
||||||
table.learn(Address::from_str("192.168.2.0").unwrap(), Some(27), peer3.clone());
|
table.learn(Address::from_str("192.168.2.0").unwrap(), Some(27), peer3);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.2.31").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("192.168.2.31").unwrap()), Some(peer3));
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.2.32").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("192.168.2.32").unwrap()), Some(peer1));
|
||||||
table.learn(Address::from_str("192.168.2.0").unwrap(), Some(28), peer3.clone());
|
table.learn(Address::from_str("192.168.2.0").unwrap(), Some(28), peer3);
|
||||||
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("192.168.2.1").unwrap()), Some(peer3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,31 +265,31 @@ fn routing_table_ipv6() {
|
||||||
let peer2 = "::1:2".to_socket_addrs().unwrap().next().unwrap();
|
let peer2 = "::1:2".to_socket_addrs().unwrap().next().unwrap();
|
||||||
let peer3 = "::1:3".to_socket_addrs().unwrap().next().unwrap();
|
let peer3 = "::1:3".to_socket_addrs().unwrap().next().unwrap();
|
||||||
assert!(table.lookup(&Address::from_str("::1").unwrap()).is_none());
|
assert!(table.lookup(&Address::from_str("::1").unwrap()).is_none());
|
||||||
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap(), Some(128), peer1.clone());
|
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap(), Some(128), peer1);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
||||||
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap(), None, peer2.clone());
|
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap(), None, peer2);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
||||||
table.learn(Address::from_str("dead:beef:dead:beef::").unwrap(), Some(64), peer3.clone());
|
table.learn(Address::from_str("dead:beef:dead:beef::").unwrap(), Some(64), peer3);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
||||||
table.learn(Address::from_str("dead:beef:dead:be00::").unwrap(), Some(56), peer1.clone());
|
table.learn(Address::from_str("dead:beef:dead:be00::").unwrap(), Some(56), peer1);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:1::").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:1::").unwrap()), Some(peer3));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:be01::").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:be01::").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
||||||
table.learn(Address::from_str("::").unwrap(), Some(0), peer2.clone());
|
table.learn(Address::from_str("::").unwrap(), Some(0), peer2);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:1::").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:1::").unwrap()), Some(peer3));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:be01::").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:be01::").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:1").unwrap()), Some(peer1));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:2").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:3").unwrap()), Some(peer3));
|
||||||
assert_eq!(table.lookup(&Address::from_str("::1").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("::1").unwrap()), Some(peer2));
|
||||||
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:be00").unwrap(), Some(123), peer2.clone());
|
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:be00").unwrap(), Some(123), peer2);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be1f").unwrap()), Some(peer2));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be1f").unwrap()), Some(peer2));
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be20").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be20").unwrap()), Some(peer3));
|
||||||
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:be00").unwrap(), Some(124), peer3.clone());
|
table.learn(Address::from_str("dead:beef:dead:beef:dead:beef:dead:be00").unwrap(), Some(124), peer3);
|
||||||
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be01").unwrap()), Some(peer3));
|
assert_eq!(table.lookup(&Address::from_str("dead:beef:dead:beef:dead:beef:dead:be01").unwrap()), Some(peer3));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue