Documentation
¶
Overview ¶
Package meshforward contains the separately reviewed authority and bounded byte-stream machinery for the ARM mesh TCP service route. Nothing in this package treats SSH, sync or workspace membership as a TCP grant.
Index ¶
- Constants
- Variables
- func AuthenticateLocal(c net.Conn, digest string) (io.Reader, []byte, bool, error)
- func NewCreditNonce() (string, error)
- func ReadAccepted(r io.Reader, q Request) error
- func ServeLocal(ctx context.Context, local net.Conn, digest string, ...) error
- func ServeLocalCompatibleTLS(ctx context.Context, local net.Conn, serverTLS *tls.Config, digest string, ...) error
- func ServeLocalTLS(ctx context.Context, local net.Conn, serverTLS *tls.Config, digest string, ...) error
- func TokenDigest(token string) (string, error)
- func WriteAccepted(w io.Writer, q Request) error
- func WriteRequest(w io.Writer, q Request) error
- type AdmittedRoute
- type Endpoint
- type Grant
- type Identity
- type Proxy
- type Request
Constants ¶
const ( MaxNodes = 8 MaxLifetime = 15 * time.Minute MaxConnections = 8 MaxBytes = 8 << 30 MaxRate = 1 << 30 MaxGrantBytes = 8 << 30 )
Variables ¶
var ErrClosed = errors.New("TCP forward proxy stopped")
Functions ¶
func AuthenticateLocal ¶
AuthenticateLocal consumes only the first bounded local authentication record. HTTP is handled as one request per connection so a later header cannot leak the token through a persistent connection.
func NewCreditNonce ¶
func ServeLocal ¶
func ServeLocal(ctx context.Context, local net.Conn, digest string, open func(context.Context) (net.Conn, error)) error
ServeLocal connects one authenticated local user to one already reviewed destination stream. open must finish exact remote control admission before returning. No redirect, DNS lookup or alternate target is performed here.
func ServeLocalCompatibleTLS ¶
func ServeLocalCompatibleTLS(ctx context.Context, local net.Conn, serverTLS *tls.Config, digest string, open func(context.Context) (net.Conn, error)) error
ServeLocalCompatibleTLS keeps already-reviewed plaintext local modes usable while a fenced rollout migrates them. A TLS ClientHello is never retried as plaintext, so the updated CLI cannot downgrade after authentication fails. Plaintext callers still carry their existing bearer risk on port handoff; they must not be presented as source-authenticated clients.
func ServeLocalTLS ¶
func ServeLocalTLS(ctx context.Context, local net.Conn, serverTLS *tls.Config, digest string, open func(context.Context) (net.Conn, error)) error
ServeLocalTLS presents the existing local mesh identity before reading a bearer or application byte. The client pins that identity; the destination still performs its normal grant admission.
func TokenDigest ¶
TokenDigest accepts only the digest of a 256-bit random hex token. The backend keeps this digest, never the bearer secret or a logged URL copy.
Types ¶
type AdmittedRoute ¶
type AdmittedRoute struct {
// contains filtered or unexported fields
}
AdmittedRoute owns an original inner TLS connection only after the exact destination ACK has been read on a pinned forwarding channel. Its fields are private so an arbitrary opener cannot return a raw connection as admission.
func ReadAdmittedRoute ¶
func ReadAdmittedRoute(conn *tls.Conn, q Request) (*AdmittedRoute, error)
ReadAdmittedRoute is called only after WriteRequest on the same original inner TLS connection. The caller owns conn on every failure.
func (*AdmittedRoute) Conn ¶
func (a *AdmittedRoute) Conn() *tls.Conn
func (*AdmittedRoute) Request ¶
func (a *AdmittedRoute) Request() Request
type Endpoint ¶
type Endpoint struct {
Name string `json:"name"`
Network string `json:"network"`
Address string `json:"address"`
}
Endpoint names one destination-local service. The address is installed by that destination's operator; no route request can supply or replace it. Literal loopback IPs avoid DNS rebinding and accidental LAN exposure.
type Grant ¶
type Grant struct {
Workspace string `json:"workspace"`
Generation string `json:"generation"`
Source string `json:"source"`
Target string `json:"target"`
SourceGeneration int64 `json:"source_generation"`
TargetGeneration int64 `json:"target_generation"`
DirectoryPin string `json:"directory_pin"`
DirectorySPKI string `json:"directory_spki"`
SourcePin string `json:"source_pin"`
SourceSPKI string `json:"source_spki"`
TargetPin string `json:"target_pin"`
TargetSPKI string `json:"target_spki"`
Account string `json:"account"`
Endpoint Endpoint `json:"endpoint"`
Revision int64 `json:"revision"`
MaxConnections int `json:"max_connections"`
BytesPerConnection int64 `json:"bytes_per_connection"`
BytesPerSecond int64 `json:"bytes_per_second"`
TotalBytes int64 `json:"total_bytes,omitempty"`
CreditNonce string `json:"credit_nonce,omitempty"`
Transit model.Resources `json:"transit_resources"`
MaxTTL time.Duration `json:"max_ttl_ns"`
Expires time.Time `json:"expires_at"`
}
Grant is destination-local TCP authority for one original source and one exact installed service. A relay's own grant cannot be substituted.
func (Grant) ValidateCredit ¶
ValidateCredit distinguishes readable legacy policy records from grants that can open a new stream. A lifetime limit is never inferred from other limits.
type Identity ¶
type Identity struct {
SourcePin, SourceSPKI, TargetPin, TargetSPKI, Account string
}
Identity must come from the checked, pinned inner TLS peer certificate and current destination service binding, never from a route header or relay.
type Proxy ¶
type Proxy struct {
Dial func(context.Context, string, string) (net.Conn, error) // nil uses net.Dialer
CheckCredit func(context.Context, Grant) error
Credit func(context.Context, Grant, int) (int, error) // required durable destination-local prepayment
// contains filtered or unexported fields
}
Proxy owns final destination TCP streams. Grant must read the current local grant on every call; a missing grant denies by default. The caller owns the authenticated carrier and must join this Open before settling its lease.
func (*Proxy) Open ¶
func (p *Proxy) Open(ctx context.Context, q Request, who Identity, stream net.Conn, grantNow func(context.Context) (Grant, error), ready func() error) error
Open returns only after both copy workers, the revocation watcher, and the final socket have joined. The caller's route and Manager holds remain live until it returns. Any transfer failure is an unknown application outcome.
type Request ¶
type Request struct {
Version int `json:"schema_version"`
Workspace string `json:"workspace"`
Generation string `json:"generation"`
Source string `json:"source"`
Target string `json:"target"`
SourcePin string `json:"source_pin"`
TargetPin string `json:"target_pin"`
Service string `json:"service"`
GrantRevision int64 `json:"grant_revision"`
ConnectionID string `json:"connection_id"`
TTL time.Duration `json:"ttl_ns"`
RouteBindingHash string `json:"route_binding_sha256"`
}
Request is authenticated by the pinned inner TLS channel. It has no dial address and no SSH or sync selector.