mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 06:58:31 -04:00
Merge pull request #8 from aramperes/7-flexible-addr
This commit is contained in:
commit
cf78172937
1 changed files with 5 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
@ -98,8 +98,10 @@ impl Config {
|
||||||
|
|
||||||
fn parse_addr(s: Option<&str>) -> anyhow::Result<SocketAddr> {
|
fn parse_addr(s: Option<&str>) -> anyhow::Result<SocketAddr> {
|
||||||
s.with_context(|| "Missing address")?
|
s.with_context(|| "Missing address")?
|
||||||
.parse::<SocketAddr>()
|
.to_socket_addrs()
|
||||||
.with_context(|| "Invalid address")
|
.with_context(|| "Invalid address")?
|
||||||
|
.next()
|
||||||
|
.with_context(|| "Could not lookup address")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ip(s: Option<&str>) -> anyhow::Result<IpAddr> {
|
fn parse_ip(s: Option<&str>) -> anyhow::Result<IpAddr> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue