server

package
v1.4.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package server implements the HTTP and gRPC server used throughout Grafana Agent Static.

It is a grafana/alloy-specific fork of github.com/weaveworks/common/server.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFlags = Flags{
		RegisterInstrumentation: true,
		GracefulShutdownTimeout: 30 * time.Second,

		HTTP: DefaultHTTPFlags,
		GRPC: DefaultGRPCFlags,
	}

	DefaultHTTPFlags = HTTPFlags{
		InMemoryAddr:  "agent.internal:12345",
		ListenNetwork: "tcp",
		ListenAddress: "127.0.0.1:12345",
		ReadTimeout:   30 * time.Second,
		WriteTimeout:  30 * time.Second,
		IdleTimeout:   120 * time.Second,
	}

	DefaultGRPCFlags = GRPCFlags{
		InMemoryAddr:          "agent.internal:12346",
		ListenNetwork:         "tcp",
		ListenAddress:         "127.0.0.1:12346",
		MaxRecvMsgSize:        4 * 1024 * 1024,
		MaxSendMsgSize:        4 * 1024 * 1024,
		MaxConcurrentStreams:  100,
		MaxConnectionIdle:     infinity,
		MaxConnectionAge:      infinity,
		MaxConnectionAgeGrace: infinity,
		KeepaliveTime:         2 * time.Hour,
		KeepaliveTimeout:      20 * time.Second,
		MinTimeBetweenPings:   5 * time.Minute,
	}
)

Default options structs.

View Source
var (
	DefaultLogLevel = func() LogLevel {
		var lvl LogLevel
		lvl.RegisterFlags(emptyFlagSet)
		return lvl
	}()
)

Default configuration structs.

Functions

func GetClientAuthFromString

func GetClientAuthFromString(clientAuth string) (tls.ClientAuthType, error)

Types

type Config

type Config struct {
	LogLevel  LogLevel `yaml:"log_level,omitempty"`
	LogFormat string   `yaml:"log_format,omitempty"`

	GRPC GRPCConfig `yaml:",inline"`
	HTTP HTTPConfig `yaml:",inline"`
}

Config holds dynamic configuration options for a Server.

func DefaultConfig

func DefaultConfig() Config

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the server config with defaults applied.

type DialContextFunc

type DialContextFunc func(ctx context.Context, network string, addr string) (net.Conn, error)

DialContextFunc is a function matching the signature of net.Dialer.DialContext.

type Flags

type Flags struct {
	RegisterInstrumentation bool
	GracefulShutdownTimeout time.Duration

	LogSourceIPs       bool
	LogSourceIPsHeader string
	LogSourceIPsRegex  string

	GRPC GRPCFlags
	HTTP HTTPFlags
}

Flags hold static configuration options for a Server.

func (*Flags) RegisterFlags

func (f *Flags) RegisterFlags(fs *flag.FlagSet)

RegisterFlags registers flags for c to the given FlagSet.

type GRPCConfig

type GRPCConfig struct {
	TLSConfig TLSConfig `yaml:"grpc_tls_config,omitempty"`
}

GRPCConfig holds dynamic configuration options for the gRPC server.

type GRPCFlags

type GRPCFlags struct {
	UseTLS bool

	InMemoryAddr string

	ListenNetwork string
	ListenAddress string // host:port
	ConnLimit     int

	MaxRecvMsgSize           int
	MaxSendMsgSize           int
	MaxConcurrentStreams     uint
	MaxConnectionIdle        time.Duration
	MaxConnectionAge         time.Duration
	MaxConnectionAgeGrace    time.Duration
	KeepaliveTime            time.Duration
	KeepaliveTimeout         time.Duration
	MinTimeBetweenPings      time.Duration
	PingWithoutStreamAllowed bool
}

GRPCFlags hold static configuration options for the gRPC server.

func (GRPCFlags) ListenHostPort

func (f GRPCFlags) ListenHostPort() (host string, port int, err error)

ListenHostPort splits the ListenAddress into a listen host and listen port. Returns an error if the ListenAddress isn't valid.

func (*GRPCFlags) RegisterFlags

func (f *GRPCFlags) RegisterFlags(fs *flag.FlagSet)

RegisterFlags registers flags for c to the given FlagSet.

type HTTPConfig

type HTTPConfig struct {
	TLSConfig TLSConfig `yaml:"http_tls_config,omitempty"`
}

HTTPConfig holds dynamic configuration options for the HTTP server.

type HTTPFlags

