projects
/
ldk-sample
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7ea18dc
)
Switch to ToSocketAddrs to support connecting to hostnames not IPs
author
Matt Corallo
<git@bluematt.me>
Tue, 4 May 2021 22:06:13 +0000
(22:06 +0000)
committer
Matt Corallo
<git@bluematt.me>
Tue, 4 May 2021 22:06:13 +0000
(22:06 +0000)
src/cli.rs
patch
|
blob
|
history
diff --git
a/src/cli.rs
b/src/cli.rs
index d7a76bc03c9768c7f076afc1ec777fd8d296dec5..d2d5a218a3e123299aac3fecf33d1ecd17ea39a6 100644
(file)
--- a/
src/cli.rs
+++ b/
src/cli.rs
@@
-18,7
+18,7
@@
use lightning_invoice::{utils, Currency, Invoice};
use std::env;
use std::io;
use std::io::{BufRead, Write};
use std::env;
use std::io;
use std::io::{BufRead, Write};
-use std::net::
SocketAddr
;
+use std::net::
{SocketAddr, ToSocketAddrs}
;
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;
@@
-639,12
+639,12
@@
pub(crate) fn parse_peer_info(
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"ERROR: incorrectly formatted peer
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"ERROR: incorrectly formatted peer
- info. Should be formatted as: `pubkey@host:port`",
+
info. Should be formatted as: `pubkey@host:port`",
));
}
));
}
- let peer_addr
: Result<SocketAddr, _> = peer_addr_str.unwrap().parse(
);
- if peer_addr.is_err() {
+ let peer_addr
= peer_addr_str.unwrap().to_socket_addrs().map(|mut r| r.next()
);
+ if peer_addr.is_err()
|| peer_addr.as_ref().unwrap().is_none()
{
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"ERROR: couldn't parse pubkey@host:port into a socket address",
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"ERROR: couldn't parse pubkey@host:port into a socket address",
@@
-659,5
+659,5
@@
pub(crate) fn parse_peer_info(
));
}
));
}
- Ok((pubkey.unwrap(), peer_addr.unwrap()))
+ Ok((pubkey.unwrap(), peer_addr.unwrap()
.unwrap()
))
}
}