reresolve address at every reconnect, to avoid problems switching from IPv6 to IPv4-only networks

This commit is contained in:
Florian Stecker 2024-01-02 22:47:52 -05:00
parent 002393b18e
commit caf3912af1

View File

@ -214,13 +214,12 @@ pub fn connect_and_idle<F: Fn(), G: Fn()>(cli: &Cli, connected_callback: F, mail
cli.server.as_str().try_into().unwrap())?;
let mut addrs = cli.addrs.borrow_mut();
if addrs.is_empty() {
addrs.extend(
(cli.server.as_str(), cli.port)
.to_socket_addrs()
.map_err(|e|io::Error::new(ErrorKind::NotConnected, e.to_string()))?
);
}
addrs.clear();
addrs.extend(
(cli.server.as_str(), cli.port)
.to_socket_addrs()
.map_err(|e|io::Error::new(ErrorKind::NotConnected, e.to_string()))?
);
let mut socket = TcpStream::connect(addrs.as_slice())?;
let mut state = ImapState::Unauthenticated;