type HTTPFlags struct {
	UseTLS bool

	InMemoryAddr string

	ListenNetwork string
	ListenAddress string // host:port
	ConnLimit     int

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
}

HTTPFlags hold static configuration options for the HTTP server.

func (HTTPFlags) ListenHostPort

func (f HTTPFlags) ListenHostPort() (host string, port int, err error)

ListenHostPort splits the ListenAddress into a listen host and listen port. Returns an error if the ListenAddress isn't valid.

func (*HTTPFlags) RegisterFlags

func (f *HTTPFlags) RegisterFlags(fs *flag.FlagSet)

RegisterFlags registers flags for c to the given FlagSet.

type LogLevel

type LogLevel struct {
	log.Level `yaml:",inline"`
}

LogLevel wraps the logging.Level type to allow defining IsZero, which is required to make omitempty work when marshalling YAML.

func (LogLevel) IsZero

func (l LogLevel) IsZero() bool

type TLSCipher

type TLSCipher uint16

TLSCipher holds the ID of a tls.CipherSuite.

func (TLSCipher) MarshalYAML

func (c TLSCipher) MarshalYAML() (interface{}, error)

MarshalYAML marshals the name of the cipher suite.

func (*TLSCipher) UnmarshalYAML

func (c *TLSCipher) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the name of a cipher suite to its ID.

type TLSConfig

type TLSConfig struct {
	TLSCertPath              string                    `yaml:"cert_file,omitempty"`
	TLSKeyPath               string                    `yaml:"key_file,omitempty"`
	ClientAuth               string                    `yaml:"client_auth_type,omitempty"`
	ClientCAs                string                    `yaml:"client_ca_file,omitempty"`
	CipherSuites             []TLSCipher               `yaml:"cipher_suites,omitempty"`
	CurvePreferences         []TLSCurve                `yaml:"curve_preferences,omitempty"`
	MinVersion               TLSVersion                `yaml:"min_version,omitempty"`
	MaxVersion               TLSVersion                `yaml:"max_version,omitempty"`
	PreferServerCipherSuites bool                      `yaml:"prefer_server_cipher_suites,omitempty"`
	WindowsCertificateFilter *WindowsCertificateFilter `yaml:"windows_certificate_filter,omitempty"`
}

TLSConfig holds dynamic configuration options for TLS.

type TLSCurve

type TLSCurve tls.CurveID

TLSCurve holds the ID of a TLS elliptic curve.

func (*TLSCurve) MarshalYAML

func (c *TLSCurve) MarshalYAML() (interface{}, error)

MarshalYAML marshals the ID of a TLS elliptic curve into its name.

func (*TLSCurve) UnmarshalYAML

func (c *TLSCurve) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the name of a TLS elliptic curve into its ID.

type TLSVersion

type TLSVersion uint16

TLSVersion holds a TLS version ID.

func (*TLSVersion) MarshalYAML

func (tv *TLSVersion) MarshalYAML() (interface{}, error)

MarshalYAML marshals the ID of a TLS version into its name.

func (*TLSVersion) UnmarshalYAML

func (tv *TLSVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the name of a TLS version into its ID.

type WinCertStoreHandler

type WinCertStoreHandler struct {
}

func (WinCertStoreHandler) Run

func (w WinCertStoreHandler) Run()

func (WinCertStoreHandler) Stop

func (w WinCertStoreHandler) Stop()

type WindowsCertificateFilter

type WindowsCertificateFilter struct {
	Server *WindowsServerFilter `yaml:"server,omitempty"`
	Client *WindowsClientFilter `yaml:"client,omitempty"`
}

WindowsCertificateFilter represents the configuration for accessing the Windows store

type WindowsClientFilter

type WindowsClientFilter struct {
	IssuerCommonNames []string `yaml:"issuer_common_names,omitempty"`
	SubjectRegEx      string   `yaml:"subject_regex,omitempty"`
	TemplateID        string   `yaml:"template_id,omitempty"`
}

WindowsClientFilter is used to select a client root CA certificate

type WindowsServerFilter

type WindowsServerFilter struct {
	Store             string   `yaml:"store,omitempty"`
	SystemStore       string   `yaml:"system_store,omitempty"`
	IssuerCommonNames []string `yaml:"issuer_common_names,omitempty"`
	TemplateID        string   `yaml:"template_id,omitempty"`

	RefreshInterval time.Duration `yaml:"refresh_interval,omitempty"`
}

WindowsServerFilter is used to select a server certificate

Jump to

Keyboard shortcuts

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