netutil

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientTLSConfig

func ClientTLSConfig(sslCert, sslKey, sslCA string) (*tls.Config, error)

func RunGRPCServerWithContext

func RunGRPCServerWithContext(ctx context.Context, server *grpc.Server, addr string) error

Run a GRPC server controlled by a Context.

func RunHTTPServerWithContext

func RunHTTPServerWithContext(ctx context.Context, server *http.Server) error

Run a HTTP server controlled by a Context.

func ServerTLSConfig

func ServerTLSConfig(sslCert, sslKey, sslCA string) (*tls.Config, error)

Types

type GRPCEndpointSpec

type GRPCEndpointSpec struct {
	TLSParams `yaml:",inline"`

	Addr              string `yaml:"addr" doc:"GRPC endpoint (host:port)"`
	ServiceConfigJSON string `yaml:"service_config" doc:"additional GRPC client config (JSON-encoded)"`
	// contains filtered or unexported fields
}

func (*GRPCEndpointSpec) Dial

func (e *GRPCEndpointSpec) Dial(opts ...grpc.DialOption) (*grpc.ClientConn, error)

func (*GRPCEndpointSpec) DialOptions

func (e *GRPCEndpointSpec) DialOptions() ([]grpc.DialOption, error)

func (*GRPCEndpointSpec) DialShard

func (e *GRPCEndpointSpec) DialShard(shard string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

type GRPCServerSpec

type GRPCServerSpec struct {
	TLSParams

	ACL string `yaml:"acl"`
}

func (*GRPCServerSpec) ServerOptions

func (s *GRPCServerSpec) ServerOptions() ([]grpc.ServerOption, *grpcprom.ServerMetrics, error)

type LineConn

type LineConn struct {
	net.Conn

	WriteTimeout time.Duration
	ReadTimeout  time.Duration
	// contains filtered or unexported fields
}

A LineConn is just a slightly improved net/textproto.Conn, with timeout support and a byte-oriented API.

func NewLineConn

func NewLineConn(conn net.Conn) *LineConn

NewLineConn creates a new LineConn. As opposed to the textproto.Conn, LineConn owns the net.Conn so you should call Close() on it and not on the original connection.

func (*LineConn) ReadRequest

func (c *LineConn) ReadRequest() ([]byte, error)

func (*LineConn) WriteResponse

func (c *LineConn) WriteResponse(response []byte) error

type SocketHandler

type SocketHandler interface {
	ServeConnection(c net.Conn)
}

Handler for UNIX socket server connections.

type SocketServer

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

SocketServer accepts connections on a UNIX socket, speaking the line-based wire protocol, and dispatches incoming requests to the wrapped Server.

func NewSystemdSocketServer

func NewSystemdSocketServer(h SocketHandler) (*SocketServer, error)

NewSystemdSocketServer uses systemd socket activation, receiving the open socket as a file descriptor on exec.

func NewUNIXSocketServer

func NewUNIXSocketServer(socketPath string, h SocketHandler) (*SocketServer, error)

NewUNIXSocketServer returns a new SocketServer listening on the given path.

func (*SocketServer) Close

func (s *SocketServer) Close()

Close the socket listener and release all associated resources. Waits for active connections to terminate before returning.

func (*SocketServer) Serve

func (s *SocketServer) Serve() error

Serve connections.

type TLSParams

type TLSParams struct {
	SSLCert string `yaml:"ssl_cert" doc:"SSL certificate file"`
	SSLKey  string `yaml:"ssl_key" doc:"SSL private key file"`
	SSLCA   string `yaml:"ssl_ca" doc:"SSL CA"`
}

Jump to

Keyboard shortcuts

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