From 19bcd043303258b9f3900d345ab7e4d014cf60f8 Mon Sep 17 00:00:00 2001 From: Julien Blanchard Date: Tue, 19 May 2020 10:03:19 +0200 Subject: [PATCH] Rework default port --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/finger/client.rs | 3 ++- src/gemini/client.rs | 3 ++- src/gopher/client.rs | 5 +---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a2911b..b6c7e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "castor" -version = "0.8.7" +version = "0.8.8" dependencies = [ "ansi-parser", "dirs", diff --git a/Cargo.toml b/Cargo.toml index 71a4628..71ecea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "castor" -version = "0.8.7" +version = "0.8.8" authors = ["Julien Blanchard "] edition = "2018" diff --git a/src/finger/client.rs b/src/finger/client.rs index e94334d..5b1efcb 100644 --- a/src/finger/client.rs +++ b/src/finger/client.rs @@ -8,7 +8,8 @@ use crate::Protocol; pub fn get_data(url: T) -> Result<(Option>, Vec), String> { let url = url.get_source_url(); let host = url.host_str().unwrap().to_string(); - let urlf = format!("{}:79", host); + let port = url.port().unwrap_or(79); + let urlf = format!("{}:{}", host, port); match urlf.to_socket_addrs() { Ok(mut addrs_iter) => match addrs_iter.next() { diff --git a/src/gemini/client.rs b/src/gemini/client.rs index b963089..b096bdb 100644 --- a/src/gemini/client.rs +++ b/src/gemini/client.rs @@ -9,7 +9,8 @@ use crate::protocols::*; pub fn get_data(url: T) -> Result<(Option>, Vec), String> { let url = url.get_source_url(); let host = url.host_str().unwrap(); - let urlf = format!("{}:1965", host); + let port = url.port().unwrap_or(1965); + let urlf = format!("{}:{}", host, port); let mut builder = TlsConnector::builder(); builder.danger_accept_invalid_hostnames(true); diff --git a/src/gopher/client.rs b/src/gopher/client.rs index d9399c7..3b0496b 100644 --- a/src/gopher/client.rs +++ b/src/gopher/client.rs @@ -9,10 +9,7 @@ use crate::Protocol; pub fn get_data(url: T) -> Result<(Option>, Vec), String> { let url = url.get_source_url(); let host = url.host_str().unwrap().to_string(); - let port = match url.port() { - Some(port) => port, - None => 70, - }; + let port = url.port().unwrap_or(70); let urlf = format!("{}:{}", host, port); match urlf.to_socket_addrs() { -- 2.45.2