Sign in to follow this  
psql

[Help]Psql Proxy

Recommended Posts

I want build a psql proxy which could deal with the connection request from localhost to psql server which on other machine by type in psql -h localhost -U bob network. what function should I use to capture these information in my proxy code. I try to print the buf but there is nothing there after the read function. Cheers!

Share this post


Link to post
Share on other sites
Quote:
I want build a psql proxy which could deal with the connection request from localhost to psql server which on other machine by type in psql -h localhost -U bob network.
Why would you do that?

Why not use psql on localhost to deal with the connection request from localhost to the postgresql server on the other machine, like so:



psql -U bob -h remote.mynetwork.com -d mydbname


Share this post


Link to post
Share on other sites
Or you can set up a permanent SSH tunnel between your local host and the remote postgres server. Seems a lot easier than writing a tunneling server yourself.

In general, though, the tunnel is easy: accept a TCP connection on one end; establish the connection to your peer on the other end, and make that connection on the other end. The source/destination IP and port need to already be established; there's no way to connect to an arbitrary remote port/IP using simply tunneling. If that's what you want to do, you want a SOCKS 5 proxy or something similar.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this