Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Destination(ctx context.Context, cfg DestinationConfig) (*Destination, error)
- func (c *Client) DestinationHTTP(ctx context.Context, cfg DestinationConfig, handler http.Handler) error
- func (c *Client) DestinationHTTPProxy(ctx context.Context, cfg DestinationConfig, dstUrl *url.URL) error
- func (c *Client) DestinationHTTPSProxy(ctx context.Context, cfg DestinationConfig, dstUrl *url.URL, ...) error
- func (c *Client) DestinationTCP(ctx context.Context, cfg DestinationConfig, addr string) error
- func (c *Client) DestinationTLS(ctx context.Context, cfg DestinationConfig, addr string, cas *x509.CertPool) error
- func (c *Client) Destinations() []string
- func (c *Client) GetDestination(name string) (*Destination, error)
- func (c *Client) GetSource(name string) (*Source, error)
- func (c *Client) Source(ctx context.Context, cfg SourceConfig) (*Source, error)
- func (c *Client) SourceHTTP(ctx context.Context, cfg SourceConfig, srcURL *url.URL) error
- func (c *Client) SourceHTTPS(ctx context.Context, cfg SourceConfig, srcURL *url.URL, cert tls.Certificate) error
- func (c *Client) SourceTCP(ctx context.Context, cfg SourceConfig, addr string) error
- func (c *Client) SourceTLS(ctx context.Context, cfg SourceConfig, addr string, cert tls.Certificate) error
- func (c *Client) Sources() []string
- func (c *Client) Status(ctx context.Context) (ClientStatus, error)
- type ClientStatus
- type Destination
- func (d *Destination) Accept() (net.Conn, error)
- func (d *Destination) AcceptContext(ctx context.Context) (net.Conn, error)
- func (d *Destination) Addr() net.Addr
- func (d *Destination) Close() error
- func (d *Destination) Config() DestinationConfig
- func (d *Destination) Context() context.Context
- func (d *Destination) Status() (DestinationStatus, error)
- type DestinationConfig
- func (cfg DestinationConfig) WithDialTimeout(timeout time.Duration) DestinationConfig
- func (cfg DestinationConfig) WithProxy(proxy model.ProxyVersion) DestinationConfig
- func (cfg DestinationConfig) WithRelayEncryptions(schemes ...model.EncryptionScheme) DestinationConfig
- func (cfg DestinationConfig) WithRoute(route model.RouteOption) DestinationConfig
- type DestinationStatus
- type HTTPDestination
- type HTTPSource
- type Option
- func ControlAddress(address string) Option
- func ControlCAs(cas *x509.CertPool) Option
- func ControlCAsFile(certFile string) Option
- func DirectAddress(address string) Option
- func DirectStatelessResetKey(key *quic.StatelessResetKey) Option
- func DirectStatelessResetKeyFile(path string) Option
- func DirectStatelessResetKeyFromEnv() Option
- func Logger(logger *slog.Logger) Option
- func NatPMPConfig(pmp nat.PMPConfig) Option
- func Token(token string) Option
- func TokenFromEnv() Option
- type Source
- func (s *Source) Close() error
- func (s *Source) Config() SourceConfig
- func (s *Source) Context() context.Context
- func (s *Source) Dial(network, address string) (net.Conn, error)
- func (s *Source) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (s *Source) Status() (SourceStatus, error)
- type SourceConfig
- func (cfg SourceConfig) WithDialTimeout(timeout time.Duration) SourceConfig
- func (cfg SourceConfig) WithLoadBalance(policy model.LoadBalancePolicy, retry model.LoadBalanceRetry, max int) SourceConfig
- func (cfg SourceConfig) WithRelayEncryptions(schemes ...model.EncryptionScheme) SourceConfig
- func (cfg SourceConfig) WithRoute(route model.RouteOption) SourceConfig
- type SourceStatus
- type StatusPeer
- type StatusPeerConnection
- type StatusRelayConnection
- type TCPDestination
- type TCPSource
- type WSSource
Constants ¶
This section is empty.
Variables ¶
var ErrNoActiveDestinations = errors.New("no active destinations")
var ErrNoDialedDestinations = errors.New("no dialed destinations")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func Connect ¶ added in v0.7.0
Connect starts a new client and connects it to the control server. This call blocks until the server is connected or an error is detected. The client can be stopped either by canceling this context or via calling Close. Stopping the client will also stop all active endpoints (destinations/sources) associated with this client
func (*Client) Close ¶ added in v0.7.0
Close closes this client. It disconnects the client and all endpoints (destinations and sources) associated with it.
func (*Client) Destination ¶ added in v0.7.0
func (c *Client) Destination(ctx context.Context, cfg DestinationConfig) (*Destination, error)
Destination starts a new destination with a given configuration. This call blocks until it is successfully announced to the control server. The destination can be closed either via canceling the context or calling its close func.
func (*Client) DestinationHTTP ¶ added in v0.7.0
func (c *Client) DestinationHTTP(ctx context.Context, cfg DestinationConfig, handler http.Handler) error
DestinationHTTP creates a new destination which exposes an HTTP server for a given http.Handler
func (*Client) DestinationHTTPProxy ¶ added in v0.7.0
func (c *Client) DestinationHTTPProxy(ctx context.Context, cfg DestinationConfig, dstUrl *url.URL) error
DestinationHTTPProxy creates a new destination which exposes an HTTP proxy server to another HTTP server
func (*Client) DestinationHTTPSProxy ¶ added in v0.7.0
func (c *Client) DestinationHTTPSProxy(ctx context.Context, cfg DestinationConfig, dstUrl *url.URL, cas *x509.CertPool) error
DestinationHTTPSProxy creates a new destination which exposes an HTTP proxy server to another HTTPS server
func (*Client) DestinationTCP ¶ added in v0.7.0
DestinationTCP creates a new destination which connects to a downstream TCP server
func (*Client) DestinationTLS ¶ added in v0.7.0
func (c *Client) DestinationTLS(ctx context.Context, cfg DestinationConfig, addr string, cas *x509.CertPool) error
DestinationTLS creates a new destination which connects to a downstream TLS server
func (*Client) Destinations ¶ added in v0.7.0
Destinations returns the set of currently active destinations
func (*Client) GetDestination ¶ added in v0.7.0
func (c *Client) GetDestination(name string) (*Destination, error)
GetDestination returns a destination by its name. Returns an error if the destination was not found.
func (*Client) GetSource ¶ added in v0.7.0
GetSource returns a source by its name. Returns an error if the source was not found.
func (*Client) Source ¶ added in v0.7.0
Source starts a new source with a given configuration. This call blocks until it is successfully announced to the control server. The source can be closed either via canceling the context or calling its close func.
func (*Client) SourceHTTP ¶ added in v0.7.0
SourceHTTP creates a new source, and exposes it to local TCP address as an HTTP server
func (*Client) SourceHTTPS ¶ added in v0.7.0
func (c *Client) SourceHTTPS(ctx context.Context, cfg SourceConfig, srcURL *url.URL, cert tls.Certificate) error
SourceHTTPS creates a new source, and exposes it to local TCP address as an HTTPS server
func (*Client) SourceTCP ¶ added in v0.7.0
SourceTCP creates a new source, and exposes it to a local TCP address to accept incoming traffic
func (*Client) SourceTLS ¶ added in v0.7.0
func (c *Client) SourceTLS(ctx context.Context, cfg SourceConfig, addr string, cert tls.Certificate) error
SourceTLS creates a new source, and exposes it to local TCP address as a TLS server
type ClientStatus ¶ added in v0.4.0
type ClientStatus struct {
// Overall status of this client
Status statusc.Status `json:"status"`
// Status of each active destination for this client
Destinations map[model.Endpoint]DestinationStatus `json:"destinations"`
// Status of each active source for this client
Sources map[model.Endpoint]SourceStatus `json:"sources"`
}
type Destination ¶ added in v0.7.0
type Destination struct {
// contains filtered or unexported fields
}
Destination represents an endpoint that accepts connections from remote endpoints It implements net.Listener on top of connet infrastructure
func (*Destination) Accept ¶ added in v0.7.0
func (d *Destination) Accept() (net.Conn, error)
Accept calls Destination.AcceptContext with context.Background
func (*Destination) AcceptContext ¶ added in v0.7.0
AcceptContext waits for a new connection from remote sources. It blocks until a new connection comes it or the destination is closed
func (*Destination) Addr ¶ added in v0.7.0
func (d *Destination) Addr() net.Addr
Addr returns the local address that client listens on
func (*Destination) Close ¶ added in v0.7.0
func (d *Destination) Close() error
Close closes this destination. Any active connections are also closed. Any blocked accept operations will be unblocked and return errors.
func (*Destination) Config ¶ added in v0.7.0
func (d *Destination) Config() DestinationConfig
Config returns the original DestinationConfig used to start this destination
func (*Destination) Context ¶ added in v0.7.0
func (d *Destination) Context() context.Context
Context returns context.Context associated with the lifetime of this destination. Once the destination is closed, this context will be canceled
func (*Destination) Status ¶ added in v0.7.0
func (d *Destination) Status() (DestinationStatus, error)
Status returns the current status of this destination
type DestinationConfig ¶ added in v0.7.0
type DestinationConfig struct {
Endpoint model.Endpoint
Route model.RouteOption
Proxy model.ProxyVersion
RelayEncryptions []model.EncryptionScheme
DialTimeout time.Duration
}
DestinationConfig structure represents destination configuration.
func NewDestinationConfig ¶ added in v0.7.0
func NewDestinationConfig(name string) DestinationConfig
NewDestinationConfig creates a destination config for a given name
func (DestinationConfig) WithDialTimeout ¶ added in v0.10.0
func (cfg DestinationConfig) WithDialTimeout(timeout time.Duration) DestinationConfig
WithDialTimeout sets the dial timeout
func (DestinationConfig) WithProxy ¶ added in v0.10.0
func (cfg DestinationConfig) WithProxy(proxy model.ProxyVersion) DestinationConfig
WithProxy sets the proxy version option for this configuration.
func (DestinationConfig) WithRelayEncryptions ¶ added in v0.10.0
func (cfg DestinationConfig) WithRelayEncryptions(schemes ...model.EncryptionScheme) DestinationConfig
WithRelayEncryptions sets the relay encryptions option for this configuration.
func (DestinationConfig) WithRoute ¶ added in v0.10.0
func (cfg DestinationConfig) WithRoute(route model.RouteOption) DestinationConfig
WithRoute sets the route option for this configuration.
type DestinationStatus ¶ added in v0.10.0
type DestinationStatus struct {
// Overall status of this destination
Status statusc.Status `json:"status"`
// Peer status for this destination
StatusPeer
}
DestinationStatus describes the status of a destination
type HTTPDestination ¶ added in v0.7.0
type HTTPDestination struct {
// contains filtered or unexported fields
}
func NewHTTPDestination ¶ added in v0.7.0
func NewHTTPDestination(dst *Destination, handler http.Handler) *HTTPDestination
func NewHTTPFileDestination ¶ added in v0.7.0
func NewHTTPFileDestination(dst *Destination, root string) *HTTPDestination
func NewHTTPProxyDestination ¶ added in v0.7.0
func NewHTTPProxyDestination(dst *Destination, dstURL *url.URL, cfg *tls.Config, timeout time.Duration) *HTTPDestination
type HTTPSource ¶ added in v0.7.0
type HTTPSource struct {
// contains filtered or unexported fields
}
func NewHTTPSource ¶ added in v0.7.0
type Option ¶ added in v0.10.0
type Option func(cfg *config) error
Option is a functional option to configure the client
func ControlAddress ¶ added in v0.10.0
ControlAddress configures the control server address
func ControlCAs ¶ added in v0.10.0
ControlCAsFile configures the control server CAs. Used in cases where control server is not using PKIX.
func ControlCAsFile ¶ added in v0.10.0
ControlCAsFile reads from a file and configures the control server CAs. Used in cases where control server is not using PKIX.
func DirectAddress ¶ added in v0.10.0
DirectAddress configures the address on which this client will listen from peer connections
func DirectStatelessResetKey ¶ added in v0.10.0
func DirectStatelessResetKey(key *quic.StatelessResetKey) Option
DirectStatelessResetKey configures the stateless reset key for the direct server
func DirectStatelessResetKeyFile ¶ added in v0.10.0
DirectStatelessResetKeyFile reads from a file and configures the stateless reset key for the direct server
func DirectStatelessResetKeyFromEnv ¶ added in v0.10.0
func DirectStatelessResetKeyFromEnv() Option
DirectStatelessResetKeyFromEnv reads stateless reset key file from the env and configures it for the direct server
func NatPMPConfig ¶ added in v0.10.0
NatPMPConfig configures NATPMP behavior
func Token ¶ added in v0.10.0
Token configures which token the client will use to connect to the control server
func TokenFromEnv ¶ added in v0.10.0
func TokenFromEnv() Option
TokenFromEnv reads from $CONNET_TOKEN and configures the client token
type Source ¶ added in v0.7.0
type Source struct {
// contains filtered or unexported fields
}
Source represents an endpoint that can connect to remote destinations. It is compatible with net.Dialer on top of connet infrastructure
func (*Source) Close ¶ added in v0.7.0
Close closes this source. Any active connections are also closed.
func (*Source) Config ¶ added in v0.7.0
func (s *Source) Config() SourceConfig
Config returns the original SourceConfig used to start this source
func (*Source) Context ¶ added in v0.7.0
Context returns context.Context associated with the lifetime of this source. Once the source is closed, this context will be canceled
func (*Source) Dial ¶ added in v0.7.0
Dial calls Source.DialContext with context.Background
func (*Source) DialContext ¶ added in v0.7.0
DialContext dials into any available destination. Both network and address are ignored. Blocks until connection can be established.
func (*Source) Status ¶ added in v0.7.0
func (s *Source) Status() (SourceStatus, error)
Status returns the current status of this source
type SourceConfig ¶ added in v0.7.0
type SourceConfig struct {
Endpoint model.Endpoint
Route model.RouteOption
RelayEncryptions []model.EncryptionScheme
DialTimeout time.Duration
DestinationPolicy model.LoadBalancePolicy
DestinationRetry model.LoadBalanceRetry
DestinationRetryMax int
}
SourceConfig structure represents source configuration.
func NewSourceConfig ¶ added in v0.7.0
func NewSourceConfig(name string) SourceConfig
NewSourceConfig creates a source config for a given name.
func (SourceConfig) WithDialTimeout ¶ added in v0.10.0
func (cfg SourceConfig) WithDialTimeout(timeout time.Duration) SourceConfig
WithDialTimeout sets the dial timeout
func (SourceConfig) WithLoadBalance ¶ added in v0.10.0
func (cfg SourceConfig) WithLoadBalance(policy model.LoadBalancePolicy, retry model.LoadBalanceRetry, max int) SourceConfig
WithLoadBalance sets the load balancing behavior for this source
func (SourceConfig) WithRelayEncryptions ¶ added in v0.10.0
func (cfg SourceConfig) WithRelayEncryptions(schemes ...model.EncryptionScheme) SourceConfig
WithRelayEncryptions sets the relay encryptions option for this configuration.
func (SourceConfig) WithRoute ¶ added in v0.10.0
func (cfg SourceConfig) WithRoute(route model.RouteOption) SourceConfig
WithRoute sets the route option for this configuration.
type SourceStatus ¶ added in v0.10.0
type SourceStatus struct {
// Overall status of this source
Status statusc.Status `json:"status"`
// Peer status for this source
StatusPeer
}
SourceStatus describes the status of a source
type StatusPeer ¶ added in v0.10.0
type StatusPeer struct {
// Status of each relay this peer is connected to
Relays []StatusRelayConnection `json:"relays"`
// Status of each peer this peer is connected to
Peers []StatusPeerConnection `json:"peers"`
}
type StatusPeerConnection ¶ added in v0.10.0
type StatusRelayConnection ¶ added in v0.10.0
type TCPDestination ¶ added in v0.7.0
type TCPDestination struct {
// contains filtered or unexported fields
}
func NewTCPDestination ¶ added in v0.7.0
func NewTCPDestination(dst *Destination, addr string, timeout time.Duration, logger *slog.Logger) *TCPDestination
func NewTLSDestination ¶ added in v0.7.0
func NewTLSDestination(dst *Destination, addr string, cfg *tls.Config, timeout time.Duration, logger *slog.Logger) *TCPDestination
type TCPSource ¶ added in v0.7.0
type TCPSource struct {
// contains filtered or unexported fields
}
func NewTCPSource ¶ added in v0.7.0
func NewTLSSource ¶ added in v0.7.0
type WSSource ¶ added in v0.7.0
type WSSource struct {
// contains filtered or unexported fields
}