Documentation
¶
Index ¶
- Constants
- Variables
- func DestinationIPAllowed(ip net.IP) error
- func NewAccountReader(reader io.Reader, acc *atomic.Int64) io.Reader
- func NewAccountWriter(writer io.Writer, acc *atomic.Int64) io.Writer
- func NewBandwidthLimitReader(reader io.Reader, limiter *atomic.Int64) io.Reader
- func NewBandwidthLimitWriter(writer io.Writer, limiter *atomic.Int64) io.Writer
- type AccountReader
- type AccountWriter
- type BandwidthLimitReader
- type BandwidthLimitWriter
- type ConnectionLimitError
- type DNSLookupError
- type DNSTester
- type IpVersionError
- type NetworkPolicyError
- type PeerAddr
- type ProxyAttribute
- type ProxyAuthenticator
- type ProxyConnCtl
- type ProxyConnectionPool
- func (pool *ProxyConnectionPool) Add() (*ProxyConnCtl, error)
- func (pool *ProxyConnectionPool) Bandwidth() (rxBytes, txBytes int)
- func (pool *ProxyConnectionPool) CloseConnections()
- func (pool *ProxyConnectionPool) ConnectionLimit() int
- func (pool *ProxyConnectionPool) Rebalance()
- func (pool *ProxyConnectionPool) SetBandwidth(rxBytes, txBytes int)
- func (pool *ProxyConnectionPool) SetConnectionLimit(limit int) error
- func (pool *ProxyConnectionPool) WithConnection(conn net.Conn) (net.Conn, error)
- type ProxyCredentialsError
- type ProxyDNSResolver
- func (dns *ProxyDNSResolver) LookupIpNetwork(ctx context.Context, ipnetwork, host string) (hostIP net.IP, err error)
- func (dns *ProxyDNSResolver) ResolveDestination(ctx context.Context, ipnetwork, addr string) (string, error)
- func (dns *ProxyDNSResolver) Resolver() *net.Resolver
- func (dns *ProxyDNSResolver) ServerName() string
- type ProxyDialer
- type ProxyService
- type ProxySession
- type ProxySessionAttributes
- type ServiceManager
Constants ¶
const BandwidthLimitMax = 1_250_000_000
Sets a maximal throttlable bandwidth limit at around 10 GBit/s; Values over this limit should be treated as no limit at all
const DefaultConnectionLimit = math.MaxUint8
const DefaultDnsTestResultTTL = time.Minute
const DefaultDnsTestTimeout = 5 * time.Second
const DefaultDnsTestWarnTimeout = 2 * time.Second
const DefaultDnsTimeout = 15 * time.Second
const MaxConnectionLimit = math.MaxUint16
Variables ¶
var DefaultDnsProbeNames = []string{
"one.one.one.one",
"google.com",
"ripe.net",
"icann.org",
}
var ErrConnectionCtlClosed = errors.New("conn ctl closed")
Functions ¶
func DestinationIPAllowed ¶
func NewBandwidthLimitReader ¶
Types ¶
type AccountReader ¶
AccountReader is a wrapper on top of a normal reader that counts total data volume in realtime using an accumulator (atomic int)
type AccountWriter ¶
AccountWriter is a wrapper on top of a normal writer that counts total data volume in realtime using an accumulator (atomic int)
type BandwidthLimitReader ¶
BandwidthLimitReader implements a simple reader wrapper that allows for the bandwidth to be externally controlled It is quite a lot more quirky when it comes to precision than the writer, therefore the latter should be preferred when possible
type BandwidthLimitWriter ¶
BandwidthLimitWriter implements a simple writer wrapper that allows for the bandwidth to be externally controlled
type ConnectionLimitError ¶
func (*ConnectionLimitError) Error ¶
func (err *ConnectionLimitError) Error() string
type DNSLookupError ¶
type DNSLookupError struct {
Query string
}
func (*DNSLookupError) Error ¶
func (err *DNSLookupError) Error() string
type DNSTester ¶
type DNSTester struct {
ResultTTL time.Duration
Dialer net.Dialer
Control func(server string) error
// contains filtered or unexported fields
}
func (*DNSTester) LookupTestRecords ¶
type IpVersionError ¶
type IpVersionError struct {
RemoteNet, LocalNet string
}
func (*IpVersionError) Error ¶
func (err *IpVersionError) Error() string
type NetworkPolicyError ¶
type NetworkPolicyError struct {
Message string
}
func (*NetworkPolicyError) Error ¶
func (err *NetworkPolicyError) Error() string
type ProxyAttribute ¶
type ProxyAttribute interface {
EqualAttribute(attr ProxyAttribute) bool
Destroy()
}
type ProxyAuthenticator ¶
type ProxyAuthenticator interface {
// Tries to authorize a user using their name and password.
// MUST always return either a non-nil session or an error.
// Use CredentialsError to indicate non-logic errors
AuthenticateWithPassword(ctx context.Context, proxyHost net.Addr, clientIP net.IP, username, password string) (*ProxySession, error)
}
type ProxyConnCtl ¶
type ProxyConnCtl struct {
TrafficRx atomic.Int64
TrafficTx atomic.Int64
BandwidthRx atomic.Int64
BandwidthTx atomic.Int64
// contains filtered or unexported fields
}
func (*ProxyConnCtl) Close ¶
func (ctl *ProxyConnCtl) Close() (err error)
func (*ProxyConnCtl) SetBandwidth ¶
func (pool *ProxyConnCtl) SetBandwidth(rxBytes, txBytes int)
func (*ProxyConnCtl) WithConnection ¶
type ProxyConnectionPool ¶
type ProxyConnectionPool struct {
TrafficRx atomic.Int64
TrafficTx atomic.Int64
// contains filtered or unexported fields
}
func (*ProxyConnectionPool) Add ¶
func (pool *ProxyConnectionPool) Add() (*ProxyConnCtl, error)
func (*ProxyConnectionPool) Bandwidth ¶
func (pool *ProxyConnectionPool) Bandwidth() (rxBytes, txBytes int)
func (*ProxyConnectionPool) CloseConnections ¶
func (pool *ProxyConnectionPool) CloseConnections()
func (*ProxyConnectionPool) ConnectionLimit ¶
func (pool *ProxyConnectionPool) ConnectionLimit() int
func (*ProxyConnectionPool) Rebalance ¶
func (pool *ProxyConnectionPool) Rebalance()
func (*ProxyConnectionPool) SetBandwidth ¶
func (pool *ProxyConnectionPool) SetBandwidth(rxBytes, txBytes int)
func (*ProxyConnectionPool) SetConnectionLimit ¶
func (pool *ProxyConnectionPool) SetConnectionLimit(limit int) error
func (*ProxyConnectionPool) WithConnection ¶
type ProxyCredentialsError ¶
func (*ProxyCredentialsError) Error ¶
func (err *ProxyCredentialsError) Error() string
type ProxyDNSResolver ¶
func (*ProxyDNSResolver) LookupIpNetwork ¶
func (*ProxyDNSResolver) ResolveDestination ¶
func (*ProxyDNSResolver) Resolver ¶
func (dns *ProxyDNSResolver) Resolver() *net.Resolver
func (*ProxyDNSResolver) ServerName ¶
func (dns *ProxyDNSResolver) ServerName() string
type ProxyDialer ¶
type ProxyDialer struct {
OutboundAddr *PeerAddr
}
ProxyDialer simplifies dialing proxy destinations
func (*ProxyDialer) DialContext ¶
type ProxyService ¶
type ProxySession ¶
type ProxySession struct {
PeerID string
PeerEnabled bool
Dialer ProxyDialer
DNS ProxyDNSResolver
Attributes ProxySessionAttributes
Pool ProxyConnectionPool
}
func (*ProxySession) DialDestinationContext ¶
func (sess *ProxySession) DialDestinationContext(ctx context.Context, network, address string) (net.Conn, error)
Dials an address while checking that a peer is allowed to access the remote and wrapping resulting connection in a (proxyConnection)
func (*ProxySession) Reset ¶
func (sess *ProxySession) Reset()
type ProxySessionAttributes ¶
type ProxySessionAttributes struct {
// contains filtered or unexported fields
}
Wraps the underlying sync map to prevent it from getting cleared without being properly closed
func (*ProxySessionAttributes) Reset ¶
func (attrs *ProxySessionAttributes) Reset()
func (*ProxySessionAttributes) WithValue ¶
func (attrs *ProxySessionAttributes) WithValue(key any, newAttr ProxyAttribute) (attr ProxyAttribute, replaced bool)