httpsvc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(tunnel string, vhost, control, opsH http.Handler, st *httpStats, routed func(string) bool, lim *liveLimits) (http.Handler, error)

Handler sends the tunnel name to the ops API and frp control, and a host that routed reports to vhost, which is frps's site proxy in this process. Any other host gets no response at all. A nil routed passes every host to vhost. A nil lim uses the default limits; a nil control leaves frp control out.

func NodeOnly

func NodeOnly(tunnel string) func(tls.ConnectionState) error

NodeOnly accepts a verified client certificate only when it carries a dark-node identity of tunnel: spiffe://<tunnel>/node/<name>. It guards frp control on TCP 443 and, through frps, on QUIC.

func QUICCertificate

func QUICCertificate(ctx context.Context, cfg config.Config, domains *Domains) (func(*tls.ClientHelloInfo) (*tls.Certificate, error), error)

QUICCertificate is what frps presents on UDP 443, and only to the tunnel name: a probe naming anything else gets no certificate. It is the certmagic config TCP 443 uses, so both present the same certificate and a renewal on either is used by the other's next handshake.

func Serve

func Serve(ctx context.Context, cfg config.Config, policy []byte, filt edgeFilter, domains *Domains, control, vhost http.Handler, apply ops.ApplyFunc, reboot func()) error

Serve runs the HTTP and HTTPS servers until ctx ends. policy is the policy.yml cfg holds, as stored; apply stores and applies a new one.

Types

type Domains

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

Domains is the set of hostnames that currently have an HTTP route. frps reports a name when its first route appears and when its last route disappears. Under tls: acme, the first report of an exact name manages its certificate: loaded from disk, or obtained. certmagic's timer then checks it every renew_interval and renews it once it is due. The last report stops that; the certificate stays on disk.

func NewDomains

func NewDomains(tunnel string) *Domains

func (*Domains) Allowed

func (d *Domains) Allowed(name string) bool

Allowed is the tunnel name, or an exact name a dark node currently has registered: the names that may have a certificate.

func (*Domains) Domain

func (d *Domains) Domain(domain string, added bool)

Domain is the frps vhost callback. added is true when the name gains its first route and false when it loses its last. frps calls it with its router lock held, so the obtain runs in the background.

func (*Domains) Known

func (d *Domains) Known(name string) bool

Known is a name the edge answers for: the tunnel or a routed site. Anything else gets no certificate, no status code, and no bytes.

func (*Domains) Routed

func (d *Domains) Routed(host string) bool

Routed reports whether frps has a route for host, matched the way its router matches: the exact name, then each wildcard parent down to three labels (a.b.example.com tries *.b.example.com, then *.example.com), then a catch-all "*".

Jump to

Keyboard shortcuts

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