server

package
v1.0.35 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Package server implements GRPC-server upon gnetcli library.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

func BuildCreds

func BuildCreds(login, password string, enableAgent bool, logger *zap.Logger) credentials.Credentials

func BuildEmptyCreds added in v1.0.1

func BuildEmptyCreds(logger *zap.Logger) credentials.Credentials

func MakeFileResult

func MakeFileResult(path string, file streamer.File) *pb.FileData

Types

type Auth

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

func NewAuth

func NewAuth(logger *zap.Logger, login string, password credentials.Secret) *Auth

func NewAuthInsecure

func NewAuthInsecure(logger *zap.Logger) *Auth

func (*Auth) AuthenticateStream

func (m *Auth) AuthenticateStream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func (*Auth) AuthenticateUnary

func (m *Auth) AuthenticateUnary(ctx context.Context, req interface{}, servInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

type Config added in v1.0.27

type Config struct {
	Logging     LogConfig `yaml:"logging"`
	Port        int       `config:"port,description=Server port" yaml:"port"`
	DevLogin    string    `config:"dev-login,description=Default device login" yaml:"dev_login"`
	DevPass     string    `config:"dev-pass,description=Default device password" yaml:"dev_pass"`
	DevUseAgent bool      `config:"dev-use-agent" yaml:"dev_use_agent"`
	ConfFile    string    `config:"conf-file,description=Path to config file"`
	Tls         bool      `config:"tls,description=Connection uses TLS if true, else plain TCP" yaml:"tls"`
	CertFile    string    `config:"cert-file,description=The TLS cert file" yaml:"cert_file"`
	KeyFile     string    `config:"key-file,description=The TLS key file" yaml:"key_file"`
	BasicAuth   string    `config:"basic-auth,description=Authenticate client using Basic auth" yaml:"basic_auth"`
	DisableTcp  bool      `config:"disable_tcp,description=Disable TCP listener" yaml:"disable_tcp"`
	UnixSocket  string    `config:"unix-socket,description=Unix socket path" yaml:"unix_socket"`
	Debug       bool      `config:"debug,short=d,description=Set debug log level"`
}

func LoadConf added in v1.0.27

func LoadConf() (Config, error)

type LogConfig added in v1.0.27

type LogConfig struct {
	Level zapcore.Level `config:"level" yaml:"level"`
	Json  bool          `config:"json" yaml:"json"`
}

type MultiTrace

type MultiTrace interface {
	AddTrace(gtrace.Trace) int
	DelTrace(int) error
}

type MultiTraceImp

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

func NewMultiTrace

func NewMultiTrace() *MultiTraceImp

func (*MultiTraceImp) Add

func (m *MultiTraceImp) Add(op gtrace.Operation, data []byte)

func (*MultiTraceImp) AddTrace

func (m *MultiTraceImp) AddTrace(tr gtrace.Trace) int

func (*MultiTraceImp) DelTrace

func (m *MultiTraceImp) DelTrace(index int) error

func (*MultiTraceImp) List

func (m *MultiTraceImp) List() []gtrace.Item

type Option

type Option func(*Server)

func WithDefaultDeviceCredentials added in v1.0.27

func WithDefaultDeviceCredentials(creds credentials.Credentials) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

type Server

type Server struct {
	pb.UnimplementedGnetcliServer
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Server

func (*Server) AddDevice

func (m *Server) AddDevice(ctx context.Context, device *pb.Device) (*pb.DeviceResult, error)

func (*Server) Download added in v1.0.4

func (m *Server) Download(ctx context.Context, req *pb.FileDownloadRequest) (*pb.FilesResult, error)

func (*Server) Exec

func (m *Server) Exec(ctx context.Context, cmd *pb.CMD) (*pb.CMDResult, error)

func (*Server) ExecChat

func (m *Server) ExecChat(stream pb.Gnetcli_ExecChatServer) error

func (*Server) SetupHostParams added in v1.0.4

func (m *Server) SetupHostParams(ctx context.Context, hostParams *pb.HostParams) (*emptypb.Empty, error)

func (*Server) Upload

func (m *Server) Upload(ctx context.Context, req *pb.FileUploadRequest) (*emptypb.Empty, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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