transport

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package transport implements an origin-bound HTTP transport for authorized endpoint testing. It does not discover or scan targets.

Index

Constants

View Source
const (
	DefaultMaxRequestBytes  int64 = 16 << 20
	DefaultMaxResponseBytes int64 = 64 << 20
)

Variables

View Source
var (
	ErrOriginViolation = errors.New("request escaped the authorized origin")
	ErrBlockedAddress  = errors.New("destination address is forbidden by runner network policy")
	ErrBodyLimit       = errors.New("HTTP body exceeded the configured hard limit")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(policy Policy) (*Client, error)

func (*Client) CloseIdleConnections

func (client *Client) CloseIdleConnections()

func (*Client) Do

func (client *Client) Do(ctx context.Context, method, path string, headers http.Header, body []byte) (Response, error)

Do sends one request to a relative path within the exact authorized origin. Absolute paths, userinfo, fragments, and cross-origin URLs are rejected.

type NetworkMode

type NetworkMode string
const (
	// NetworkLocalTarget runs on the user's machine and permits the addresses
	// of one explicitly configured, exact-origin target. The target itself may
	// be loopback, private-network, or public; "local" describes the runner.
	NetworkLocalTarget NetworkMode = "local_target"
	// NetworkPublicRunner rejects non-public, link-local, multicast, and
	// unspecified addresses. It is intended for project-operated runners.
	NetworkPublicRunner NetworkMode = "public_runner"
)

type Policy

type Policy struct {
	AllowedOrigin    string
	Mode             NetworkMode
	Redirects        RedirectPolicy
	MaxRedirects     int
	AllowPlainHTTP   bool
	MaxRequestBytes  int64
	MaxResponseBytes int64
	Timeout          time.Duration
	Resolver         Resolver
	Dialer           *net.Dialer
	TLSConfig        *TLSConfig
}

type RedirectPolicy

type RedirectPolicy string
const (
	RedirectNone       RedirectPolicy = "none"
	RedirectSameOrigin RedirectPolicy = "same_origin"
)

type Resolver

type Resolver interface {
	LookupNetIP(context.Context, string, string) ([]netip.Addr, error)
}

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       []byte
	Protocol   string
	Duration   time.Duration
}

type TLSConfig

type TLSConfig struct {
	RootCAsFile string
	ServerName  string
}

TLSConfig is the small stable subset callers may tune. InsecureSkipVerify is intentionally absent.

Jump to

Keyboard shortcuts

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