Documentation ¶
Overview ¶
Copyright (c) technicianted. All rights reserved. Licensed under the MIT License.
Copyright (c) technicianted. All rights reserved. Licensed under the MIT License.
Copyright (c) technicianted. All rights reserved. Licensed under the MIT License.
Copyright (c) technicianted. All rights reserved. Licensed under the MIT License.
Index ¶
- func IsRemoteError(err error) bool
- func WithWaitForHost(w bool) types.DialOption
- type Server
- type ServerOptions
- type Service
- func (s *Service) DialContext(ctx context.Context, network, address string, logger logging.TraceLogger, ...) (net.Conn, error)
- func (s *Service) Register(stream protov1.Whip_RegisterServer) error
- func (s *Service) Start(logger logging.TraceLogger) error
- func (s *Service) Stop(logger logging.TraceLogger) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRemoteError ¶
func WithWaitForHost ¶
func WithWaitForHost(w bool) types.DialOption
WithWaitForHost returns a dial option that would block DialContext call until the target host is available or context is cancelled. Default is false which means immediately fail if the host has not already registered.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a convenient wrapper around Service to provide functionalities such as tls certificate loading, tcp dialer and listener creation and its tls wrappers. Server implements types.Dialer so it can be used as a drop-in for Service.
func NewServer ¶
func NewServer(options ServerOptions) *Server
NewServer creates a new Server wrapper with options.
func (*Server) DialContext ¶
func (s *Server) DialContext(ctx context.Context, network, address string, logger logging.TraceLogger, opts ...types.DialOption) (net.Conn, error)
DialContext passes the call to the underlying Service DialContext.
type ServerOptions ¶
type ServerOptions struct { // ExternalTCPHost is the fqdn or ip address of this whip service instance // that can be externally reached by remote clients for tcp connections. ExternalTCPHost string // External TCPPort is the port number available externally to clients to connect // remote tcp connections. ExternalTCPPort int // TCPListenPort is the port to listen on for incoming remote tcp connections. TCPListenPort int // GRPCListenPort is the port to listen on for incoming grpc control connections. GRPCListenPort int // TLS enables or disables tls for both grpc and reverse tcp connections. TLS bool // TLSKeyPath is the path to the tls pem key for the service. TLSKeyPath string // TLSCertPath is the path to the tls pem certificate for the service. TLSCertPath string // TLSCACertPath is the path to the tls pem ca certificate to be used to verify remote clients. TLSCACertPath string }
ServerOptions is a set of whip service options.
type Service ¶
type Service struct { protov1.WhipServer // contains filtered or unexported fields }
Service implements the whip control grpc service and types.DialContext for users to request reverse tcp connections. Although the service does not deal with setting up tls, it does perform tls verification if the incoming Register grpc is over tls. Verification is based on the hostname.domain in the incoming Register message. It needs to match the certificate DNS entries or SAN. Wild card certificates can be used.
In the background, the service continuously pings remove clients over the control channel and emits relevant latency metrics.
func NewService ¶
func NewService(externalTCPHost string, externalTCPPort int, tcpListner net.Listener, logger logging.TraceLogger) (*Service, error)
NewService creates a new service instance. For remote clients, externalTCPHost is the host that remote clients can use to reach the service with externalTCPPort. It uses tcpListener to listen for remote tcp connection requests.
func (*Service) DialContext ¶
func (s *Service) DialContext(ctx context.Context, network, address string, logger logging.TraceLogger, opts ...types.DialOption) (net.Conn, error)
DialContext implements types.Dialer.
func (*Service) Register ¶
func (s *Service) Register(stream protov1.Whip_RegisterServer) error
Register implements the grpc service.