controlsvc

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitReload

func InitReload(cPath string, fParseAndRun func([]string) error) error

InitReload initializes objects required before reload commands are issued.

Types

type ConnectCommand added in v1.4.2

type ConnectCommand struct {
	// contains filtered or unexported fields
}

func (*ConnectCommand) ControlFunc added in v1.4.2

func (c *ConnectCommand) ControlFunc(_ context.Context, nc NetceptorForControlCommand, cfo ControlFuncOperations) (map[string]interface{}, error)

type ConnectCommandType added in v1.4.2

type ConnectCommandType struct{}

func (*ConnectCommandType) InitFromJSON added in v1.4.2

func (t *ConnectCommandType) InitFromJSON(config map[string]interface{}) (ControlCommand, error)

func (*ConnectCommandType) InitFromString added in v1.4.2

func (t *ConnectCommandType) InitFromString(params string) (ControlCommand, error)

type ControlCommand

type ControlCommand interface {
	ControlFunc(context.Context, NetceptorForControlCommand, ControlFuncOperations) (map[string]interface{}, error)
}

ControlCommand is an instance of a command that is being run from the control service.

type ControlCommandType

type ControlCommandType interface {
	InitFromString(string) (ControlCommand, error)
	InitFromJSON(map[string]interface{}) (ControlCommand, error)
}

ControlCommandType is a type of command that can be run from the control service.

type ControlFuncOperations

type ControlFuncOperations interface {
	BridgeConn(message string, bc io.ReadWriteCloser, bcName string, logger *logger.ReceptorLogger, utils Utiler) error
	ReadFromConn(message string, out io.Writer, io Copier) error
	WriteToConn(message string, in chan []byte) error
	Close() error
	RemoteAddr() net.Addr
}

ControlFuncOperations provides callbacks for control services to take actions.

type Copier added in v1.4.2

type Copier interface {
	Copy(dst io.Writer, src io.Reader) (written int64, err error)
}

type Net added in v1.4.2

type Net struct{}

func (*Net) Listen added in v1.4.2

func (n *Net) Listen(network string, address string) (net.Listener, error)

type NetceptorForControlCommand added in v1.4.2

type NetceptorForControlCommand interface {
	GetClientTLSConfig(name string, expectedHostName string, expectedHostNameType netceptor.ExpectedHostnameType) (*tls.Config, error)
	Dial(node string, service string, tlscfg *tls.Config) (*netceptor.Conn, error)
	Ping(ctx context.Context, target string, hopsToLive byte) (time.Duration, string, error)
	MaxForwardingHops() byte
	Status() netceptor.Status
	Traceroute(ctx context.Context, target string) <-chan *netceptor.TracerouteResult
	NodeID() string
	GetLogger() *logger.ReceptorLogger
	CancelBackends()
}

type NetceptorForControlsvc added in v1.4.2

type NetceptorForControlsvc interface {
	ListenAndAdvertise(service string, tlscfg *tls.Config, tags map[string]string) (*netceptor.Listener, error)
	NetceptorForControlCommand
}

type Neter added in v1.4.2

type Neter interface {
	Listen(network string, address string) (net.Listener, error)
}

type PingCommand added in v1.4.2

type PingCommand struct {
	// contains filtered or unexported fields
}

func (*PingCommand) ControlFunc added in v1.4.2

func (c *PingCommand) ControlFunc(ctx context.Context, nc NetceptorForControlCommand, _ ControlFuncOperations) (map[string]interface{}, error)

type PingCommandType added in v1.4.2

type PingCommandType struct{}

func (*PingCommandType) InitFromJSON added in v1.4.2

func (t *PingCommandType) InitFromJSON(config map[string]interface{}) (ControlCommand, error)

func (*PingCommandType) InitFromString added in v1.4.2

func (t *PingCommandType) InitFromString(params string) (ControlCommand, error)

type ReloadCommand added in v1.4.2

type ReloadCommand struct{}

func (*ReloadCommand) ControlFunc added in v1.4.2

func (c *ReloadCommand) ControlFunc(_ context.Context, nc NetceptorForControlCommand, _ ControlFuncOperations) (map[string]interface{}, error)

type ReloadCommandType added in v1.4.2

type ReloadCommandType struct{}

func (*ReloadCommandType) InitFromJSON added in v1.4.2

func (t *ReloadCommandType) InitFromJSON(_ map[string]interface{}) (ControlCommand, error)

func (*ReloadCommandType) InitFromString added in v1.4.2

