refactor to_socket_addr and dns_check

This commit is contained in:
open-trade
2022-01-04 19:49:44 +08:00
parent 533efd04d7
commit 3e590b8212
7 changed files with 57 additions and 50 deletions

View File

@@ -9,15 +9,15 @@ pub use protobuf;
use std::{
fs::File,
io::{self, BufRead},
net::{Ipv4Addr, SocketAddr, SocketAddrV4, ToSocketAddrs},
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
path::Path,
time::{self, SystemTime, UNIX_EPOCH},
};
pub use tokio;
pub use tokio_util;
pub mod socket_client;
pub mod tcp;
pub mod udp;
pub mod socket_client;
pub use env_logger;
pub use log;
pub mod bytes_codec;
@@ -27,6 +27,7 @@ pub use anyhow::{self, bail};
pub use futures_util;
pub mod config;
pub mod fs;
pub use socket_client::to_socket_addr;
pub use sodiumoxide;
pub use tokio_socks;
@@ -149,14 +150,6 @@ pub fn get_version_from_url(url: &str) -> String {
"".to_owned()
}
pub fn to_socket_addr(host: &str) -> ResultType<SocketAddr> {
let addrs: Vec<SocketAddr> = host.to_socket_addrs()?.collect();
if addrs.is_empty() {
bail!("Failed to solve {}", host);
}
Ok(addrs[0])
}
pub fn gen_version() {
let mut file = File::create("./src/version.rs").unwrap();
for line in read_lines("Cargo.toml").unwrap() {