outbounds

package
v0.0.0-...-0cae4bf Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrEx

type AddrEx struct {
	Host        string // String representation of the host, can be an IP or a domain name
	Port        uint16
	ResolveInfo *ResolveInfo // Only set if there's a resolver in the pipeline
}

AddrEx keeps both the original string representation of the address and the resolved IP addresses from the resolver, if any. The actual outbound implementations can choose to use either the string representation or the resolved IP addresses, depending on their capabilities. A SOCKS5 outbound, for example, should prefer the string representation because SOCKS5 protocol supports sending the hostname to the proxy server and let the proxy server do the DNS resolution.

func (*AddrEx) String

func (a *AddrEx) String() string

type DirectOutboundMode

type DirectOutboundMode int
const (
	DirectOutboundModeAuto DirectOutboundMode = iota // Dual-stack "happy eyeballs"-like mode
	DirectOutboundMode64                             // Use IPv6 address when available, otherwise IPv4
	DirectOutboundMode46                             // Use IPv4 address when available, otherwise IPv6
	DirectOutboundMode6                              // Use IPv6 only, fail if not available
	DirectOutboundMode4                              // Use IPv4 only, fail if not available

)

type OutboundEntry

type OutboundEntry struct {
	Name     string
	Outbound PluggableOutbound
}

type PluggableOutbound

type PluggableOutbound interface {
	TCP(reqAddr *AddrEx) (net.Conn, error)
	UDP(reqAddr *AddrEx) (UDPConn, error)
}

PluggableOutbound differs from the built-in Outbound interface from Hysteria core in that it uses an AddrEx struct for addresses instead of a string. Because of this difference, we need a special PluggableOutboundAdapter to convert between the two for use in Hysteria core config.

func NewACLEngineFromFile

func NewACLEngineFromFile(filename string, outbounds []OutboundEntry, geoLoader acl.GeoLoader) (PluggableOutbound, error)

func NewACLEngineFromString

func NewACLEngineFromString(rules string, outbounds []OutboundEntry, geoLoader acl.GeoLoader) (PluggableOutbound, error)

func NewDirectOutboundBindToDevice

func NewDirectOutboundBindToDevice(mode DirectOutboundMode, deviceName string) (PluggableOutbound, error)

NewDirectOutboundBindToDevice creates a new directOutbound with the given mode, and binds to the given device. Only works on Linux.

func NewDirectOutboundBindToIPs

func NewDirectOutboundBindToIPs(mode DirectOutboundMode, bindIP4, bindIP6 net.IP) (PluggableOutbound, error)

NewDirectOutboundBindToIPs creates a new directOutbound with the given mode, and binds to the given IPv4 and IPv6 addresses. Either or both of the addresses can be nil, in which case the directOutbound will not bind to a specific address for that family.

func NewDirectOutboundSimple

func NewDirectOutboundSimple(mode DirectOutboundMode) PluggableOutbound

NewDirectOutboundSimple creates a new directOutbound with the given mode, without binding to a specific device. Works on all platforms.

func NewDoHResolver

func NewDoHResolver(host string, timeout time.Duration, sni string, insecure bool, next PluggableOutbound) PluggableOutbound

func NewHTTPOutbound

func NewHTTPOutbound(proxyURL string, insecure bool) (PluggableOutbound, error)

func NewSOCKS5Outbound

func NewSOCKS5Outbound(addr, username, password string) PluggableOutbound

func NewStandardResolverTCP

func NewStandardResolverTCP(addr string, timeout time.Duration, next PluggableOutbound) PluggableOutbound

func NewStandardResolverTLS

func NewStandardResolverTLS(addr string, timeout time.Duration, sni string, insecure bool, next PluggableOutbound) PluggableOutbound

func NewStandardResolverUDP

func NewStandardResolverUDP(addr string, timeout time.Duration, next PluggableOutbound) PluggableOutbound

func NewSystemResolver

func NewSystemResolver(next PluggableOutbound) PluggableOutbound

type PluggableOutboundAdapter

type PluggableOutboundAdapter struct {
	PluggableOutbound
}

func (*PluggableOutboundAdapter) TCP

func (a *PluggableOutboundAdapter) TCP(reqAddr string) (net.Conn, error)

func (*PluggableOutboundAdapter) UDP

func (a *PluggableOutboundAdapter) UDP(reqAddr string) (server.UDPConn, error)

type ResolveInfo

type ResolveInfo struct {
	IPv4 net.IP
	IPv6 net.IP
	Err  error
}

ResolveInfo contains the resolved IP addresses from the resolver, and any error that occurred during the resolution. Note that there could be no error but also no resolved IP addresses, or there could be an error but also some resolved IP addresses. It's up to the actual outbound implementation to decide how to handle these cases.

type UDPConn

type UDPConn interface {
	ReadFrom(b []byte) (int, *AddrEx, error)
	WriteTo(b []byte, addr *AddrEx) (int, error)
	Close() error
}

Directories

Path Synopsis
acl

Jump to

Keyboard shortcuts

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