MagicStack/asyncpg

connect through socks5 proxy

nagylzs opened this issue · 2 comments

I would like to use asyncpg through a socks 5 proxy. I need this because the postgresql instances are running inside a docker overlay network (swarm). The IP addresses of the servers are not fixed, and it is not possible to access them directly.

If I had a single postgres server, then it would not be a problem to manually create a tunnel. But I need to connect to several different servers, and their ip addresses are changing. Manually creating a bunch of host aliases and creating multiple tunnels is just not practical.

Would it be possible to add a layer that would allow me to add my own callback for creating the TCP socket for a given host name + port pair?

If you only want a callback functionality and going to implement the proxy handling code yourself, as opposed to having asyngpg natively support socks5, this is similar to #1054

I think that would be wonderful, and the cleanest solution. I think we can close this ticket in favour of #1054.