server

package
v0.0.0-...-3ff2ba2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 26 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRemoteError

func IsRemoteError(err error) bool

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.

func (*Server) Start

func (s *Server) Start(logger logging.TraceLogger) error

Start starts the wrapper and its underlying Service. It sets up the tcp listener for client connections with tls wrappers, and sets up the grpc service and enables tls.

func (*Server) Stop

func (s *Server) Stop(logger logging.TraceLogger) error

Stop stops the service wrapper.

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.

func (*Service) Start

func (s *Service) Start(logger logging.TraceLogger) error

Start start the service by starting the background workers. The implementation does not deal with the grpc server. Callers would need to register it before calling Start.

func (*Service) Stop

func (s *Service) Stop(logger logging.TraceLogger) error

Stop stops all background processes for the service but does not terminate the already established tcp connections.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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