config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWarpRoutingConnectTime  = 5 * time.Second
	DefaultWarpRoutingTCPKeepAlive = 30 * time.Second
)

Variables

This section is empty.

Functions

func CanonicalizeHTTPOriginURL

func CanonicalizeHTTPOriginURL(parsedURL *url.URL) *url.URL

func IsHTTPServiceScheme

func IsHTTPServiceScheme(scheme string) bool

func MatchIngressHost

func MatchIngressHost(pattern, hostname string) bool

func MatchIngressRule

func MatchIngressRule(rule CompiledIngressRule, hostname, path string) bool

func ResolvePolicyDestination

func ResolvePolicyDestination(ctx context.Context, destination M.Socksaddr) (netip.Addr, error)

func ValidateHostname

func ValidateHostname(hostname string, isLast bool) error

Types

type AccessConfig

type AccessConfig struct {
	Required    bool
	TeamName    string
	AudTag      []string
	Environment string
}

type CompiledIPRule

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

type CompiledIngressRule

type CompiledIngressRule struct {
	Hostname         string
	PunycodeHostname string
	Path             *regexp.Regexp
	Service          ResolvedService
}

func CompileIngressRules

func CompileIngressRules(defaultOriginRequest OriginRequestConfig, rawRules []LocalIngressRule) ([]CompiledIngressRule, error)

type ConfigManager

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

func NewConfigManager

func NewConfigManager() (*ConfigManager, error)

func (*ConfigManager) Apply

func (m *ConfigManager) Apply(version int32, raw []byte) UpdateResult

func (*ConfigManager) CurrentVersion

func (m *ConfigManager) CurrentVersion() int32

func (*ConfigManager) Resolve

func (m *ConfigManager) Resolve(hostname, path string) (ResolvedService, bool)

func (*ConfigManager) Snapshot

func (m *ConfigManager) Snapshot() RuntimeConfig

type IPRule

type IPRule struct {
	Prefix string
	Ports  []int
	Allow  bool
}

type IPRulePolicy

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

func NewIPRulePolicy

func NewIPRulePolicy(rawRules []IPRule) (*IPRulePolicy, error)

func (*IPRulePolicy) Allow

func (p *IPRulePolicy) Allow(ctx context.Context, destination M.Socksaddr) (bool, error)

type LocalIngressRule

type LocalIngressRule struct {
	Hostname      string
	Path          string
	Service       string
	OriginRequest OriginRequestConfig
}

type OriginRequestConfig

type OriginRequestConfig struct {
	ConnectTimeout         time.Duration
	TLSTimeout             time.Duration
	TCPKeepAlive           time.Duration
	NoHappyEyeballs        bool
	KeepAliveTimeout       time.Duration
	KeepAliveConnections   int
	HTTPHostHeader         string
	OriginServerName       string
	MatchSNIToHost         bool
	CAPool                 string
	NoTLSVerify            bool
	DisableChunkedEncoding bool
	BastionMode            bool
	ProxyAddress           string
	ProxyPort              uint
	ProxyType              string
	IPRules                []IPRule
	HTTP2Origin            bool
	Access                 AccessConfig
}

func DefaultOriginRequestConfig

func DefaultOriginRequestConfig() OriginRequestConfig

type RemoteAccessJSON

type RemoteAccessJSON struct {
	Required    bool     `json:"required,omitempty"`
	TeamName    string   `json:"teamName,omitempty"`
	AudTag      []string `json:"audTag,omitempty"`
	Environment string   `json:"environment,omitempty"`
}

type RemoteConfigJSON

type RemoteConfigJSON struct {
	OriginRequest RemoteOriginRequestJSON `json:"originRequest"`
	Ingress       []RemoteIngressRuleJSON `json:"ingress"`
	WarpRouting   RemoteWarpRoutingJSON   `json:"warp-routing"`
}

type RemoteIPRuleJSON

type RemoteIPRuleJSON struct {
	Prefix string `json:"prefix,omitempty"`
	Ports  []int  `json:"ports,omitempty"`
	Allow  bool   `json:"allow,omitempty"`
}

type RemoteIngressRuleJSON

