go-agent: github.com/sqreen/go-agent/agent/internal/config Index | Files

package config

import "github.com/sqreen/go-agent/agent/internal/config"

Index

Package Files

config.go

Constants

const (
    ErrorMessage_UnsupportedCommand = "command is not supported"
)

Error messages.

const ErrorMetricsPeriod = time.Minute

Error metrics store period.

const (
    MaxEventsPerHeatbeat = 1000
)
const PublicKey string = "" /* 269 byte string literal not displayed */

Variables

var (
    // Timeout value of a HTTP request. See http.Client.Timeout.
    BackendHTTPAPIRequestTimeout = 30 * time.Second

    // List of endpoint addresses, relative to the base URL.
    BackendHTTPAPIEndpoint = struct {
        AppLogin, AppLogout, AppBeat, AppException, Batch, ActionsPack, RulesPack HTTPAPIEndpoint
    }{
        AppLogin:     HTTPAPIEndpoint{http.MethodPost, "/sqreen/v1/app-login"},
        AppLogout:    HTTPAPIEndpoint{http.MethodGet, "/sqreen/v0/app-logout"},
        AppBeat:      HTTPAPIEndpoint{http.MethodPost, "/sqreen/v1/app-beat"},
        AppException: HTTPAPIEndpoint{http.MethodPost, "/sqreen/v0/app_sqreen_exception"},
        Batch:        HTTPAPIEndpoint{http.MethodPost, "/sqreen/v0/batch"},
        ActionsPack:  HTTPAPIEndpoint{http.MethodGet, "/sqreen/v0/actionspack"},
        RulesPack:    HTTPAPIEndpoint{http.MethodGet, "/sqreen/v0/rulespack"},
    }

    // Header name of the API token.
    BackendHTTPAPIHeaderToken = "X-Api-Key"

    // Header name of the API session.
    BackendHTTPAPIHeaderSession = "X-Session-Key"

    // Header name of the App name.
    BackendHTTPAPIHeaderAppName = "X-App-Name"

    BackendHTTPAPIOrganizationTokenPrefix = "org_"

    // BackendHTTPAPIRequestRetryPeriod is the time period to retry failed backend
    // HTTP requests.
    BackendHTTPAPIRequestRetryPeriod = time.Minute

    // BackendHTTPAPIBackoffRate is the backoff rate to compute the next sleep
    // duration before retrying the failed request.
    BackendHTTPAPIBackoffRate = 2.0

    // BackendHTTPAPIBackoffMaxDuration is the maximum backoff's sleep duration.
    BackendHTTPAPIBackoffMaxDuration = 30 * time.Minute

    // BackendHTTPAPIBackoffMaxDuration is the minimum backoff's sleep duration.
    BackendHTTPAPIBackoffMinDuration = time.Millisecond

    // BackendHTTPAPIDefaultHeartbeatDelay is the default heartbeat delay when not
    // correctly provided by the backend.
    BackendHTTPAPIDefaultHeartbeatDelay = time.Minute

    // EventBatchMaxStaleness is the time when the data in the event manager's
    // batch is considered too long, and is therefore immediatly sent to the
    // backend, without waiting for the batch to become full.
    EventBatchMaxStaleness = 20 * time.Second
)

Backend client configuration.

var (
    TrackedHTTPHeaders = []string{
        "X-Forwarded-For",
        "X-Forwarded-Host",
        "X-Forwarded-Proto",
        "X-Client-Ip",
        "X-Real-Ip",
        "X-Forwarded",
        "X-Cluster-Client-Ip",
        "Forwarded-For",
        "Forwarded",
        "Via",
        "Content-Type",
        "Content-Length",
        "Host",
        "X-Requested-With",
        "X-Request-Id",
        "HTTP_X_FORWARDED_FOR",
        "HTTP_X_REAL_IP",
        "HTTP_CLIENT_IP",
        "HTTP_X_FORWARDED",
        "HTTP_X_CLUSTER_CLIENT_IP",
        "HTTP_FORWARDED_FOR",
        "HTTP_FORWARDED",
        "HTTP_VIA",
    }

    IPRelatedHTTPHeaders = []string{
        "X-Forwarded-For",
        "X-Client-Ip",
        "X-Real-Ip",
        "X-Forwarded",
        "X-Cluster-Client-Ip",
        "Forwarded-For",
        "Forwarded",
        "Via",
        "HTTP_X_FORWARDED_FOR",
        "HTTP_X_REAL_IP",
        "HTTP_CLIENT_IP",
        "HTTP_X_FORWARDED",
        "HTTP_X_CLUSTER_CLIENT_IP",
        "HTTP_FORWARDED_FOR",
        "HTTP_FORWARDED",
        "HTTP_VIA",
    }
)
var (
    IPv4PrivateNetworks = []*net.IPNet{
        ipnet("0.0.0.0/8"),
        ipnet("10.0.0.0/8"),
        ipnet("127.0.0.0/8"),
        ipnet("169.254.0.0/16"),
        ipnet("172.16.0.0/12"),
        ipnet("192.0.0.0/29"),
        ipnet("192.0.0.170/31"),
        ipnet("192.0.2.0/24"),
        ipnet("192.168.0.0/16"),
        ipnet("198.18.0.0/15"),
        ipnet("198.51.100.0/24"),
        ipnet("203.0.113.0/24"),
        ipnet("240.0.0.0/4"),
        ipnet("255.255.255.255/32"),
    }

    IPv4PublicNetwork = ipnet("100.64.0.0/10")

    IPv6PrivateNetworks = []*net.IPNet{
        ipnet("::1/128"),
        ipnet("::/128"),
        ipnet("::ffff:0:0/96"),
        ipnet("100::/64"),
        ipnet("2001::/23"),
        ipnet("2001:2::/48"),
        ipnet("2001:db8::/32"),
        ipnet("2001:10::/28"),
        ipnet("fc00::/7"),
        ipnet("fe80::/10"),
    }
)

IP networks allowing to compute whether to

type Config Uses

type Config struct {
    *viper.Viper
}

func New Uses

func New(logger *plog.Logger) *Config

func (*Config) AppName Uses

func (c *Config) AppName() string

AppName returns the app name.

func (*Config) BackendHTTPAPIBaseURL Uses

func (c *Config) BackendHTTPAPIBaseURL() string

BackendHTTPAPIBaseURL returns the base URL of the backend HTTP API.

func (*Config) BackendHTTPAPIProxy Uses

func (c *Config) BackendHTTPAPIProxy() string

Proxy returns the proxy configuration to use for backend HTTP calls.

func (*Config) BackendHTTPAPIToken Uses

func (c *Config) BackendHTTPAPIToken() string

BackendHTTPAPIToken returns the access token to the backend API.

func (*Config) Disable Uses

func (c *Config) Disable() bool

Disable returns true when the agent should be disabled, false otherwise.

func (*Config) HTTPClientIPHeader Uses

func (c *Config) HTTPClientIPHeader() string

HTTPClientIPHeader returns the header to first lookup to find the client ip of a HTTP request.

func (*Config) HTTPClientIPHeaderFormat Uses

func (c *Config) HTTPClientIPHeaderFormat() string

HTTPClientIPHeaderFormat returns the header format of the `ip_header` value.

func (*Config) LocalRulesFile Uses

func (c *Config) LocalRulesFile() string

LocalRulesFile returns a JSON file containing custom rules in an array. They are added to the rules received from server.

func (*Config) LogLevel Uses

func (c *Config) LogLevel() plog.LogLevel

LogLevel returns the log level.

func (*Config) MaxMetricsStoreLength Uses

func (c *Config) MaxMetricsStoreLength() uint

MaxMetricsStoreLength returns the maximum length a metrics store should not exceed. After this limit, new metrics values will be dropped.

func (*Config) SDKMetricsPeriod Uses

func (c *Config) SDKMetricsPeriod() int

SDKMetricsPeriod returns the period to use for the SDK metric stores. This is temporary until the SDK rules are implemented and required for integration tests which require a shorter time.

func (*Config) StripHTTPReferer Uses

func (c *Config) StripHTTPReferer() bool

Disable returns true when the agent should be strip the `Referer` HTTP header, false otherwise.

type HTTPAPIEndpoint Uses

type HTTPAPIEndpoint struct {
    Method, URL string
}

Package config imports 10 packages (graph) and is imported by 4 packages. Updated 2019-11-12. Refresh now. Tools for package owners.