Documentation
¶
Index ¶
- Variables
- func EscapeAndRenderURL(r *http.Request) (properURL, htmlURL, attrURL, redirectBody string)
- func HandleHTTPSRedirect(w http.ResponseWriter, r *http.Request)
- func LintConfig(conf *Config, allowedAlpns []string) error
- func ListenAndRedirectPlainHTTP(addr string) error
- func NormalizeConfig(conf *Config) (map[string][]string, map[SNIALPN]*dnsCacheEntry)
- func RecordsToCSV(csvw *csv.Writer, records []CSVRecord) error
- func TunnelTCPConn(snialpn SNIALPN, cConn net.Conn, beConn net.Conn) (r int64, w int64, retErr error)
- type ACMEDNS
- type APIService
- type Backend
- type BasicVerifier
- type CSVRecord
- type CacheState
- type Config
- type ConfigAdmin
- type ConfigApp
- type ConfigConflict
- type ConfigDNS
- type ConfigError
- type ConfigService
- type ErrorNoTLSConfig
- type Int52
- type Int52Time
- type JSONError
- type JSONTime
- type ListenConfig
- func (lc *ListenConfig) ListenAndProxy(addr string, mux *http.ServeMux) error
- func (lc *ListenConfig) LoadConfig() Config
- func (lc *ListenConfig) RouteCloseClients(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteCloseRemotes(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteGetConfig(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteGetNewConfig(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteListConnections(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteListServices(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteSetNewConfig(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) RouteSetService(w http.ResponseWriter, r *http.Request)
- func (lc *ListenConfig) Shutdown(ctx context.Context)
- func (lc *ListenConfig) StoreConfig(conf Config)
- type PConn
- type PlainConn
- func (p *PlainConn) Close() error
- func (p *PlainConn) LocalAddr() net.Addr
- func (p *PlainConn) Read(b []byte) (int, error)
- func (p *PlainConn) RemoteAddr() net.Addr
- func (p *PlainConn) SetDeadline(t time.Time) error
- func (p *PlainConn) SetReadDeadline(t time.Time) error
- func (p *PlainConn) SetWriteDeadline(t time.Time) error
- func (p *PlainConn) TLSConnectionState() tls.ConnectionState
- func (p *PlainConn) Write(b []byte) (int, error)
- type SNIALPN
Constants ¶
This section is empty.
Variables ¶
var ErrDoNotTerminate = fmt.Errorf("a self-terminating match was found")
var HTTPFamilyALPNs = []string{
"h3",
"h2",
"h2c",
"http/0.9",
"http/1.0",
"http/1.1",
}
var Verbose bool
Functions ¶
func EscapeAndRenderURL ¶
EscapeAndRenderURL uses both querystring and html escape for the appropriate style - hrefURL is the safest
func HandleHTTPSRedirect ¶
func HandleHTTPSRedirect(w http.ResponseWriter, r *http.Request)
HandleHTTPSRedirect issues a client-side redirect via HTML meta refresh. - If the client accepts text/html (browser-like), includes <link rel="canonical">. - All clients receive 200 OK with HTML body containing meta refresh and link. - Uses the same status, headers, and logic regardless of Accept. - If Host header is missing, returns 400 Bad Request.
func LintConfig ¶
func ListenAndRedirectPlainHTTP ¶
ListenAndRedirectPlainHTTP starts an HTTP listener on :80 that redirects to HTTPS
func NormalizeConfig ¶
func RecordsToCSV ¶
RecordsToCSV serializes a list of CSV records to a CSV string.
Types ¶
type ACMEDNS ¶
type ACMEDNS struct {
Domains []string `json:"domains"`
DNSProvider certmagic.DNSProvider `json:"-"`
DNS01Provider struct {
API string `json:"api"`
Config struct {
APIToken string `json:"api_token"`
} `json:"config"`
} `json:"dns01_provider"`
}
type APIService ¶
type APIService struct {
AppSlug string `json:"app_slug"`
Slug string `json:"slug"`
Comment *string `json:"comment,omitempty"`
Disabled *bool `json:"disabled,omitempty"`
Domains []string `json:"domains"`
ALPNs []string `json:"alpns"`
BackendSlugs []string `json:"backend_slugs,omitempty"`
}
APIService defines a rule for matching domains and ALPNs to backends.
type Backend ¶
type Backend struct {
Slug string `json:"slug"`
Comment string `json:"comment,omitempty"`
Disabled bool `json:"disabled,omitempty"`
ALPNs []string `json:"alpns,omitempty"`
Address string `json:"address"`
Port uint16 `json:"port"`
Host string `json:"-"`
HTTPTunnel tun.InjectListener `json:"-"`
PROXYProto int `json:"proxy_protocol,omitempty"`
TerminateTLS bool `json:"terminate_tls"`
ForceHTTP bool `json:"force_http,omitempty"`
ConnectTLS bool `json:"connect_tls"`
RewriteHost string `json:"rewrite_host,omitempty"`
SkipTLSVerify bool `json:"connect_insecure"`
AuthToken string `json:"auth_token,omitempty"`
}
Backend defines a proxy destination.
type BasicVerifier ¶ added in v0.8.0
type CSVRecord ¶
type CSVRecord struct {
AppSlug string
Domain string
ALPN string
BackendAddress string
BackendPort uint16
TerminateTLS bool
ConnectTLS bool
RewriteHost string
SkipTLSVerify bool
Auth string
AllowedClientHostnames string
}
CSVRecord represents a single row in the CSV output.
type CacheState ¶ added in v0.8.0
type CacheState int
const ( CacheFresh CacheState = iota CacheStale CacheExpired )
type Config ¶
type Config struct {
Revision string `json:"rev,omitempty"`
Hash string `json:"hash,omitempty"`
Handler *http.ServeMux `json:"-"`
ACMEDirectoryEndpoint string `json:"-"`
FilePath string `json:"-"`
FileTime time.Time `json:"-"` // from file date
TabVault *tabvault.TabVault `json:"-"`
AdminDNS ConfigAdmin `json:"admin"`
Apps []ConfigApp `json:"apps"`
Networks []net.IPNet `json:"dynamic_host_networks"`
IPDomains []string `json:"dynamic_ip_domains"`
IPs []net.IP `json:"-"`
// contains filtered or unexported fields
}
Config holds the TLS routing configuration and hostname resolutions. Note: JSON keys are encoded in a consistent order, as per struct-order, and generic map keys are sorted.
func (*Config) Reincarnate ¶
func (c *Config) Reincarnate()
func (*Config) SetSigChan ¶
type ConfigAdmin ¶
type ConfigApp ¶
type ConfigApp struct {
Label string `json:"label"`
Slug string `json:"slug"`
Comment string `json:"comment,omitempty"`
Disabled bool `json:"disabled,omitempty"`
DNSProviders []ConfigDNS `json:"dns_providers,omitempty"`
Services []ConfigService `json:"services"`
}
ConfigApp describes an arbitrarily relationship between services
type ConfigConflict ¶
type ConfigDNS ¶
type ConfigDNS struct {
Slug string `json:"slug"`
Comment string `json:"comment,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Domains []string `json:"domains,omitempty"`
XDomains []string `json:"excluded_domains,omitempty"`
API string `json:"api"`
APIToken string `json:"api_token"`
}
ConfigDNS defines libdns-style DNS API options
type ConfigError ¶
type ConfigError struct {
Error string `json:"error"`
}
type ConfigService ¶
type ConfigService struct {
Slug string `json:"slug"`
Comment string `json:"comment,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Domains []string `json:"domains"`
ALPNs []string `json:"alpns,omitempty"`
Backends []Backend `json:"backends"`
CurrentBackend *atomic.Uint32 `json:"-"`
AllowedClientHostnames []string `json:"allowed_client_hostnames,omitempty"`
}
ConfigService defines a rule for matching domains and ALPNs to backends.
func (*ConfigService) GenSlug ¶
func (srv *ConfigService) GenSlug() string
type ErrorNoTLSConfig ¶
type ErrorNoTLSConfig string
func (ErrorNoTLSConfig) Error ¶
func (e ErrorNoTLSConfig) Error() string
type Int52 ¶
type Int52 int64
Int52 is a newtype for int that marshals/unmarshals as int64 in JSON.
func (Int52) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Int52) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Int52Time ¶
type Int52Time int64
Int52Time is a newtype for int64 that marshals/unmarshals a UnixMilli() as ISO Time in JSON.
func (Int52Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Int52Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type JSONError ¶
type JSONError struct {
Error string `json:"error"`
Code string `json:"code"`
Detail string `json:"detail"`
}
JSONError represents an API error response
type JSONTime ¶
JSONTime is a newtype for int64 that marshals/unmarshals a UnixMilli() as ISO Time in JSON.
func (JSONTime) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*JSONTime) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ListenConfig ¶
type ListenConfig struct {
Conns sync.Map
TLSMismatches sync.Map
Context context.Context
ACMEDirectoryEndpoint string
Close func()
IPPolicy *ippolicy.Policy
// contains filtered or unexported fields
}
func NewListenConfig ¶
func NewListenConfig(conf Config) *ListenConfig
func (*ListenConfig) ListenAndProxy ¶
func (lc *ListenConfig) ListenAndProxy(addr string, mux *http.ServeMux) error
func (*ListenConfig) LoadConfig ¶
func (lc *ListenConfig) LoadConfig() Config
func (*ListenConfig) RouteCloseClients ¶
func (lc *ListenConfig) RouteCloseClients(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteCloseRemotes ¶
func (lc *ListenConfig) RouteCloseRemotes(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteGetConfig ¶
func (lc *ListenConfig) RouteGetConfig(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteGetNewConfig ¶
func (lc *ListenConfig) RouteGetNewConfig(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteListConnections ¶
func (lc *ListenConfig) RouteListConnections(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteListServices ¶
func (lc *ListenConfig) RouteListServices(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteSetNewConfig ¶
func (lc *ListenConfig) RouteSetNewConfig(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) RouteSetService ¶
func (lc *ListenConfig) RouteSetService(w http.ResponseWriter, r *http.Request)
func (*ListenConfig) Shutdown ¶
func (lc *ListenConfig) Shutdown(ctx context.Context)
TODO move to *Listener
func (*ListenConfig) StoreConfig ¶
func (lc *ListenConfig) StoreConfig(conf Config)
type PConn ¶
type PConn struct {
Self bool `json:"self,omitempty"`
Address string `json:"address"`
ServerName string `json:"servername"`
ALPN string `json:"alpn"`
Read Int52 `json:"read"`
Written Int52 `json:"written"`
Since JSONTime `json:"since"`
PlainRead Int52 `json:"plain_read"`
PlainWritten Int52 `json:"plain_written"`
LastRead Int52Time `json:"last_read"`
LastWrite Int52Time `json:"last_write"`
}
func WConnToPConn ¶
func WConnToPConn(wconn *wrappedConn) PConn
type PlainConn ¶
type PlainConn struct {
BytesRead atomic.Uint64
BytesWritten atomic.Uint64
// contains filtered or unexported fields
}
PlainConn wraps a *tls.Conn as a private field (not embedded) for two reasons:
- Byte counting — Read/Write intercept plaintext traffic so we can track bandwidth at both the TLS and TCP layers independently.
- h2 detection — exposing only net.Conn makes http.Server's rwc.(*tls.Conn) assertion fail, so h2c-preface detection runs on the decrypted stream.
ConnectionState is still accessible via an explicit method for stats/reporting.
func NewPlainConn ¶
func (*PlainConn) RemoteAddr ¶ added in v0.8.0
func (*PlainConn) SetReadDeadline ¶ added in v0.8.0
func (*PlainConn) SetWriteDeadline ¶ added in v0.8.0
func (*PlainConn) TLSConnectionState ¶ added in v0.8.0
func (p *PlainConn) TLSConnectionState() tls.ConnectionState
TLSConnectionState exposes TLS state for reporting. Named to avoid matching net/http's unexported connectionStater interface, which would set tlsState and prevent h2c preface detection on the decrypted stream.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
bin
|
|
|
tlsroutercsvtojson
command
|
|
|
tlsrouterjsontocsv
command
|
|
|
cmd
|
|
|
tabvault
command
|
|
|
tlsrouter
command
|
|
|
Package dnsresolver provides a parallel DNS resolver with automatic fallback servers.
|
Package dnsresolver provides a parallel DNS resolver with automatic fallback servers. |
|
internal
|
|
|
net
|
|
|
tools
|
|
|
alpn-get
command
|