Skip link_local v4 addresses and v6 address when v6 is not enabled
This commit is contained in:
parent
ec713c18c4
commit
8b9713a934
|
@ -8,9 +8,8 @@ extern crate solana;
|
|||
|
||||
use atty::{is, Stream};
|
||||
use getopts::Options;
|
||||
use pnet::datalink;
|
||||
use rayon::prelude::*;
|
||||
use solana::crdt::{Crdt, ReplicatedData};
|
||||
use solana::crdt::{get_ip_addr, Crdt, ReplicatedData};
|
||||
use solana::mint::MintDemo;
|
||||
use solana::ncp::Ncp;
|
||||
use solana::signature::{GenKeys, KeyPair, KeyPairUtil};
|
||||
|
@ -38,17 +37,6 @@ fn print_usage(program: &str, opts: Options) {
|
|||
print!("{}", opts.usage(&brief));
|
||||
}
|
||||
|
||||
fn get_ip_addr() -> Option<IpAddr> {
|
||||
for iface in datalink::interfaces() {
|
||||
for p in iface.ips {
|
||||
if !p.ip().is_loopback() && !p.ip().is_multicast() {
|
||||
return Some(p.ip());
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init().unwrap();
|
||||
let mut threads = 4usize;
|
||||
|
|
13
src/crdt.rs
13
src/crdt.rs
|
@ -54,9 +54,22 @@ pub fn get_ip_addr() -> Option<IpAddr> {
|
|||
for iface in datalink::interfaces() {
|
||||
for p in iface.ips {
|
||||
if !p.ip().is_loopback() && !p.ip().is_multicast() {
|
||||
match p.ip() {
|
||||
IpAddr::V4(addr) => {
|
||||
if !addr.is_link_local() {
|
||||
return Some(p.ip());
|
||||
}
|
||||
}
|
||||
IpAddr::V6(_addr) => {
|
||||
// Select an ipv6 address if the config is selected
|
||||
#[cfg(feature = "ipv6")]
|
||||
{
|
||||
return Some(p.ip());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue