Skip to content

Commit 9d03aad

Browse files
committed
Add iterate_sockets_info_without_pids to linux
1 parent aa2ca45 commit 9d03aad

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/integrations/linux/api.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ use libc::*;
88
pub fn iterate_sockets_info(
99
af_flags: AddressFamilyFlags,
1010
proto_flags: ProtocolFlags,
11+
) -> Result<impl Iterator<Item = Result<SocketInfo, Error>>, Error> {
12+
Ok(attach_pids(iterate_sockets_info_without_pids(
13+
af_flags,
14+
proto_flags,
15+
)?))
16+
}
17+
18+
/// Iterate through sockets information without attaching PID.
19+
pub fn iterate_sockets_info_without_pids(
20+
af_flags: AddressFamilyFlags,
21+
proto_flags: ProtocolFlags,
1122
) -> Result<impl Iterator<Item = Result<SocketInfo, Error>>, Error> {
1223
let ipv4 = af_flags.contains(AddressFamilyFlags::IPV4);
1324
let ipv6 = af_flags.contains(AddressFamilyFlags::IPV6);
@@ -32,7 +43,7 @@ pub fn iterate_sockets_info(
3243
}
3344
}
3445
}
35-
Ok(attach_pids(iterators.into_iter().flatten()))
46+
Ok(iterators.into_iter().flatten())
3647
}
3748

3849
fn attach_pids(

0 commit comments

Comments
 (0)