Browse Source

Prefer IPV4

.to_socket_addrs() returns IPV6 first and some servers seem to have
issues
tags/0.8.6^0
Julien Blanchard 1 year ago
parent
commit
bb7926a5fb
3 changed files with 4 additions and 3 deletions
  1. 1
    1
      src/finger/client.rs
  2. 1
    1
      src/gemini/client.rs
  3. 2
    1
      src/gopher/client.rs

+ 1
- 1
src/finger/client.rs View File

@@ -11,7 +11,7 @@ pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), Strin
11 11
     let host = url.host_str().unwrap().to_string();
12 12
     let urlf = format!("{}:79", host);
13 13
     let socket = match urlf.to_socket_addrs() {
14
-        Ok(mut iter) => iter.next(),
14
+        Ok(iter) => iter.rev().next(),
15 15
         Err(_) => None,
16 16
     };
17 17
 

+ 1
- 1
src/gemini/client.rs View File

@@ -24,7 +24,7 @@ pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), Strin
24 24
     let connector = builder.build().unwrap();
25 25
 
26 26
     match urlf.to_socket_addrs() {
27
-        Ok(mut addrs_iter) => match addrs_iter.next() {
27
+        Ok(addrs_iter) => match addrs_iter.rev().next() {
28 28
             Some(socket_addr) => {
29 29
                 let stream = TcpStream::connect_timeout(&socket_addr, Duration::new(5, 0));
30 30
 

+ 2
- 1
src/gopher/client.rs View File

@@ -15,8 +15,9 @@ pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), Strin
15 15
         None => 70,
16 16
     };
17 17
     let urlf = format!("{}:{}", host, port);
18
+
18 19
     let socket = match urlf.to_socket_addrs() {
19
-        Ok(mut iter) => iter.next(),
20
+        Ok(iter) => iter.rev().next(),
20 21
         Err(_) => None,
21 22
     };
22 23
 

Loading…
Cancel
Save