Skip to content

Commit 0010713

Browse files
committed
Made it compilable
1 parent 7644398 commit 0010713

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

my-postgres-core/src/connection/connection_loop.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub async fn start_connection_loop(
3232

3333
#[cfg(feature = "with-ssh")]
3434
let postgres_host = if let Some(ssh_config) = &ssh_config {
35-
let postgres_host = conn_string.get_host_endpoint();
36-
3735
let ssh_cred_type = match ssh_config.credentials.as_ref() {
3836
my_ssh::SshCredentials::SshAgent { .. } => "SshAgent",
3937
my_ssh::SshCredentials::UserNameAndPassword { .. } => "UserNameAndPassword",
@@ -42,14 +40,15 @@ pub async fn start_connection_loop(
4240

4341
let (ssh_host, ssh_port) = ssh_config.credentials.get_host_port();
4442
format!(
45-
"[{}]ssh:{}:{}->{}",
43+
"[{}]ssh:{}:{}->{}:{}",
4644
ssh_cred_type,
4745
ssh_host,
4846
ssh_port,
49-
postgres_host.get_host_port().as_str()
47+
conn_string.get_host(),
48+
conn_string.get_port()
5049
)
5150
} else {
52-
format!("{:?}", conn_string.get_host_endpoint())
51+
format!("{}:{}", conn_string.get_host(), conn_string.get_port())
5352
};
5453

5554
#[cfg(not(feature = "with-ssh"))]

my-postgres-core/src/ssh/port_allocator.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ lazy_static::lazy_static! {
3535
pub static ref PORT_ALLOCATOR: PortAllocator = PortAllocator::new(33000, 34000);
3636
}
3737

38-
pub fn generate_unix_socket_file(
39-
_ssh_credentials: &SshCredentials,
40-
_remote_host: rust_extensions::url_utils::HostEndpoint,
41-
) -> (&'static str, u16) {
38+
pub fn generate_unix_socket_file(_ssh_credentials: &SshCredentials) -> (&'static str, u16) {
4239
let port = PORT_ALLOCATOR.get_next_port();
4340
return ("127.0.0.1", port);
4441
/*

my-postgres-core/src/ssh/start_ssh_tunnel.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{PostgresConnectionString, POSTGRES_DEFAULT_PORT};
1+
use crate::PostgresConnectionString;
22

33
use super::PostgresSshConfig;
44

@@ -8,14 +8,12 @@ pub async fn start_ssh_tunnel_and_get_connection_string(
88
) {
99
let (host, port) = ssh_config.credentials.get_host_port();
1010

11-
let postgres_endpoint = connection_string.get_host_endpoint();
12-
1311
let ssh_tunnel_key = format!(
1412
"{}:{}->{}:{}",
1513
host,
1614
port,
17-
postgres_endpoint.host,
18-
postgres_endpoint.port.unwrap_or(POSTGRES_DEFAULT_PORT)
15+
connection_string.get_host(),
16+
connection_string.get_port()
1917
);
2018

2119
{
@@ -30,18 +28,14 @@ pub async fn start_ssh_tunnel_and_get_connection_string(
3028

3129
let ssh_session = ssh_config.get_ssh_session().await;
3230

33-
let get_host_endpoint = connection_string.get_host_endpoint();
34-
3531
let (listen_host, listen_port) =
36-
crate::ssh::generate_unix_socket_file(ssh_config.credentials.as_ref(), get_host_endpoint);
32+
crate::ssh::generate_unix_socket_file(ssh_config.credentials.as_ref());
3733

3834
let result = ssh_session
3935
.start_port_forward(
4036
format!("{}:{}", listen_host, listen_port),
41-
get_host_endpoint.host.to_string(),
42-
get_host_endpoint
43-
.port
44-
.unwrap_or(crate::POSTGRES_DEFAULT_PORT),
37+
connection_string.get_host().to_string(),
38+
connection_string.get_port(),
4539
)
4640
.await;
4741

0 commit comments

Comments
 (0)