proxy

package
v0.168.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 11

Documentation

Overview

Package proxy provides utilities for updating a data source plugin connection to go through a proxy.

Index

Constants

This section is empty.

Variables

View Source
var (

	// PluginSecureSocksProxyEnabled is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_ENABLED
	// environment variable used to specify if a secure socks proxy is allowed to be used for datasource connections.
	PluginSecureSocksProxyEnabled = "GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_ENABLED"
	// PluginSecureSocksProxyClientCert is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_CERT
	// environment variable used to specify the file location of the client cert for the secure socks proxy.
	PluginSecureSocksProxyClientCert = "GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_CERT"
	// PluginSecureSocksProxyClientKey is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_KEY
	// environment variable used to specify the file location of the client key for the secure socks proxy.
	PluginSecureSocksProxyClientKey = "GF_SECURE_SOCKS_DATASOURCE_PROXY_CLIENT_KEY"
	// PluginSecureSocksProxyRootCACert is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_ROOT_CA_CERT
	// environment variable used to specify the file location of the root ca for the secure socks proxy.
	PluginSecureSocksProxyRootCACert = "GF_SECURE_SOCKS_DATASOURCE_PROXY_ROOT_CA_CERT"
	// PluginSecureSocksProxyProxyAddress is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_PROXY_ADDRESS
	// environment variable used to specify the secure socks proxy server address to proxy the connections to.
	PluginSecureSocksProxyProxyAddress = "GF_SECURE_SOCKS_DATASOURCE_PROXY_PROXY_ADDRESS"
	// PluginSecureSocksProxyServerName is a constant for the GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_NAME
	// environment variable used to specify the server name of the secure socks proxy.
	PluginSecureSocksProxyServerName = "GF_SECURE_SOCKS_DATASOURCE_PROXY_SERVER_NAME"
)
View Source
var DefaultTimeoutOptions = TimeoutOptions{
	Timeout:   30 * time.Second,
	KeepAlive: 30 * time.Second,
}

DefaultTimeoutOptions default timeout/connection options for the proxy.

Functions

func ConfigureSecureSocksHTTPProxy

func ConfigureSecureSocksHTTPProxy(transport *http.Transport, opts *Options) error

ConfigureSecureSocksHTTPProxy takes a http.DefaultTransport and wraps it in a socks5 proxy with TLS if it is enabled on the datasource and the grafana instance

func NewSecureSocksProxyContextDialer

func NewSecureSocksProxyContextDialer(opts *Options) (proxy.Dialer, error)

NewSecureSocksProxyContextDialer returns a proxy context dialer that can be used to allow datasource connections to go through a secure socks proxy

func SecureSocksProxyEnabled

func SecureSocksProxyEnabled(opts *Options) bool

SecureSocksProxyEnabled checks if the Grafana instance allows the secure socks proxy to be used and the datasource options specify to use the proxy

func SecureSocksProxyEnabledOnDS

func SecureSocksProxyEnabledOnDS(jsonData map[string]interface{}) bool

SecureSocksProxyEnabledOnDS checks the datasource json data for `enableSecureSocksProxy` to determine if the secure socks proxy should be enabled on it

Types

type AuthOptions

type AuthOptions struct {
	Username string
	Password string
}

AuthOptions socks5 username and password options. Every datasource can have separate credentials to the proxy.

type Options

type Options struct {
	Enabled  bool
	Auth     *AuthOptions
	Timeouts *TimeoutOptions
}

Options defines per datasource options for creating the proxy dialer.

type TimeoutOptions

type TimeoutOptions struct {
	Timeout   time.Duration
	KeepAlive time.Duration
}

TimeoutOptions timeout/connection options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL