proxyparser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package proxyparser compiles proxy formats and parses proxy strings into proxykit.Proxy values.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidProxyFormat is returned when parsed fields fail
	// [proxykit.Proxy.IsValid].
	ErrInvalidProxyFormat error = errors.New("proxyparser: parsed string is not a valid proxy format")
	// ErrInvalidFormatEndStr is returned by [New] when format ends with an
	// incomplete verb.
	ErrInvalidFormatEndStr error = errors.New("proxyparser: format string cannot end with '%'")
	// ErrHostNotParsed is returned when lenient parsing produces no host.
	ErrHostNotParsed error = errors.New("proxyparser: could not parse host")
	// ErrSchemeNotParsed is returned when lenient parsing produces no scheme.
	ErrSchemeNotParsed error = errors.New("proxyparser: could not parse scheme")
	// ErrNilProxy is returned by [ProxyParser.ParseInto] when dst is nil.
	ErrNilProxy error = errors.New("proxyparser: nil proxy destination")
)

Functions

This section is empty.

Types

type ErrInvalidFormatVerb

type ErrInvalidFormatVerb byte

ErrInvalidFormatVerb records an unsupported verb passed to New.

func (ErrInvalidFormatVerb) Error

func (err ErrInvalidFormatVerb) Error() string

Error returns a description of the unsupported format verb.

type ErrMismatchDelim

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

ErrMismatchDelim records a delimiter mismatch during strict parsing.

func (ErrMismatchDelim) Error

func (err ErrMismatchDelim) Error() string

Error returns a description of the delimiter mismatch.

type ErrSubseqDelimNotFound

type ErrSubseqDelimNotFound string

ErrSubseqDelimNotFound records a delimiter missing after a parsed field.

func (ErrSubseqDelimNotFound) Error

func (err ErrSubseqDelimNotFound) Error() string

Error returns a description of the missing subsequent delimiter.

type ErrUnexpectedDelim

type ErrUnexpectedDelim string

ErrUnexpectedDelim records a required delimiter missing from input.

func (ErrUnexpectedDelim) Error

func (err ErrUnexpectedDelim) Error() string

Error returns a description of the missing delimiter.

type ErrUnexpectedTrail

type ErrUnexpectedTrail string

ErrUnexpectedTrail records input remaining after strict parsing.

func (ErrUnexpectedTrail) Error

func (err ErrUnexpectedTrail) Error() string

Error returns a description of the unparsed input.

type ProxyParser

type ProxyParser interface {
	// Parse parses input and returns a newly allocated [proxykit.Proxy].
	Parse(input string) (*proxykit.Proxy, error)

	// ParseInto resets dst and parses input into it.
	// Successful parsing does not allocate for standard proxy formats.
	ParseInto(input string, dst *proxykit.Proxy) error
}

ProxyParser parses proxy strings according to a format compiled by New. A ProxyParser is safe for concurrent use by multiple goroutines.

func New

func New(format string, strict bool) (ProxyParser, error)

New compiles format and returns a ProxyParser.

Format accepts %t for scheme, %h for host, %d for port, %u for username, %p for password, and %% for a literal percent sign.

In strict mode, input must match format exactly. In lenient mode, missing credentials and ports are tolerated after a scheme and host are parsed, and trailing input is ignored.

Jump to

Keyboard shortcuts

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