proxy

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderJA3   = "X-JA3-Fingerprint"
	HeaderJA4   = "X-JA4-Fingerprint"
	HeaderJA4H  = "X-JA4H-Fingerprint"
	HeaderHTTP2 = "X-HTTP2-Fingerprint"
)
View Source
const DefaultBodyLimit int64 = 1 << 20 // 1MB
View Source
const DefaultProxyCacheSize = 32

DefaultProxyCacheSize controls how many upstream reverse proxies are kept in memory. Tests may override ProxyCacheSize to tune behaviour.

Variables

BodyLimit controls how many bytes of the request body are captured for logging and Suricata matching. The full body is still forwarded upstream. The value can be adjusted for testing or tuning.

View Source
var ProxyCacheSize int = DefaultProxyCacheSize

ProxyCacheSize defines the maximum number of cached reverse proxies. It can be overridden for testing or via configuration.

Functions

This section is empty.

Types

type Server

type Server struct {
	*proxyserver.Server
	ID           string
	ListenAddr   string
	UpstreamURL  *url.URL
	LocalEngine  *rules.Engine
	GlobalEngine *rules.Engine
	Logger       *logger.Logger
	Hub          *sse.Hub
	Service      atomic.Pointer[galah.Service]

	SuricataSet *atomic.Pointer[suricata.RuleSet]

	CertFile           string
	KeyFile            string
	UpstreamCAFile     string
	UpstreamSkipVerify bool
	// contains filtered or unexported fields
}

Server wraps proxyserver.Server and holds minimal configuration.

func New

func New(id, listenAddr, upstreamURL, certFile, keyFile string, lgr *logger.Logger, localEng, globalEng *rules.Engine, suriSet *atomic.Pointer[suricata.RuleSet], hub *sse.Hub, svc *galah.Service, upstreamCAFile string, upstreamSkipVerify bool) (*Server, error)

New creates a Server that listens on listenAddr and forwards to upstreamURL. A self-signed certificate is generated if certFile and keyFile are empty. The provided logger records request events and can be shared by multiple servers.

func NewEcho

func NewEcho(id, listenAddr, certFile, keyFile string) (*Server, error)

NewEcho creates a Server that returns fingerprint information for every request instead of proxying to an upstream.

func (*Server) Close

func (s *Server) Close() error

Close immediately closes the server.

func (*Server) SetGalahOptions

func (s *Server) SetGalahOptions(cache, events bool)

SetGalahOptions updates Galah cache and event logging settings.

func (*Server) SetGalahService

func (s *Server) SetGalahService(svc *galah.Service)

SetGalahService stores svc atomically and updates the rule handler.

func (*Server) SetGlobalEngine

func (s *Server) SetGlobalEngine(eng *rules.Engine)

SetGlobalEngine replaces the shared rule engine.

func (*Server) SetLocalEngine

func (s *Server) SetLocalEngine(eng *rules.Engine)

SetLocalEngine replaces the listener-specific rule engine.

func (*Server) SetSuricataSet

func (s *Server) SetSuricataSet(set *atomic.Pointer[suricata.RuleSet])

SetSuricataSet replaces the active Suricata rule set.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server, waiting for active requests to finish.

func (*Server) Start

func (s *Server) Start() error

Start runs the HTTPS server.

type TarpitConfig

type TarpitConfig struct {
	// StatusCode is the HTTP status written once the connection is accepted.
	// If zero, http.StatusOK is used.
	StatusCode int

	// IntervalMin and IntervalMax define the range for random intervals between
	// writes. Defaults are 3s and 7s respectively when unset.
	IntervalMin time.Duration
	IntervalMax time.Duration

	// DelayMin and DelayMax bound the total duration of the tarpit. Defaults are
	// 45s and 120s when unset.
	DelayMin time.Duration
	DelayMax time.Duration

	// Concurrency is an optional semaphore channel that limits the maximum
	// number of concurrent tarpits. If nil, no limit is applied.
	Concurrency chan struct{}
}

TarpitConfig configures the tarpit handler.

Jump to

Keyboard shortcuts

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