protocols

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidScheme = fmt.Errorf("invalid scheme")

Functions

func EncodeURLWithMetadata

func EncodeURLWithMetadata(scheme string, host string, metadata Metadata, keyUsername, keyPassword string) string

func RegisterAlias

func RegisterAlias(k, v string)

func RegisterReverseAlias

func RegisterReverseAlias(k, v string)

func RegisterScheme

func RegisterScheme(scheme string, schemeInfo SchemeInfo)

Types

type AddressKind

type AddressKind uint8
var (
	AddressHost   AddressKind = 1
	AddressPath   AddressKind = 2
	AddressOpaque AddressKind = 3
)

type Endpoint

type Endpoint struct {
	// Network is the name of the network.
	// stream-like, e.g. tcp, unix, etc.
	// packet-like, e.g. udp, unixpacket, etc.
	Network string `json:"network"`
	// Address is the address of the endpoint.
	// e.g. "localhost:8080", "/tmp/foo.sock"
	Address string `json:"address"`
}

Endpoint represents a network endpoint.

type Metadata

type Metadata = url.Values

Metadata is a map of metadata fields.

type Protocol

type Protocol struct {
	// Wrappers is a list of network wrappers.
	Wrappers []Wrapper `json:"wrappers,omitempty"`
	// Endpoint is the endpoint of the protocol.
	Endpoint Endpoint `json:"endpoint"`
}

Protocol represents a network protocol.

func NewProtocol

func NewProtocol(rawURI string) (*Protocol, error)

func NewProtocolFrom

func NewProtocolFrom(uri *url.URL) (*Protocol, error)

func (*Protocol) String

func (p *Protocol) String() string

func (*Protocol) URI

func (p *Protocol) URI() *url.URL

type SchemeInfo

type SchemeInfo struct {
	Kind        SchemeKind
	Base        SchemeKind
	AddressKind AddressKind

	MetaFields []string

	// Match username/password of url
	UsernameField string
	PasswordField string
}

type SchemeKind

type SchemeKind string
var (
	KindNone   SchemeKind = ""
	KindStream SchemeKind = "stream"
	KindPacket SchemeKind = "packet"
	KindProxy  SchemeKind = "proxy"
)

type Wrapper

type Wrapper struct {
	// Scheme is the scheme of the wrapper.
	Scheme string `json:"scheme"`
	// Metadata is the metadata of the wrapper.
	Metadata Metadata `json:"metadata,omitempty"`
}

Wrapper is a network wrapper. Wrap a packet-like network with a stream-like network. e.g. udp -> quic Wrap a stream-like network with a stream-like network. e.g. tls or compression Wrap a stream-like network with a proxy. e.g. tcp -> socks5

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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