Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add port conn params#127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
demonolock wants to merge11 commits intomaster
base:master
Choose a base branch
Loading
fromadd-port-conn-params
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Update establish_ssh_tunnel
  • Loading branch information
vshepard committedJun 6, 2024
commit1eb9a92fd7fee551fc49939c2048b4a1de571b9f
2 changes: 1 addition & 1 deletionsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@
readme = f.read()

setup(
version='1.10.1',
version='1.10.2',
name='testgres',
packages=['testgres', 'testgres.operations', 'testgres.helpers'],
description='Testing utility for PostgreSQL and its extensions',
Expand Down
11 changes: 7 additions & 4 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,11 +76,14 @@ def is_port_open(host, port):
except socket.error:
return False

def establish_ssh_tunnel(self, local_port, remote_port):
def establish_ssh_tunnel(self, local_port, remote_port, host):
"""
Establish an SSH tunnel from a local port to a remote PostgreSQL port.
"""
ssh_cmd = ['-N', '-L', f"{local_port}:localhost:{remote_port}"]
if host != 'localhost':
ssh_cmd = ['-N', '-L', f"localhost:{local_port}:{host}:{remote_port}"]
else:
ssh_cmd = ['-N', '-L', f"{local_port}:{host}:{remote_port}"]
self.tunnel_process = self.exec_command(ssh_cmd, get_process=True, timeout=300)
timeout = 10
start_time = time.time()
Expand DownExpand Up@@ -412,10 +415,10 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
"""
local_port = reserve_port()
self.tunnel_port = local_port
self.establish_ssh_tunnel(local_port=local_port, remote_port=port)
self.establish_ssh_tunnel(local_port=local_port, remote_port=port, host=host)
try:
conn = pglib.connect(
host=host,
host='localhost',
port=local_port,
database=dbname,
user=user,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp