mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 21:42:37 +08:00
Secure socks proxy: use Grafana Plugin SDK (#71616)
This commit is contained in:

committed by
GitHub

parent
600f623610
commit
4ece133fce
@ -16,6 +16,7 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||
sdkproxy "github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
|
||||
|
||||
@ -23,6 +24,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/sqleng"
|
||||
"github.com/grafana/grafana/pkg/tsdb/sqleng/proxyutil"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -85,10 +87,11 @@ func newInstanceSettings(cfg *setting.Cfg, httpClientProvider httpclient.Provide
|
||||
}
|
||||
|
||||
// register the secure socks proxy dialer context, if enabled
|
||||
if cfg.SecureSocksDSProxy.Enabled && jsonData.SecureDSProxy {
|
||||
proxyOpts := proxyutil.GetSQLProxyOptions(dsInfo)
|
||||
if sdkproxy.Cli.SecureSocksProxyEnabled(proxyOpts) {
|
||||
// UID is only unique per org, the only way to ensure uniqueness is to do it by connection information
|
||||
uniqueIdentifier := dsInfo.User + dsInfo.DecryptedSecureJSONData["password"] + dsInfo.URL + dsInfo.Database
|
||||
protocol, err = registerProxyDialerContext(&cfg.SecureSocksDSProxy, protocol, uniqueIdentifier)
|
||||
protocol, err = registerProxyDialerContext(protocol, uniqueIdentifier, proxyOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user