type RemoteIngressRuleJSON struct {
	Hostname      string                  `json:"hostname,omitempty"`
	Path          string                  `json:"path,omitempty"`
	Service       string                  `json:"service"`
	OriginRequest RemoteOriginRequestJSON `json:"originRequest,omitempty"`
}

type RemoteOriginRequestJSON

type RemoteOriginRequestJSON struct {
	ConnectTimeout         int64              `json:"connectTimeout,omitempty"`
	TLSTimeout             int64              `json:"tlsTimeout,omitempty"`
	TCPKeepAlive           int64              `json:"tcpKeepAlive,omitempty"`
	NoHappyEyeballs        *bool              `json:"noHappyEyeballs,omitempty"`
	KeepAliveTimeout       int64              `json:"keepAliveTimeout,omitempty"`
	KeepAliveConnections   *int               `json:"keepAliveConnections,omitempty"`
	HTTPHostHeader         string             `json:"httpHostHeader,omitempty"`
	OriginServerName       string             `json:"originServerName,omitempty"`
	MatchSNIToHost         *bool              `json:"matchSNIToHost,omitempty"`
	CAPool                 string             `json:"caPool,omitempty"`
	NoTLSVerify            *bool              `json:"noTLSVerify,omitempty"`
	DisableChunkedEncoding *bool              `json:"disableChunkedEncoding,omitempty"`
	BastionMode            *bool              `json:"bastionMode,omitempty"`
	ProxyAddress           string             `json:"proxyAddress,omitempty"`
	ProxyPort              *uint              `json:"proxyPort,omitempty"`
	ProxyType              string             `json:"proxyType,omitempty"`
	IPRules                []RemoteIPRuleJSON `json:"ipRules,omitempty"`
	HTTP2Origin            *bool              `json:"http2Origin,omitempty"`
	Access                 *RemoteAccessJSON  `json:"access,omitempty"`
}

type RemoteWarpRoutingJSON

type RemoteWarpRoutingJSON struct {
	ConnectTimeout int64  `json:"connectTimeout,omitempty"`
	MaxActiveFlows uint64 `json:"maxActiveFlows,omitempty"`
	TCPKeepAlive   int64  `json:"tcpKeepAlive,omitempty"`
}

type ResolvedService

type ResolvedService struct {
	Kind          ResolvedServiceKind
	Service       string
	Destination   M.Socksaddr
	StreamHasPort bool
	BaseURL       *url.URL
	UnixPath      string
	StatusCode    int
	SocksPolicy   *IPRulePolicy
	OriginRequest OriginRequestConfig
}

func ParseResolvedService

func ParseResolvedService(rawService string, originRequest OriginRequestConfig) (ResolvedService, error)

func (ResolvedService) BuildRequestURL

func (s ResolvedService) BuildRequestURL(requestURL string) (string, error)

func (ResolvedService) RouterControlled

func (s ResolvedService) RouterControlled() bool

type ResolvedServiceKind

type ResolvedServiceKind int
const (
	ResolvedServiceHTTP ResolvedServiceKind = iota
	ResolvedServiceStream
	ResolvedServiceStatus
	ResolvedServiceUnix
	ResolvedServiceUnixTLS
	ResolvedServiceBastion
	ResolvedServiceSocksProxy
)

type RuntimeConfig

type RuntimeConfig struct {
	Ingress       []CompiledIngressRule
	OriginRequest OriginRequestConfig
	WarpRouting   WarpRoutingConfig
}

func BuildRemoteRuntimeConfig

func BuildRemoteRuntimeConfig(raw []byte) (RuntimeConfig, error)

func DefaultRuntimeConfig

func DefaultRuntimeConfig() (RuntimeConfig, error)

func (RuntimeConfig) Resolve

func (c RuntimeConfig) Resolve(hostname, path string) (ResolvedService, bool)

type UpdateResult

type UpdateResult struct {
	LastAppliedVersion int32
	Err                error
}

type WarpRoutingConfig

type WarpRoutingConfig struct {
	ConnectTimeout time.Duration
	MaxActiveFlows uint64
	TCPKeepAlive   time.Duration
}

func WarpRoutingFromRemote

func WarpRoutingFromRemote(input RemoteWarpRoutingJSON) WarpRoutingConfig

Jump to

Keyboard shortcuts

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