No need to create a new SocketAddr.

This commit is contained in:
Pedro de Oliveira 2023-03-21 21:18:02 +00:00
parent fd7c9198d0
commit 40786f3290
Signed by: falso
GPG Key ID: 1E4F05ACDBB2C85C
1 changed files with 2 additions and 5 deletions

View File

@ -1,7 +1,7 @@
//! Chaturbate Streams Recorder
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
use std::net::{IpAddr, ToSocketAddrs};
use std::thread;
use std::time::{Duration, Instant};
@ -71,10 +71,7 @@ impl Chaturbate {
.timeout_read(Duration::from_secs(5))
.timeout_write(Duration::from_secs(5))
.resolver(|addr: &str| { // force IPv4
addr.to_socket_addrs().map(|iter| iter.filter_map(|sa| match sa.ip() {
IpAddr::V4(ipv4) => Some(SocketAddr::new(IpAddr::V4(ipv4), sa.port())),
_ => None,
}).collect::<Vec<_>>())
addr.to_socket_addrs().map(|iter| iter.filter(|&sa| matches!(sa.ip(), IpAddr::V4(_))).collect::<Vec<_>>())
})
.build();
let config: Settings = read_config();