aidproxy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package aidproxy implements the AID Resource Addressing Gateway.

It exposes an Handler that translates

http://127.0.0.1:2121/aid/{address}/{path...}

URLs into outbound connections to the named AID, streaming raw HTTP/1.1 over the transport layer (QUIC stream for remote AIDs, direct TCP for locally registered agents).

The handler is mounted at /aid/ outside the daemon's main middleware chain so that arbitrary Content-Types and large request bodies are supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain []Resolver

Chain tries each Resolver in order, returning the first successful result.

func NewChain

func NewChain(resolvers ...Resolver) Chain

NewChain constructs a Chain from the given resolvers.

func (Chain) Resolve

func (c Chain) Resolve(ctx context.Context, address string) (a2al.Address, error)

Resolve implements Resolver by trying each resolver in sequence.

type Dialer

type Dialer interface {
	Dial(ctx context.Context, remote a2al.Address) (io.ReadWriteCloser, error)
}

Dialer opens a bidirectional stream to a remote AID.

The returned io.ReadWriteCloser carries raw HTTP/1.1 bytes:

  • For remote AIDs: a QUIC stream through the Tangled Network.
  • For locally registered AIDs: a direct TCP connection to service_tcp.

The caller is responsible for closing the returned stream.

type Handler

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

Handler is the AID Resource Addressing Gateway http.Handler.

It parses the AID address from the URL path, resolves it, dials a stream to the remote AID, and bidirectionally proxies the raw HTTP/1.1 exchange.

func New

func New(resolver Resolver, dialer Dialer, log *slog.Logger) *Handler

New creates a Handler with the given resolver, dialer, and logger. If log is nil, slog.Default is used.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles requests of the form /aid/{address}[/{path}[?{query}]].

URL structure:

/aid/{address}[/{path}[?{query}]]

{address} is resolved via the Resolver chain to an a2al.Address. The request is then forwarded over the stream with its original method, headers, and body. The response is streamed back verbatim.

type RawAIDResolver

type RawAIDResolver struct{}

RawAIDResolver resolves raw AID strings (the primary Phase 1 resolver). Later phases add DNS TXT bridging and DHT name resolution as additional links in a Chain.

func (RawAIDResolver) Resolve

func (RawAIDResolver) Resolve(_ context.Context, address string) (a2al.Address, error)

Resolve parses a raw AID string.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, address string) (a2al.Address, error)
}

Resolver maps an address string to an a2al.Address. Implementations may support raw AID strings, DNS TXT records, or other naming systems. Multiple resolvers can be composed with Chain.

Jump to

Keyboard shortcuts

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