notifier

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Overview

Package notifier defines the interface and the GRPC implementation for event notifier plugins. Notifier plugins allow to receive notifications for supported filesystem events such as file uploads, downloads etc., provider events such as objects add, update, delete and log events.

Index

Constants

View Source
const (
	// PluginName defines the name for a notifier plugin
	PluginName = "notifier"
)

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "SFTPGO_PLUGIN_NOTIFIER",
	MagicCookieValue: "c499b98b-cd59-4df2-92b3-6268817f4d80",
}

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	PluginName: &Plugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type FsEvent

type FsEvent struct {
	Action            string            `json:"action"`
	Username          string            `json:"username"`
	Path              string            `json:"path"`
	TargetPath        string            `json:"target_path,omitempty"`
	VirtualPath       string            `json:"virtual_path"`
	VirtualTargetPath string            `json:"virtual_target_path,omitempty"`
	SSHCmd            string            `json:"ssh_cmd,omitempty"`
	FileSize          int64             `json:"file_size,omitempty"`
	FsProvider        int               `json:"fs_provider"`
	Bucket            string            `json:"bucket,omitempty"`
	Endpoint          string            `json:"endpoint,omitempty"`
	Status            int               `json:"status"`
	Protocol          string            `json:"protocol"`
	IP                string            `json:"ip"`
	SessionID         string            `json:"session_id"`
	Timestamp         int64             `json:"timestamp"`
	OpenFlags         int               `json:"open_flags,omitempty"`
	Role              string            `json:"role,omitempty"`
	Elapsed           int64             `json:"elapsed,omitempty"`
	Metadata          map[string]string `json:"metadata,omitempty"`
}

FsEvent defines a file system event

type GRPCClient

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

GRPCClient is an implementation of Notifier interface that talks over RPC.

func (*GRPCClient) NotifyFsEvent

func (c *GRPCClient) NotifyFsEvent(event *FsEvent) error

NotifyFsEvent implements the Notifier interface

func (*GRPCClient) NotifyLogEvent added in v0.1.4

func (c *GRPCClient) NotifyLogEvent(event *LogEvent) error

NotifyLogEvent implements the Notifier interface

func (*GRPCClient) NotifyProviderEvent

func (c *GRPCClient) NotifyProviderEvent(event *ProviderEvent) error

NotifyProviderEvent implements the Notifier interface

type GRPCServer

type GRPCServer struct {
	Impl Notifier
}

GRPCServer defines the gRPC server that GRPCClient talks to.

func (*GRPCServer) SendFsEvent

func (s *GRPCServer) SendFsEvent(ctx context.Context, req *proto.FsEvent) (*emptypb.Empty, error)

SendFsEvent implements the serve side fs notify method

func (*GRPCServer) SendLogEvent added in v0.1.4

func (s *GRPCServer) SendLogEvent(ctx context.Context, req *proto.LogEvent) (*emptypb.Empty, error)

SendLogEvent implements the serve side provider event notify method

func (*GRPCServer) SendProviderEvent

func (s *GRPCServer) SendProviderEvent(ctx context.Context, req *proto.ProviderEvent) (*emptypb.Empty, error)

SendProviderEvent implements the serve side provider event notify method

type LogEvent added in v0.1.4

type LogEvent struct {
	Timestamp int64
	Event     LogEventType
	Protocol  string
	Username  string
	IP        string
	Message   string
	Role      string
}

LogEvent defines a log event

type LogEventType added in v0.1.4

type LogEventType int

LogEventType is the enumerable for the supported log events

const (
	LogEventTypeLoginFailed LogEventType = iota + 1
	LogEventTypeLoginNoUser
	LogEventTypeNoLoginTried
	LogEventTypeNotNegotiated
	LogEventTypeLoginOK
)

type Notifier

type Notifier interface {
	NotifyFsEvent(event *FsEvent) error
	NotifyProviderEvent(event *ProviderEvent) error
	NotifyLogEvent(event *LogEvent) error
}

Notifier defines the interface for notifiers plugins

type Plugin

type Plugin struct {
	plugin.Plugin
	Impl Notifier
}

Plugin defines the implementation to serve/connect to a notifier plugin

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient defines the GRPC client implementation for this plugin

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer defines the GRPC server implementation for this plugin

type ProviderEvent

type ProviderEvent struct {
	Action     string
	Username   string
	ObjectType string
	ObjectName string
	IP         string
	ObjectData []byte
	Timestamp  int64
	Role       string
}

ProviderEvent defines a provider event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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