Point db to local tunnel if ssh is enabled
This commit is contained in:
parent
f0f447857f
commit
983f285373
@ -2,6 +2,7 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
neturl "net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -86,8 +87,14 @@ func NewFromUrl(url string, sshInfo *shared.SSHInfo) (*Client, error) {
|
|||||||
|
|
||||||
go tunnel.Start()
|
go tunnel.Start()
|
||||||
|
|
||||||
|
uri, err := neturl.Parse(url)
|
||||||
|
if err != nil {
|
||||||
|
tunnel.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Override remote postgres port with local proxy port
|
// Override remote postgres port with local proxy port
|
||||||
url = strings.Replace(url, ":5432", fmt.Sprintf(":%v", tunnel.Port), 1)
|
url = strings.Replace(url, uri.Host, fmt.Sprintf("127.0.0.1:%v", tunnel.Port), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if command.Opts.Debug {
|
if command.Opts.Debug {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user