Documentation
¶
Overview ¶
Package netaccess validates the installation's explicit network boundary. It has no authority to start motion, launch processes, or change a firewall.
Index ¶
- Constants
- func ClientIP(r *http.Request) string
- func HasForwardingHeaders(r *http.Request) bool
- func IsForwarded(r *http.Request) bool
- func ParseOrigin(value string) (*url.URL, error)
- func RemoteEndpoint(address, baseURL string, port int, publicURL string) (string, string, error)
- func Save(ctx context.Context, db *appstore.DB, config Config) error
- func SaveTx(ctx context.Context, tx *sql.Tx, config Config) error
- type Automation
- func (a *Automation) Close()
- func (a *Automation) Discover(ctx context.Context) (InternetDiscovery, error)
- func (a *Automation) LoadManaged(policy *Policy) (CertificateProvider, error)
- func (a *Automation) LocalTrustCertificate() ([]byte, error)
- func (a *Automation) Prepare(policy *Policy) (PreparationStatus, error)
- func (a *Automation) Snapshot() PreparationStatus
- func (a *Automation) StartRenewal()
- func (a *Automation) ValidatePrepared(policy *Policy) error
- type CertificateProvider
- type CertificateStatus
- type Certificates
- type Config
- type InternetDiscovery
- type Policy
- type PreparationStatus
Constants ¶
const ( // AutomaticPublic obtains and renews a public certificate using TLS-ALPN-01. AutomaticPublic = "automatic_public" // LocalCA uses this installation's private CA; clients explicitly enroll trust. LocalCA = "local_ca" )
const ( // Local keeps remote exposure disabled. Local = "local" // DirectHTTPS terminates client TLS in MagicHandy. DirectHTTPS = "direct_https" // TrustedProxy accepts HTTPS metadata only from explicitly configured peers. TrustedProxy = "trusted_proxy" )
Variables ¶
This section is empty.
Functions ¶
func HasForwardingHeaders ¶
HasForwardingHeaders also blocks accidental forwarding to local-only routes.
func IsForwarded ¶
IsForwarded preserves the trust boundary independently of a claimed client IP.
func ParseOrigin ¶
ParseOrigin accepts one canonical HTTPS origin, with no credentials or path.
func RemoteEndpoint ¶
RemoteEndpoint derives a second origin without widening the bind interface, TLS policy or trusted proxy peers. A remote port of -1 disables the listener; zero selects the port after the main listener. Public origin overrides are useful for a trusted proxy. Direct HTTPS reuses the main host's certificate.
Types ¶
type Automation ¶
type Automation struct {
// contains filtered or unexported fields
}
Automation owns certificate work, never account authority or app listeners. Initial public issuance opens a temporary challenge-only socket. Saving the network configuration is a separate password-confirmed transaction, after a valid certificate exists. Renewal uses the already-authorized TLS listener.
func NewAutomation ¶
func NewAutomation(dataDir string) *Automation
NewAutomation does not create files, contact services, or open sockets.
func (*Automation) Close ¶
func (a *Automation) Close()
Close cancels network operations and joins every job before storage teardown.
func (*Automation) Discover ¶
func (a *Automation) Discover(ctx context.Context) (InternetDiscovery, error)
Discover coalesces repeated UI clicks and bounds provider traffic per process.
func (*Automation) LoadManaged ¶
func (a *Automation) LoadManaged(policy *Policy) (CertificateProvider, error)
LoadManaged fails closed if setup has not yet produced a valid certificate.
func (*Automation) LocalTrustCertificate ¶
func (a *Automation) LocalTrustCertificate() ([]byte, error)
LocalTrustCertificate downloads only the public root, never its signing key.
func (*Automation) Prepare ¶
func (a *Automation) Prepare(policy *Policy) (PreparationStatus, error)
Prepare starts at most one job and limits repeated public validation attempts.
func (*Automation) Snapshot ¶
func (a *Automation) Snapshot() PreparationStatus
Snapshot never includes keys, certificate paths, or provider error bodies.
func (*Automation) StartRenewal ¶
func (a *Automation) StartRenewal()
StartRenewal is called once the app owns the selected TLS listener. Issuance is scheduled independently of browser requests, preventing handshake abuse.
func (*Automation) ValidatePrepared ¶
func (a *Automation) ValidatePrepared(policy *Policy) error
ValidatePrepared only reads the saved chain; it cannot cause issuance.
type CertificateProvider ¶
type CertificateProvider interface {
TLSConfig() *tls.Config
Status() CertificateStatus
}
CertificateProvider is the common listener contract for file and managed TLS.
type CertificateStatus ¶
type CertificateStatus struct {
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
Fingerprint string `json:"sha256"`
DNSNames []string `json:"dns_names"`
RenewalDue bool `json:"renewal_due"`
ReloadError bool `json:"reload_error"`
Managed bool `json:"managed,omitempty"`
}
CertificateStatus contains public certificate metadata, never file paths/key data.
type Certificates ¶
type Certificates struct {
// contains filtered or unexported fields
}
Certificates retains the last valid chain during a failed file replacement. An expired chain is never offered. Replacements are checked at most every 30s on a handshake; the operator's CA/ACME client owns issuance and file writes.
func LoadCertificates ¶
func LoadCertificates(policy *Policy) (*Certificates, error)
LoadCertificates validates the configured identity before a listener starts.
func (*Certificates) Status ¶
func (c *Certificates) Status() CertificateStatus
Status snapshots certificate metadata without touching key files.
func (*Certificates) TLSConfig ¶
func (c *Certificates) TLSConfig() *tls.Config
TLSConfig returns a TLS 1.2+ configuration with bounded renewal checks.
type Config ¶
type Config struct {
RemotePort int `json:"remote_port,omitempty"`
RemotePublicURL string `json:"remote_public_url,omitempty"`
Mode string `json:"mode"`
ListenAddress string `json:"listen_address"`
PublicURL string `json:"public_url"`
TrustedProxies []string `json:"trusted_proxies"`
TLSCertificate string `json:"tls_certificate"`
TLSPrivateKey string `json:"tls_private_key"`
Scope string `json:"scope,omitempty"`
CertificateMode string `json:"certificate_mode,omitempty"`
AcceptedTerms string `json:"accepted_terms,omitempty"`
}
Config is persisted separately from live settings: changes apply on restart. Certificate paths belong to the host. Private-key contents never enter JSON.
type InternetDiscovery ¶
type InternetDiscovery struct {
PublicIP string `json:"public_ip"`
TermsURL string `json:"terms_url"`
IPError bool `json:"ip_error"`
CAError bool `json:"ca_error"`
ExternalPort int `json:"external_port"`
}
InternetDiscovery describes observations, never a claim of inbound reachability.
func DiscoverInternet ¶
func DiscoverInternet(ctx context.Context) InternetDiscovery
DiscoverInternet contacts only fixed services, when explicitly requested from setup. No URL from a browser is fetched. Private worker addresses stay private.
type Policy ¶
Policy is an immutable, validated listener and origin policy.
func RemotePolicy ¶
RemotePolicy reuses a validated policy and its certificate provider. ACME issuance remains on the main public 443 listener; serving the resulting certificate on the remote port does not request a second certificate.
type PreparationStatus ¶
type PreparationStatus struct {
State string `json:"state"`
Config *Config `json:"config,omitempty"`
Message string `json:"message,omitempty"`
Certificate *CertificateStatus `json:"certificate,omitempty"`
}
PreparationStatus is a bounded, public snapshot of one explicit setup action.