forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
excludes private ip addresses (solana-labs#18740)
(cherry picked from commit e316586) # Conflicts: # core/src/broadcast_stage.rs # gossip/src/cluster_info.rs Co-authored-by: behzad nouri <behzadnouri@gmail.com>
- Loading branch information
1 parent
98658eb
commit df9061b
Showing
6 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
pub mod packet; | ||
pub mod recvmmsg; | ||
pub mod sendmmsg; | ||
pub mod socket; | ||
pub mod streamer; | ||
|
||
#[macro_use] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::net::SocketAddr; | ||
|
||
// TODO: remove these once IpAddr::is_global is stable. | ||
|
||
#[cfg(test)] | ||
pub fn is_global(_: &SocketAddr) -> bool { | ||
true | ||
} | ||
|
||
#[cfg(not(test))] | ||
pub fn is_global(addr: &SocketAddr) -> bool { | ||
use std::net::IpAddr; | ||
|
||
match addr.ip() { | ||
IpAddr::V4(addr) => { | ||
// TODO: Consider excluding: | ||
// addr.is_loopback() || addr.is_link_local() | ||
// || addr.is_broadcast() || addr.is_documentation() | ||
// || addr.is_unspecified() | ||
!addr.is_private() | ||
} | ||
IpAddr::V6(_) => { | ||
// TODO: Consider excluding: | ||
// addr.is_loopback() || addr.is_unspecified(), | ||
true | ||
} | ||
} | ||
} |