refactoring, more config, packaging

This commit is contained in:
John Smith
2022-05-16 11:52:48 -04:00
parent 444f65d76d
commit ef1f5d7b52
42 changed files with 1329 additions and 368 deletions

View File

@@ -214,7 +214,14 @@ impl Network {
.interfaces
.best_addresses()
.iter()
.map(|a| SocketAddr::new(*a, from.port()))
.filter_map(|a| {
// We create sockets that are only ipv6 or ipv6 (not dual, so only translate matching unspecified address)
if (a.is_ipv4() && from.is_ipv4()) || (a.is_ipv6() && from.is_ipv6()) {
Some(SocketAddr::new(*a, from.port()))
} else {
None
}
})
.collect()
}
}

View File

@@ -445,6 +445,7 @@ impl Network {
log_net!("updating network class");
let protocol_config = self.inner.lock().protocol_config.unwrap_or_default();
let old_network_class = self.inner.lock().network_class;
let context = DiscoveryContext::new(self.routing_table(), self.clone());
@@ -470,9 +471,10 @@ impl Network {
}
let network_class = context.inner.lock().network_class;
self.inner.lock().network_class = network_class;
log_net!(debug "network class set to {:?}", network_class);
if network_class != old_network_class {
self.inner.lock().network_class = network_class;
log_net!(debug "network class changed to {:?}", network_class);
}
// send updates to everyone
self.routing_table().send_node_info_updates();

View File

@@ -291,6 +291,8 @@ impl Network {
let local_dial_info_list = self.create_udp_inbound_sockets(ip_addrs, udp_port).await?;
let mut static_public = false;
trace!("UDP: listener started on {:#?}", local_dial_info_list);
// Register local dial info
for di in &local_dial_info_list {
// If the local interface address is global, or we are enabling local peer scope
@@ -397,7 +399,7 @@ impl Network {
Box::new(|c, t, a| Box::new(WebsocketProtocolHandler::new(c, t, a))),
)
.await?;
trace!("WS: listener started");
trace!("WS: listener started on {:#?}", socket_addresses);
let mut static_public = false;
let mut registered_addresses: HashSet<IpAddr> = HashSet::new();
@@ -515,7 +517,7 @@ impl Network {
wss_port,
ip_addrs
);
let _socket_addresses = self
let socket_addresses = self
.start_tcp_listener(
ip_addrs,
wss_port,
@@ -523,7 +525,7 @@ impl Network {
Box::new(|c, t, a| Box::new(WebsocketProtocolHandler::new(c, t, a))),
)
.await?;
trace!("WSS: listener started");
trace!("WSS: listener started on {:#?}", socket_addresses);
// NOTE: No interface dial info for WSS, as there is no way to connect to a local dialinfo via TLS
// If the hostname is specified, it is the public dialinfo via the URL. If no hostname
@@ -629,7 +631,7 @@ impl Network {
Box::new(|_, _, a| Box::new(RawTcpProtocolHandler::new(a))),
)
.await?;
trace!("TCP: listener started");
trace!("TCP: listener started on {:#?}", socket_addresses);
let mut static_public = false;
let mut registered_addresses: HashSet<IpAddr> = HashSet::new();