fix: Always send messages to a peer using the socket they contacted us with

To implement this it was necessary to introduce an `Endpoint` abstraction
over SocketAddr's that includes the information which socket was used.
This commit is contained in:
Karolin Varner
2023-05-22 11:42:51 +02:00
committed by Karolin Varner
parent f3c343c472
commit f8bea94330
2 changed files with 132 additions and 51 deletions
+1 -9
View File
@@ -1,6 +1,5 @@
use anyhow::{bail, ensure};
use clap::Parser;
use std::net::ToSocketAddrs;
use std::path::{Path, PathBuf};
use crate::app_server::AppServer;
@@ -229,20 +228,13 @@ impl Cli {
)?);
for cfg_peer in config.peers {
let endpoint = cfg_peer
.endpoint
.as_ref()
.map(ToSocketAddrs::to_socket_addrs)
.transpose()?
.and_then(|mut i| i.next());
srv.add_peer(
// psk, pk, outfile, outwg, tx_addr
cfg_peer.pre_shared_key.map(SymKey::load_b64).transpose()?,
SPk::load(&cfg_peer.public_key)?,
cfg_peer.key_out,
None, // TODO remove this argument
endpoint,
cfg_peer.endpoint.clone(),
)?;
}