Skip to content

Commit

Permalink
Parse ipv6 info from procfs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxp1998 committed Jan 13, 2020
1 parent 88b40d1 commit 8768bad
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
}
}

if let Ok(tcp) = ::procfs::net::tcp() {
if let Ok(mut tcp) = ::procfs::net::tcp() {
if let Ok(mut tcp6) = ::procfs::net::tcp6() {
tcp.append(tcp6);
}
for entry in tcp.into_iter() {
let local_port = entry.local_address.port();
let local_ip = entry.local_address.ip();
if let (Some(connection), Some(procname)) = (
if let (connection, Some(procname)) = (
Connection::new(entry.remote_address, local_ip, local_port, Protocol::Tcp),
inode_to_procname.get(&entry.inode),
) {
Expand All @@ -37,11 +40,14 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
}
}

if let Ok(udp) = ::procfs::net::udp() {
if let Ok(mut udp) = ::procfs::net::udp() {
if let Ok(mut udp6) = ::procfs::net::udp6() {
udp.append(udp6);
}
for entry in udp.into_iter() {
let local_port = entry.local_address.port();
let local_ip = entry.local_address.ip();
if let (Some(connection), Some(procname)) = (
if let (connection, Some(procname)) = (
Connection::new(entry.remote_address, local_ip, local_port, Protocol::Udp),
inode_to_procname.get(&entry.inode),
) {
Expand Down

0 comments on commit 8768bad

Please sign in to comment.