Browse Source

Rework default port

tags/0.8.8^0
Julien Blanchard 1 year ago
parent
commit
19bcd04330
5 changed files with 7 additions and 8 deletions
  1. 1
    1
      Cargo.lock
  2. 1
    1
      Cargo.toml
  3. 2
    1
      src/finger/client.rs
  4. 2
    1
      src/gemini/client.rs
  5. 1
    4
      src/gopher/client.rs

+ 1
- 1
Cargo.lock View File

@@ -112,7 +112,7 @@ dependencies = [
112 112
 
113 113
 [[package]]
114 114
 name = "castor"
115
-version = "0.8.7"
115
+version = "0.8.8"
116 116
 dependencies = [
117 117
  "ansi-parser",
118 118
  "dirs",

+ 1
- 1
Cargo.toml View File

@@ -1,6 +1,6 @@
1 1
 [package]
2 2
 name = "castor"
3
-version = "0.8.7"
3
+version = "0.8.8"
4 4
 authors = ["Julien Blanchard <julien@typed-hole.org>"]
5 5
 edition = "2018"
6 6
 

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

@@ -8,7 +8,8 @@ use crate::Protocol;
8 8
 pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), String> {
9 9
     let url = url.get_source_url();
10 10
     let host = url.host_str().unwrap().to_string();
11
-    let urlf = format!("{}:79", host);
11
+    let port = url.port().unwrap_or(79);
12
+    let urlf = format!("{}:{}", host, port);
12 13
 
13 14
     match urlf.to_socket_addrs() {
14 15
         Ok(mut addrs_iter) => match addrs_iter.next() {

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

@@ -9,7 +9,8 @@ use crate::protocols::*;
9 9
 pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), String> {
10 10
     let url = url.get_source_url();
11 11
     let host = url.host_str().unwrap();
12
-    let urlf = format!("{}:1965", host);
12
+    let port = url.port().unwrap_or(1965);
13
+    let urlf = format!("{}:{}", host, port);
13 14
 
14 15
     let mut builder = TlsConnector::builder();
15 16
     builder.danger_accept_invalid_hostnames(true);

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

@@ -9,10 +9,7 @@ use crate::Protocol;
9 9
 pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), String> {
10 10
     let url = url.get_source_url();
11 11
     let host = url.host_str().unwrap().to_string();
12
-    let port = match url.port() {
13
-        Some(port) => port,
14
-        None => 70,
15
-    };
12
+    let port = url.port().unwrap_or(70);
16 13
     let urlf = format!("{}:{}", host, port);
17 14
 
18 15
     match urlf.to_socket_addrs() {

Loading…
Cancel
Save