func (t *ReloadCommandType) InitFromString(_ string) (ControlCommand, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an instance of a control service.

var MainInstance *Server

MainInstance is the global instance of the control service instantiated by the command-line main() function.

func New

func New(stdServices bool, nc NetceptorForControlsvc) *Server

New returns a new instance of a control service.

func (*Server) AddControlFunc

func (s *Server) AddControlFunc(name string, cType ControlCommandType) error

AddControlFunc registers a function that can be used from a control socket.

func (*Server) ConnectionListener added in v1.4.2

func (s *Server) ConnectionListener(ctx context.Context, listener net.Listener)

func (*Server) RunControlSession

func (s *Server) RunControlSession(conn net.Conn)

RunControlSession runs the server protocol on the given connection.

func (*Server) RunControlSvc

func (s *Server) RunControlSvc(ctx context.Context, service string, tlscfg *tls.Config,
	unixSocket string, unixSocketPermissions os.FileMode, tcpListen string, tcptls *tls.Config,
) error

RunControlSvc runs the main accept loop of the control service.

func (*Server) SetServerNet added in v1.4.2

func (s *Server) SetServerNet(n Neter)

func (*Server) SetServerTLS added in v1.4.2

func (s *Server) SetServerTLS(t Tlser)

func (*Server) SetServerUtils added in v1.4.2

func (s *Server) SetServerUtils(u Utiler)

func (*Server) SetupConnection added in v1.4.2

func (s *Server) SetupConnection(conn net.Conn)

type SockControl added in v1.4.2

type SockControl struct {
	// contains filtered or unexported fields
}

SockControl implements the ControlFuncOperations interface that is passed back to control functions.

func NewSockControl added in v1.4.2

func NewSockControl(conn net.Conn) *SockControl

func (*SockControl) BridgeConn added in v1.4.2

func (s *SockControl) BridgeConn(message string, bc io.ReadWriteCloser, bcName string, logger *logger.ReceptorLogger, utils Utiler) error

BridgeConn bridges the socket to another socket.

func (*SockControl) Close added in v1.4.2

func (s *SockControl) Close() error

func (*SockControl) ReadFromConn added in v1.4.2

func (s *SockControl) ReadFromConn(message string, out io.Writer, io Copier) error

ReadFromConn copies from the socket to an io.Writer, until EOF.

func (*SockControl) RemoteAddr added in v1.4.2

func (s *SockControl) RemoteAddr() net.Addr

func (*SockControl) WriteMessage added in v1.4.2

func (s *SockControl) WriteMessage(message string) error

WriteMessage attempts to write a message to a connection.

func (*SockControl) WriteToConn added in v1.4.2

func (s *SockControl) WriteToConn(message string, in chan []byte) error

WriteToConn writes an initial string, and then messages to a channel, to the connection.

type SocketConnIO added in v1.4.2

type SocketConnIO struct{}

func (*SocketConnIO) Copy added in v1.4.2

func (s *SocketConnIO) Copy(dst io.Writer, src io.Reader) (written int64, err error)

type StatusCommand added in v1.4.2

type StatusCommand struct {
	// contains filtered or unexported fields
}

func (*StatusCommand) ControlFunc added in v1.4.2

func (c *StatusCommand) ControlFunc(_ context.Context, nc NetceptorForControlCommand, _ ControlFuncOperations) (map[string]interface{}, error)

type StatusCommandType added in v1.4.2

type StatusCommandType struct{}

func (*StatusCommandType) InitFromJSON added in v1.4.2

func (t *StatusCommandType) InitFromJSON(config map[string]interface{}) (ControlCommand, error)

func (*StatusCommandType) InitFromString added in v1.4.2

func (t *StatusCommandType) InitFromString(params string) (ControlCommand, error)

type TLS added in v1.4.2

type TLS struct{}

func (*TLS) NewListener added in v1.4.2

func (t *TLS) NewListener(inner net.Listener, config *tls.Config) net.Listener

type Tlser added in v1.4.2

type Tlser interface {
	NewListener(inner net.Listener, config *tls.Config) net.Listener
}

type TracerouteCommand added in v1.4.2

type TracerouteCommand struct {
	// contains filtered or unexported fields
}

func (*TracerouteCommand) ControlFunc added in v1.4.2

func (c *TracerouteCommand) ControlFunc(ctx context.Context, nc NetceptorForControlCommand, _ ControlFuncOperations) (map[string]interface{}, error)

type TracerouteCommandType added in v1.4.2

type TracerouteCommandType struct{}

func (*TracerouteCommandType) InitFromJSON added in v1.4.2

func (t *TracerouteCommandType) InitFromJSON(config map[string]interface{}) (ControlCommand, error)

func (*TracerouteCommandType) InitFromString added in v1.4.2

func (t *TracerouteCommandType) InitFromString(params string) (ControlCommand, error)

type Util added in v1.4.2

type Util struct{}

func (*Util) BridgeConns added in v1.4.2

func (u *Util) BridgeConns(c1 io.ReadWriteCloser, c1Name string, c2 io.ReadWriteCloser, c2Name string, logger *logger.ReceptorLogger)

func (*Util) UnixSocketListen added in v1.4.2

func (u *Util) UnixSocketListen(filename string, permissions fs.FileMode) (net.Listener, *utils.FLock, error)

type Utiler added in v1.4.2

type Utiler interface {
	BridgeConns(c1 io.ReadWriteCloser, c1Name string, c2 io.ReadWriteCloser, c2Name string, logger *logger.ReceptorLogger)
	UnixSocketListen(filename string, permissions fs.FileMode) (net.Listener, *utils.FLock, error)
}

Directories

Path Synopsis
Package mock_controlsvc is a generated GoMock package.
Package mock_controlsvc is a generated GoMock package.

Jump to

Keyboard shortcuts

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