server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ServerMaxMessageSize - Server-side max GRPC message size.
	ServerMaxMessageSize = 2*gb - 1
)

Variables

This section is empty.

Functions

func BufferingOptions

func BufferingOptions() (options []grpc.ServerOption)

BufferingOptions returns a list of server options with max send/receive message size, which value is that of the ServerMaxMessageSize variable (2GB).

func LogMiddlewareOptions

func LogMiddlewareOptions(serv *server.Server) ([]grpc.ServerOption, error)

LogMiddlewareOptions is a set of logging middleware options preconfigured to perform the following tasks: - Log all connections/disconnections to/from the teamserver listener. - Log all raw client requests into a teamserver audit file (see server.AuditLog()).

func NewClientFrom

func NewClientFrom(server *Teamserver, opts ...grpc.DialOption) *clientConn.Teamclient

NewClientFrom requires an existing grpc Teamserver to create an in-memory connection bound to both the teamserver and the teamclient backends. It returns a teamclient meant to be ran in memory, with TLS credentials disabled.

func TLSAuthMiddlewareOptions

func TLSAuthMiddlewareOptions(s *server.Server) ([]grpc.ServerOption, error)

TLSAuthMiddlewareOptions is a set of transport security options which will use the preconfigured teamserver TLS (credentials) configuration to authenticate incoming client connections. The authentication is Mutual TLS, used because all teamclients will connect with a known TLS credentials set.

Types

type ContextKey

type ContextKey int

ContextKey represents a gRPC context metadata key.

const (
	Transport ContextKey = iota
	User
)

type Teamserver

type Teamserver struct {
	*teamserver.Server
	// contains filtered or unexported fields
}

Teamserver is a simple example gRPC teamserver listener and server backend. This server can handle both remote and local (in-memory) connections, provided that it is being created with the correct grpc.Server options.

This teamserver embeds a team/server.Server core driver and uses it for fetching server-side TLS configurations, use its loggers and access its database/users/list.

By default, the server has no grpc.Server options attached. Please see the other functions of this package for pre-configured option sets.

func NewListener

func NewListener(opts ...grpc.ServerOption) *Teamserver

NewListener is a simple constructor returning a teamserver loaded with the provided list of server options. By default the server does not come with any.

func (*Teamserver) Close

func (h *Teamserver) Close() error

Close implements team/server.Handler.Close(). In this implementation, the function does nothing. Thus the underlying *grpc.Server.Shutdown() method is not called, and only the listener will be closed by the server automatically when using CloseListener().

This is probably not optimal from a resource usage standpoint, but currently it fits most use cases. Feel free to reimplement or propose changes to this lib.

func (*Teamserver) Init

func (h *Teamserver) Init(serv *teamserver.Server) (err error)

Init implements team/server.Handler.Init(). It is used to initialize the listener with the correct TLS credentials middleware (or absence of if about to serve an in-memory connection).

func (*Teamserver) Listen

func (h *Teamserver) Listen(addr string) (ln net.Listener, err error)

Listen implements team/server.Handler.Listen(). It starts listening on a network address for incoming gRPC clients. If the teamserver has previously been given an in-memory connection, it returns it as the listener without errors.

func (*Teamserver) Name

func (h *Teamserver) Name() string

Name immplements team/server.Handler.Name(). It indicates the transport/rpc stack, in this case "gRPC".

func (*Teamserver) PostServe

func (h *Teamserver) PostServe(hooks ...func(server *grpc.Server) error)

PostServe registers one or more hook functions to be ran on the server before it is served to the listener. These hooks should naturally be used to register additional services to it.

Jump to

Keyboard shortcuts

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