This commit is contained in:
Dennis Schwerdel 2022-09-25 15:03:19 +02:00
parent 89d058134e
commit a9b960b04e
7 changed files with 27 additions and 4 deletions

View File

@ -24,9 +24,9 @@
"serayuzgur.crates", "serayuzgur.crates",
"editorconfig.editorconfig", "editorconfig.editorconfig",
"swellaby.vscode-rust-test-adapter", "swellaby.vscode-rust-test-adapter",
"matklad.rust-analyzer",
"asciidoctor.asciidoctor-vscode", "asciidoctor.asciidoctor-vscode",
"ms-vscode.test-adapter-converter" "ms-vscode.test-adapter-converter",
"rust-lang.rust-analyzer"
], ],
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [], // "forwardPorts": [],

2
Cargo.lock generated
View File

@ -1213,7 +1213,7 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]] [[package]]
name = "vpncloud" name = "vpncloud"
version = "2.3.0" version = "2.4.0"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"chrono", "chrono",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "vpncloud" name = "vpncloud"
version = "2.3.0" version = "2.4.0"
authors = ["Dennis Schwerdel <schwerdel@googlemail.com>"] authors = ["Dennis Schwerdel <schwerdel@googlemail.com>"]
build = "build.rs" build = "build.rs"
license = "GPL-3.0" license = "GPL-3.0"

View File

@ -11,4 +11,21 @@
- [x] Fix Ctrl-C - [x] Fix Ctrl-C
- [x] Fix auto-claim IP - [x] Fix auto-claim IP
## More threads
- [ ] abstract socket + peers + traffic + table into one class + shared part
- [ ] management thread
- [ ] Send peer list
- [ ] Statsd
- [ ] Write out stats
- [ ] Port forwarding
## VIA Feature
- [ ] Implement message type VIA for relaying messages
- [ ] Advertize VIA addresses (optional) as claims from own peers
- [ ] Use VIA if no peer found
- [ ] Make sure VIA does not recurse
- [ ] Allow enabling VIA in config
## REST API ## REST API

View File

@ -109,6 +109,7 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> DeviceThread<S, D, P, TS
debug!("Found destination for {} => {}", dst, addr); debug!("Found destination for {} => {}", dst, addr);
self.send_msg(addr, MESSAGE_TYPE_DATA)?; self.send_msg(addr, MESSAGE_TYPE_DATA)?;
} }
//TODO: VIA: find relay peer and relay message
None => { None => {
if self.broadcast { if self.broadcast {
debug!("No destination for {} found, broadcasting", dst); debug!("No destination for {} found, broadcasting", dst);

View File

@ -349,6 +349,7 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> SocketThread<S, D, P, TS
match msg_result { match msg_result {
MessageResult::Message(type_) => match type_ { MessageResult::Message(type_) => match type_ {
MESSAGE_TYPE_DATA => self.handle_payload_from(src)?, MESSAGE_TYPE_DATA => self.handle_payload_from(src)?,
//TODO: VIA: relay message
MESSAGE_TYPE_NODE_INFO => { MESSAGE_TYPE_NODE_INFO => {
let info = match NodeInfo::decode(Cursor::new(self.buffer.message())) { let info = match NodeInfo::decode(Cursor::new(self.buffer.message())) {
Ok(val) => val, Ok(val) => val,
@ -445,6 +446,7 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> SocketThread<S, D, P, TS
self.table.housekeep(); self.table.housekeep();
self.crypto_housekeep()?; self.crypto_housekeep()?;
// Periodically extend the port-forwarding // Periodically extend the port-forwarding
//TODO: extra thread
if let Some(ref mut pfw) = self.port_forwarding { if let Some(ref mut pfw) = self.port_forwarding {
pfw.check_extend(); pfw.check_extend();
} }
@ -463,7 +465,9 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> SocketThread<S, D, P, TS
self.reconnect_to_peers()?; self.reconnect_to_peers()?;
if self.next_stats_out < now { if self.next_stats_out < now {
// Write out the statistics // Write out the statistics
//TODO: extra thread
self.write_out_stats().map_err(|err| Error::FileIo("Failed to write stats file", err))?; self.write_out_stats().map_err(|err| Error::FileIo("Failed to write stats file", err))?;
//TODO: extra thread
self.send_stats_to_statsd()?; self.send_stats_to_statsd()?;
self.next_stats_out = now + STATS_INTERVAL; self.next_stats_out = now + STATS_INTERVAL;
self.traffic.period(Some(5)); self.traffic.period(Some(5));

View File

@ -36,6 +36,7 @@ pub struct NodeInfo {
pub claims: RangeList, pub claims: RangeList,
pub peer_timeout: Option<u16>, pub peer_timeout: Option<u16>,
pub addrs: AddrList, pub addrs: AddrList,
//TODO: VIA: Add via ranges
} }
impl NodeInfo { impl NodeInfo {