mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 21:32:22 +08:00
postgres: socks proxy: use plugin-sdk (#82376)
This commit is contained in:
@ -5,21 +5,13 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
sdkproxy "github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
"github.com/lib/pq"
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
// newPostgresProxyDriver updates the dialer for a postgres connector with a dialer that proxies connections through the secure socks proxy
|
||||
// and returns a new postgres driver to register
|
||||
func newPostgresProxyDialer(opts *sdkproxy.Options) (pq.Dialer, error) {
|
||||
dialer, err := sdkproxy.New(opts).NewSecureSocksProxyContextDialer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// update the postgres dialer with the proxy dialer
|
||||
return &postgresProxyDialer{d: dialer}, nil
|
||||
// we wrap the proxy.Dialer to become dialer that the postgres module accepts
|
||||
func newPostgresProxyDialer(dialer proxy.Dialer) pq.Dialer {
|
||||
return &postgresProxyDialer{d: dialer}
|
||||
}
|
||||
|
||||
var _ pq.Dialer = (&postgresProxyDialer{})
|
||||
|
Reference in New Issue
Block a user