Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Dec 18, 2024
1 parent 5fef320 commit 6ab4ffa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/http_clients_cache/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl HttpClientResolver<TcpStream, HttpConnector> for HttpClientCreator {
_client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<TcpStream, HttpConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT.into());
let http_connector = crate::http_connectors::HttpConnector::new(remote_endpoint.to_owned());

Arc::new(MyHttpClient::new(http_connector))
Expand All @@ -46,7 +46,7 @@ impl HttpClientResolver<TcpStream, HttpConnector> for HttpClientsCache {
client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<TcpStream, HttpConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT.into());

let hash_map_key = get_http_key(remote_endpoint);

Expand Down Expand Up @@ -78,7 +78,7 @@ impl HttpClientResolver<TcpStream, HttpConnector> for HttpClientsCache {
url_builder: &UrlBuilder,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) {
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTP_DEFAULT_PORT.into());
let hash_map_key = get_http_key(remote_endpoint);
let mut write_access = self.inner.write().await;
write_access.http.remove(hash_map_key.as_str());
Expand Down
6 changes: 3 additions & 3 deletions src/http_clients_cache/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl HttpClientResolver<TlsStream<TcpStream>, HttpsConnector> for HttpsClientCre
client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<TlsStream<TcpStream>, HttpsConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT.into());

let connector = HttpsConnector::new(
remote_endpoint.to_owned(),
Expand Down Expand Up @@ -52,7 +52,7 @@ impl HttpClientResolver<TlsStream<TcpStream>, HttpsConnector> for HttpClientsCac
client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<TlsStream<TcpStream>, HttpsConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT.into());
let hash_map_key = get_https_key(remote_endpoint);
let mut write_access = self.inner.write().await;

Expand Down Expand Up @@ -82,7 +82,7 @@ impl HttpClientResolver<TlsStream<TcpStream>, HttpsConnector> for HttpClientsCac
url_builder: &UrlBuilder,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) {
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT);
let remote_endpoint = url_builder.get_remote_endpoint(HTTPS_DEFAULT_PORT.into());
let hash_map_key = get_https_key(remote_endpoint);
let mut write_access = self.inner.write().await;
write_access.https.remove(hash_map_key.as_str());
Expand Down
8 changes: 4 additions & 4 deletions src/http_clients_cache/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl HttpClientResolver<my_ssh::SshAsyncChannel, SshHttpConnector> for SshHttpCl
.get_or_create(ssh_credentials)
.await;

let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(80); //todo!("Detect 80 or 443 according to schemes")

let connector = SshHttpConnector {
ssh_session,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl HttpClientResolver<my_ssh::SshAsyncChannel, SshHttpConnector> for HttpClien
client_certificate: Option<&ClientCertificate>,
ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<my_ssh::SshAsyncChannel, SshHttpConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(80); //todo!("Detect 80 or 443 according to schemes")
let hash_map_key = get_ssh_key(ssh_credentials.unwrap(), remote_endpoint);
let mut write_access = self.inner.write().await;

Expand Down Expand Up @@ -82,7 +82,7 @@ impl HttpClientResolver<my_ssh::SshAsyncChannel, SshHttpConnector> for HttpClien
url_builder: &UrlBuilder,
ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) {
let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(80); //todo!("Detect 80 or 443 according to schemes")
let ssh_credentials = ssh_credentials.unwrap();
let hash_map_key = get_ssh_key(ssh_credentials, remote_endpoint);
let mut write_access = self.inner.write().await;
Expand All @@ -107,7 +107,7 @@ fn get_ssh_key(
result.push_str(port.to_string().as_str());

result.push_str("->");
result.push_str(remote_endpoint.get_host_port(None).as_str());
result.push_str(remote_endpoint.get_host_port().as_str());

result
}
6 changes: 3 additions & 3 deletions src/http_clients_cache/unix_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl HttpClientResolver<UnixSocketStream, UnixSocketConnector> for UnixSocketHtt
_client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<UnixSocketStream, UnixSocketConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(None);
let connector = UnixSocketConnector::new(remote_endpoint.to_owned());
let new_one = MyHttpClient::new(connector);

Expand All @@ -46,7 +46,7 @@ impl HttpClientResolver<UnixSocketStream, UnixSocketConnector> for HttpClientsCa
client_certificate: Option<&ClientCertificate>,
#[cfg(feature = "with-ssh")] ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) -> Arc<MyHttpClient<UnixSocketStream, UnixSocketConnector>> {
let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(None);

let mut write_access = self.inner.write().await;

Expand Down Expand Up @@ -78,7 +78,7 @@ impl HttpClientResolver<UnixSocketStream, UnixSocketConnector> for HttpClientsCa
url_builder: &UrlBuilder,
#[cfg(feature = "with-ssh")] _ssh_credentials: Option<&Arc<my_ssh::SshCredentials>>,
) {
let remote_endpoint = url_builder.get_remote_endpoint();
let remote_endpoint = url_builder.get_remote_endpoint(None);
let hash_map_key = get_unix_socket_key(remote_endpoint);
let mut write_access = self.inner.write().await;
write_access.unix_socket.remove(hash_map_key.as_str());
Expand Down
10 changes: 5 additions & 5 deletions src/http_connectors/ssh_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{sync::Arc, time::Duration};

use my_http_client::{MyHttpClientConnector, MyHttpClientError};
use my_ssh::{SshAsyncChannel, SshSession};
use rust_extensions::{remote_endpoint::RemoteEndpointOwned, StrOrString};
use rust_extensions::remote_endpoint::*;

pub struct SshHttpConnector {
pub ssh_session: Arc<SshSession>,
Expand All @@ -16,7 +16,7 @@ impl MyHttpClientConnector<SshAsyncChannel> for SshHttpConnector {
if port.is_none() {
panic!(
"Port is not defined in the remote endpoint {}",
self.remote_host.get_host_port(None)
self.remote_host.get_host_port()
);
}

Expand All @@ -41,15 +41,15 @@ impl MyHttpClientConnector<SshAsyncChannel> for SshHttpConnector {
ssh_credentials.get_user_name(),
ssh_host,
ssh_port,
self.remote_host.get_host_port(None).as_str(),
self.remote_host.get_host_port().as_str(),
err
)),
)
}
}
}
fn get_remote_host(&self) -> StrOrString {
self.remote_host.as_str().into()
fn get_remote_endpoint(&self) -> RemoteEndpoint {
self.remote_host.to_ref()
}
fn is_debug(&self) -> bool {
false
Expand Down
6 changes: 3 additions & 3 deletions src/http_connectors/unix_socket_connector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use my_http_client::{MyHttpClientConnector, MyHttpClientError};
use rust_extensions::{remote_endpoint::RemoteEndpointOwned, StrOrString};
use rust_extensions::remote_endpoint::*;
use tokio::net::{UnixSocket, UnixStream};

pub type UnixSocketStream = tokio::net::UnixStream;
Expand Down Expand Up @@ -40,8 +40,8 @@ impl MyHttpClientConnector<UnixStream> for UnixSocketConnector {
),
}
}
fn get_remote_host(&self) -> StrOrString {
self.remote_host.as_str().into()
fn get_remote_endpoint(&self) -> RemoteEndpoint {
self.remote_host.to_ref()
}
fn is_debug(&self) -> bool {
false
Expand Down

0 comments on commit 6ab4ffa

Please sign in to comment.