add filter_force_ipv6 option that (only when being set) filters gossip endpoints by their version (false -> V4, true -> V6). this avoids mixups in setups where interfaces are separated by IP version.
This commit is contained in:
parent
7d02510878
commit
66ee10619b
1 changed files with 10 additions and 2 deletions
12
src/main.rs
12
src/main.rs
|
@ -85,6 +85,7 @@ struct InterfaceSetting {
|
|||
name: String,
|
||||
/// Specify the external port that should be IGD forwarded to this Wireguard interface. Only used for IPv4.
|
||||
upnp_ext_port_v4: Option<u16>,
|
||||
filter_force_ipv6: Option<bool>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
@ -657,7 +658,6 @@ impl State {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn setup_wg_peers(&mut self, daemon: &Daemon, i: usize) -> Result<()> {
|
||||
let now = time();
|
||||
for peer_cfg in daemon.config.peers.iter() {
|
||||
|
@ -737,6 +737,15 @@ impl State {
|
|||
}
|
||||
}
|
||||
endpoints.sort();
|
||||
// if prefer_ipv6 option is set, strongly prefer addresses of chosen version
|
||||
if let Some(interface) = daemon.config.interfaces.iter().find(|ifsetting| ifsetting.name == peer_cfg.interface) {
|
||||
if let Some(filter_ipv6_only) = interface.filter_force_ipv6 {
|
||||
endpoints = endpoints.into_iter().filter(|(ep, _)| {
|
||||
ep.ip().is_ipv6() == filter_ipv6_only
|
||||
}).collect();
|
||||
}
|
||||
}
|
||||
|
||||
endpoints = endpoints
|
||||
.into_iter()
|
||||
.filter(|(ep, _)| {
|
||||
|
@ -750,7 +759,6 @@ impl State {
|
|||
endpoints
|
||||
}
|
||||
};
|
||||
|
||||
if !endpoints.is_empty() {
|
||||
let endpoint = endpoints[i % endpoints.len()].0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue