proxy

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Overview

* * Copyright (c) 2020 Ameya Lokare

* * Copyright (c) 2020 Ameya Lokare

*

  • Copyright (c) 2020 Ameya Lokare

Index

Constants

View Source
const (
	ReasonCodeHeader string = "X-WhSentry-ReasonCode"
	ReasonHeader     string = "X-WhSentry-Reason"

	BlockedIPAddress           uint16 = 1000
	UnableToResolveIP          uint16 = 1001
	InvalidRequestURI          uint16 = 1002
	InvalidUrlScheme           uint16 = 1003
	RequestTimedOut            uint16 = 1004
	TLSHandshakeError          uint16 = 1005
	TCPConnectionError         uint16 = 1006
	CertificateValidationError uint16 = 1007
	ResponseTooLarge           uint16 = 1008
	InternalServerError        uint16 = 1009
	ClientCertNotFoundError    uint16 = 1010
)

Variables

This section is empty.

Functions

func CreateProxyServers

func CreateProxyServers(proxyConfig *ProxyConfig) []*http.Server

func InitConfig

func InitConfig(config *ProxyConfig) error

func PublicKey

func PublicKey(priv interface{}) interface{}

func SetupLogging

func SetupLogging(config *ProxyConfig) error

func SetupMetrics

func SetupMetrics(metricsAddress string)

func StartHTTPServer

func StartHTTPServer(listenAddress string, server *http.Server, wg *sync.WaitGroup)

func StartTLSServer

func StartTLSServer(listenAddress, certFile, keyFile string, server *http.Server, wg *sync.WaitGroup)

Types

type AccessLogTextFormatter

type AccessLogTextFormatter struct {
}

func (*AccessLogTextFormatter) Format

func (f *AccessLogTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

type Cidr

type Cidr net.IPNet

func (*Cidr) UnmarshalYAML

func (cidr *Cidr) UnmarshalYAML(unmarshal func(interface{}) error) error

type ListenerConfig

type ListenerConfig struct {
	Address  string
	Type     Protocol
	CertFile string `yaml:"certFile"`
	KeyFile  string `yaml:"keyFile"`
}

type LogConfig

type LogConfig struct {
	File string
	Type LogType
}

type LogType

type LogType string
const (
	JSON LogType = "json"
	Text LogType = "text"
)

type Mitmer

type Mitmer struct {
	// contains filtered or unexported fields
}

func NewMitmer

func NewMitmer() (*Mitmer, error)

func (*Mitmer) HandleHttpConnect

func (m *Mitmer) HandleHttpConnect(requestID string, w http.ResponseWriter, r *http.Request)

type Protocol

type Protocol string
const (
	HTTP  Protocol = "http"
	HTTPS Protocol = "https"
)

type ProxyConfig

type ProxyConfig struct {
	CidrDenyList                 []Cidr                     `yaml:"cidrDenyList"`
	Listeners                    []ListenerConfig           `yaml:"listeners"`
	ConnectTimeout               time.Duration              `yaml:"connectTimeout"`
	ConnectionLifetime           time.Duration              `yaml:"connectionLifetime"`
	ReadTimeout                  time.Duration              `yaml:"readTimeout"`
	MaxResponseBodySize          uint32                     `yaml:"maxResponseBodySize"`
	InsecureSkipCertVerification bool                       `yaml:"insecureSkipCertVerification"`
	InsecureSkipCidrDenyList     bool                       `yaml:"insecureSkipCidrDenyList"`
	ClientCertFile               string                     `yaml:"clientCertFile"`
	ClientKeyFile                string                     `yaml:"clientKeyFile"`
	ClientCerts                  map[string]tls.Certificate `yaml:"-"`
	RootCACerts                  *x509.CertPool             `yaml:"-"` // TODO: not taking a file override yet
	MitmIssuerCertFile           string                     `yaml:"mitmIssuerCertFile"`
	MitmIssuerKeyFile            string                     `yaml:"mitmIssuerKeyFile"`
	MitmIssuerCert               *tls.Certificate           `yaml:"-"`
	AccessLog                    LogConfig                  `yaml:"accessLog"`
	ProxyLog                     LogConfig                  `yaml:"proxyLog"`
	MetricsAddress               string                     `yaml:"metricsAddress"`
	RequestIDHeader              string                     `yaml:"requestIDHeader"`
}

func InitDefaultConfig

func InitDefaultConfig() (*ProxyConfig, error)

func NewDefaultConfig

func NewDefaultConfig() *ProxyConfig

func UnmarshalConfig

func UnmarshalConfig(configData []byte) (*ProxyConfig, error)

func UnmarshalConfigFromFile

func UnmarshalConfigFromFile(configFile string) (*ProxyConfig, error)

func (*ProxyConfig) Validate added in v1.1.0

func (config *ProxyConfig) Validate() error

type ProxyHTTPHandler

type ProxyHTTPHandler struct {
	// contains filtered or unexported fields
}

ProxyHTTPHandler some struct

func (*ProxyHTTPHandler) ServeHTTP

func (p *ProxyHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProxyLogTextFormatter

type ProxyLogTextFormatter struct {
}

func (*ProxyLogTextFormatter) Format

func (f *ProxyLogTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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