mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
commit
6baf495ce2
1 changed files with 8 additions and 1 deletions
|
@ -70,6 +70,9 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let hostname = xgethostname();
|
let hostname = xgethostname();
|
||||||
|
|
||||||
if matches.opt_present("i") {
|
if matches.opt_present("i") {
|
||||||
|
// XXX: to_socket_addrs needs hostname:port so append a dummy port and remove it later.
|
||||||
|
// This should use std::net::lookup_host, but that is still marked unstable.
|
||||||
|
let hostname = hostname + ":1";
|
||||||
match hostname.to_socket_addrs() {
|
match hostname.to_socket_addrs() {
|
||||||
Ok(addresses) => {
|
Ok(addresses) => {
|
||||||
let mut hashset = HashSet::new();
|
let mut hashset = HashSet::new();
|
||||||
|
@ -77,7 +80,11 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
for addr in addresses {
|
for addr in addresses {
|
||||||
// XXX: not sure why this is necessary...
|
// XXX: not sure why this is necessary...
|
||||||
if !hashset.contains(&addr) {
|
if !hashset.contains(&addr) {
|
||||||
output.push_str(&format!("{}", addr));
|
let mut ip = format!("{}", addr);
|
||||||
|
if ip.ends_with(":1") {
|
||||||
|
ip = ip[..ip.len()-2].to_string();
|
||||||
|
}
|
||||||
|
output.push_str(&ip);
|
||||||
output.push_str(" ");
|
output.push_str(" ");
|
||||||
hashset.insert(addr.clone());
|
hashset.insert(addr.clone());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue