Documentation
¶
Index ¶
- Constants
- Variables
- func AddrAssigned(addr net.IP) (bool, error)
- func DurationTCIO(bandwidth int, size int) time.Duration
- func GetAddrPort(addr net.Addr) (net.IP, int)
- func IsLocalAddress(addr string) bool
- func NewDnsResolver(addr string) (*net.Resolver, error)
- func ParseFramedIP(addr string) (net.IP, error)
- func ProbeDnsServer(addr string) error
- func ProxyBridge(ctl *PeerConnection, clientConn net.Conn, remoteConn net.Conn) (err error)
- func ReadByte(reader io.Reader) (byte, error)
- func ReadN(reader io.Reader, n int) ([]byte, error)
- func RedistributePeerBandwidth(conns []*PeerConnection, bandwidth PeerBandwidth)
- func ServiceBindAddr(addr string, service ProxyProto) (string, error)
- func SpliceConn(ctx context.Context, dst io.Writer, src io.Reader, bw BandwidthFn, ...) error
- func SplitAddrNet(addr string) (string, string, bool)
- func TcpDialAddr(addr net.IP) net.Addr
- func WaitTCIO(bandwidth int, size int, started time.Time)
- type AccountFn
- type AddrContainer
- type BandwidthFn
- type CredentialsError
- type DnsProvider
- type Peer
- type PeerBandwidth
- type PeerConnection
- type PeerDelta
- type PeerOptions
- type ProxyProto
- type RateLimitError
- type RateLimiter
- type RateLimiterOptions
- type RlCounter
- type ServerToken
- type ServiceOptions
- type Slot
- type SlotInfo
- type SlotOptions
- type SlotService
- type UserPassword
Constants ¶
View Source
const ( ProxyProtoSocks = ProxyProto("socks") ProxyProtoHttp = ProxyProto("http") )
Variables ¶
View Source
var DefaultRatelimiter = RateLimiterOptions{ Quota: 50, Window: 5 * time.Minute, }
View Source
var ErrSlotOptionsIncompatible = errors.New("slot options incompatible")
View Source
var ErrTooManyConnections = errors.New("too many connections")
View Source
var ErrUnsupportedProto = errors.New("unsupported protocol")
Functions ¶
func DurationTCIO ¶
Returns the amount of time it's expected for an IO operation to take. Bandwidth in bps, size in bytes
func IsLocalAddress ¶
func ProbeDnsServer ¶
func ProxyBridge ¶
Bridges two connections together to create a proxy
func RedistributePeerBandwidth ¶
func RedistributePeerBandwidth(conns []*PeerConnection, bandwidth PeerBandwidth)
func ServiceBindAddr ¶
func ServiceBindAddr(addr string, service ProxyProto) (string, error)
Types ¶
type AddrContainer ¶
type BandwidthFn ¶
Implementations of BandwidthFn must return the data volume in bytes that a connection may copy in one second at most
type CredentialsError ¶
type CredentialsError struct {
Username *string
}
func (*CredentialsError) Error ¶
func (err *CredentialsError) Error() string
type DnsProvider ¶
type Peer ¶
type Peer struct {
PeerOptions
BaseContext context.Context
Dialer net.Dialer
HttpClient *http.Client
DeltaRx atomic.Uint64
DeltaTx atomic.Uint64
// contains filtered or unexported fields
}
func (*Peer) CloseConnections ¶
func (peer *Peer) CloseConnections()
func (*Peer) Connection ¶
func (peer *Peer) Connection() (*PeerConnection, error)
func (*Peer) ConnectionList ¶
func (peer *Peer) ConnectionList() []*PeerConnection
type PeerBandwidth ¶
type PeerConnection ¶
type PeerConnection struct {
// contains filtered or unexported fields
}
func (*PeerConnection) AccountRx ¶
func (conn *PeerConnection) AccountRx(delta int)
func (*PeerConnection) AccountTx ¶
func (conn *PeerConnection) AccountTx(delta int)
func (*PeerConnection) BandwidthRx ¶
func (conn *PeerConnection) BandwidthRx() (int, bool)
func (*PeerConnection) BandwidthTx ¶
func (conn *PeerConnection) BandwidthTx() (int, bool)
func (*PeerConnection) Close ¶
func (conn *PeerConnection) Close()
func (*PeerConnection) Context ¶
func (conn *PeerConnection) Context() context.Context
type PeerOptions ¶
type PeerOptions struct {
// unique peer ID used for accounting identification
ID uuid.UUID `json:"id"`
// optional (not so) paasword auth data
PasswordAuth *UserPassword `json:"password_auth"`
// maximal number of open connections
MaxConnections uint `json:"max_connections"`
// connection speed limits
Bandwidth PeerBandwidth `json:"bandwidth"`
// public ip to use for outbound connections, optional
FramedIP string `json:"framed_ip,omitempty"`
// used to disable a peer without completely removing it
Disabled bool `json:"disabled"`
}
func (*PeerOptions) CmpCredentials ¶
func (peer *PeerOptions) CmpCredentials(other PeerOptions) bool
func (*PeerOptions) DisplayName ¶
func (peer *PeerOptions) DisplayName() string
type ProxyProto ¶
type ProxyProto string
func (ProxyProto) Valid ¶
func (val ProxyProto) Valid() bool
type RateLimitError ¶
func (*RateLimitError) Error ¶
func (val *RateLimitError) Error() string
type RateLimiter ¶
type RateLimiter struct {
RateLimiterOptions
// contains filtered or unexported fields
}
func (*RateLimiter) Get ¶
func (rl *RateLimiter) Get(key string) *RlCounter
type RateLimiterOptions ¶
type ServerToken ¶
func NewServerToken ¶
func NewServerToken() (*ServerToken, error)
func ParseServerToken ¶
func ParseServerToken(val string) (*ServerToken, error)
func (*ServerToken) String ¶
func (token *ServerToken) String() string
type ServiceOptions ¶
type ServiceOptions struct {
SlotOptions
Peers []PeerOptions `json:"peers"`
}
type Slot ¶
type Slot struct {
SlotOptions
BaseContext context.Context
Rl *RateLimiter
DNS DnsProvider
// contains filtered or unexported fields
}
func (*Slot) ClosePeerConnections ¶
func (slot *Slot) ClosePeerConnections()
func (*Slot) LookupWithPassword ¶
func (*Slot) SetPeers ¶
func (slot *Slot) SetPeers(entries []PeerOptions)
type SlotInfo ¶
type SlotInfo struct {
Up bool `json:"up"`
Proto ProxyProto `json:"proto"`
BindAddr string `json:"bind_addr"`
RegisteredPeers int `json:"registered_peers"`
Error string `json:"error,omitempty"`
}
type SlotOptions ¶
type SlotOptions struct {
Proto ProxyProto `json:"proto"`
BindAddr string `json:"bind_addr"`
}
func (*SlotOptions) Compatible ¶ added in v0.1.2
func (opts *SlotOptions) Compatible(other *SlotOptions) bool
type SlotService ¶
type SlotService interface {
Info() SlotInfo
Deltas() []PeerDelta
SetPeers(entries []PeerOptions)
SetOptions(opts SlotOptions) error
Close() error
}
type UserPassword ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.