impl

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditServiceImpl

type AuditServiceImpl struct {
	ioc.ObjectImpl

	// MinIO 配置
	MinIO *MinIOConfig `json:"minio" yaml:"minio" toml:"minio"`

	// 事件缓冲配置
	EventBuffer *EventBufferConfig `json:"event_buffer" yaml:"event_buffer" toml:"event_buffer"`
	// contains filtered or unexported fields
}

AuditServiceImpl 审计服务实现

func (*AuditServiceImpl) CloseConnection

func (i *AuditServiceImpl) CloseConnection(ctx context.Context, event *audit.ConnectionCloseEvent) error

CloseConnection 记录连接关闭

func (*AuditServiceImpl) GetObjectStorage

func (i *AuditServiceImpl) GetObjectStorage() audit.ObjectStorage

GetObjectStorage 获取对象存储接口

func (*AuditServiceImpl) GetSession

GetSession 获取会话记录

func (*AuditServiceImpl) GetSessionReplay

GetSessionReplay 获取会话回放数据

func (*AuditServiceImpl) Init

func (i *AuditServiceImpl) Init() error

func (*AuditServiceImpl) Name

func (i *AuditServiceImpl) Name() string

func (*AuditServiceImpl) Priority

func (i *AuditServiceImpl) Priority() int

func (*AuditServiceImpl) QuerySessions

QuerySessions 查询会话列表

func (*AuditServiceImpl) RecordConnection

func (i *AuditServiceImpl) RecordConnection(ctx context.Context, event *audit.ConnectionEvent) error

RecordConnection 记录连接建立

func (*AuditServiceImpl) RecordDataFlow

func (i *AuditServiceImpl) RecordDataFlow(ctx context.Context, event *audit.DataFlowEvent) error

RecordDataFlow 记录数据流(目前仅记录日志,实际解析在 parser 中进行)

func (*AuditServiceImpl) RecordEvent

func (i *AuditServiceImpl) RecordEvent(ctx context.Context, event *audit.OperationEvent) error

RecordEvent 记录操作事件

type EventBuffer

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

EventBuffer 事件缓冲队列

func NewEventBuffer

func NewEventBuffer(storage StorageAdapter, cfg *EventBufferConfig) *EventBuffer

NewEventBuffer 创建事件缓冲队列

func (*EventBuffer) Close

func (b *EventBuffer) Close() error

Close 关闭缓冲队列

func (*EventBuffer) Flush

func (b *EventBuffer) Flush() error

Flush 立即刷新所有待处理事件

func (*EventBuffer) Stats

func (b *EventBuffer) Stats() map[string]interface{}

Stats 获取缓冲队列统计

func (*EventBuffer) Stop

func (b *EventBuffer) Stop()

Stop 停止缓冲队列,刷新所有待处理事件

func (*EventBuffer) Write

func (b *EventBuffer) Write(event *audit.OperationEvent) error

Write 写入事件(异步)

type EventBufferConfig

type EventBufferConfig struct {
	Enabled       bool `toml:"enabled" json:"enabled" yaml:"enabled" env:"AUDIT_BUFFER_ENABLED"`
	Size          int  `toml:"size" json:"size" yaml:"size" env:"AUDIT_BUFFER_SIZE"`
	FlushInterval int  `toml:"flush_interval" json:"flush_interval" yaml:"flush_interval" env:"AUDIT_BUFFER_FLUSH_INTERVAL"`
	BatchSize     int  `toml:"batch_size" json:"batch_size" yaml:"batch_size" env:"AUDIT_BUFFER_BATCH_SIZE"`
}

EventBufferConfig 事件缓冲配置

func DefaultEventBufferConfig

func DefaultEventBufferConfig() *EventBufferConfig

DefaultEventBufferConfig 默认配置

type MinIOConfig

type MinIOConfig struct {
	Endpoint  string `toml:"endpoint" json:"endpoint" yaml:"endpoint" env:"MINIO_ENDPOINT"`
	AccessKey string `toml:"access_key" json:"access_key" yaml:"access_key" env:"MINIO_ACCESS_KEY"`
	SecretKey string `toml:"secret_key" json:"secret_key" yaml:"secret_key" env:"MINIO_SECRET_KEY"`
	Bucket    string `toml:"bucket" json:"bucket" yaml:"bucket" env:"MINIO_BUCKET"`
	UseSSL    bool   `toml:"use_ssl" json:"use_ssl" yaml:"use_ssl" env:"MINIO_USE_SSL"`
}

MinIOConfig MinIO 配置

func DefaultMinIOConfig

func DefaultMinIOConfig() *MinIOConfig

DefaultMinIOConfig 默认配置

type MinIOStorage

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

MinIOStorage MinIO 存储实现

func NewMinIOStorage

func NewMinIOStorage(cfg *MinIOConfig) (*MinIOStorage, error)

NewMinIOStorage 创建 MinIO 存储实例

func (*MinIOStorage) BatchDownload

func (s *MinIOStorage) BatchDownload(ctx context.Context, paths []string, destDir string) error

BatchDownload 批量下载文件到本地目录

func (*MinIOStorage) Delete

func (s *MinIOStorage) Delete(ctx context.Context, path string) error

Delete 实现 ObjectStorage 接口

func (*MinIOStorage) DeleteRecording

func (s *MinIOStorage) DeleteRecording(ctx context.Context, path string) error

DeleteRecording 删除录像文件

func (*MinIOStorage) Download

func (s *MinIOStorage) Download(ctx context.Context, path string) ([]byte, error)

Download 实现 ObjectStorage 接口

func (*MinIOStorage) DownloadRecording

func (s *MinIOStorage) DownloadRecording(ctx context.Context, path string) (io.ReadCloser, error)

DownloadRecording 下载录像文件

func (*MinIOStorage) Exists

func (s *MinIOStorage) Exists(ctx context.Context, path string) (bool, error)

Exists 实现 ObjectStorage 接口

func (*MinIOStorage) FileExists

func (s *MinIOStorage) FileExists(ctx context.Context, path string) (bool, error)

FileExists 检查文件是否存在

func (*MinIOStorage) GetPresignedURL

func (s *MinIOStorage) GetPresignedURL(ctx context.Context, path string, expiry int) (string, error)

GetPresignedURL 生成预签名 URL

func (*MinIOStorage) GetURL

func (s *MinIOStorage) GetURL(ctx context.Context, path string, expiry time.Duration) (string, error)

GetURL 实现 ObjectStorage 接口

func (*MinIOStorage) ListObjectsWithPrefix

func (s *MinIOStorage) ListObjectsWithPrefix(ctx context.Context, prefix string) ([]string, error)

ListObjectsWithPrefix 列出指定前缀的所有对象

func (*MinIOStorage) Upload

func (s *MinIOStorage) Upload(ctx context.Context, path string, data io.Reader) error

Upload 实现 ObjectStorage 接口(带重试)

func (*MinIOStorage) UploadRecording

func (s *MinIOStorage) UploadRecording(ctx context.Context, path string, data io.Reader, contentType string) error

UploadRecording 上传录像文件

type MySQLStorage

type MySQLStorage struct{}

MySQLStorage MySQL 存储实现

func NewMySQLStorage

func NewMySQLStorage() *MySQLStorage

NewMySQLStorage 创建 MySQL 存储实例

func (*MySQLStorage) BatchSaveEvents

func (s *MySQLStorage) BatchSaveEvents(ctx context.Context, events []*audit.OperationEvent) error

BatchSaveEvents 批量保存事件

func (*MySQLStorage) GetSession

func (s *MySQLStorage) GetSession(ctx context.Context, id string) (*audit.Session, error)

GetSession 获取会话

func (*MySQLStorage) QueryEvents

func (s *MySQLStorage) QueryEvents(ctx context.Context, sessionID string) ([]*audit.OperationEvent, error)

QueryEvents 查询会话的所有事件

func (*MySQLStorage) QuerySessions

func (s *MySQLStorage) QuerySessions(ctx context.Context, req *audit.QuerySessionRequest) (*audit.SessionSet, error)

QuerySessions 查询会话列表

func (*MySQLStorage) SaveEvent

func (s *MySQLStorage) SaveEvent(ctx context.Context, event *audit.OperationEvent) error

SaveEvent 保存单个事件

func (*MySQLStorage) SaveSession

func (s *MySQLStorage) SaveSession(ctx context.Context, session *audit.Session) error

SaveSession 保存会话

func (*MySQLStorage) UpdateSession

func (s *MySQLStorage) UpdateSession(ctx context.Context, session *audit.Session) error

UpdateSession 更新会话

type ObjectStorage

type ObjectStorage interface {
	// 上传录像文件
	UploadRecording(ctx context.Context, path string, data io.Reader, contentType string) error
	// 下载录像文件
	DownloadRecording(ctx context.Context, path string) (io.ReadCloser, error)
	// 生成预签名 URL(用于回放)
	GetPresignedURL(ctx context.Context, path string, expiry int) (string, error)
	// 删除录像文件
	DeleteRecording(ctx context.Context, path string) error
	// 检查文件是否存在
	FileExists(ctx context.Context, path string) (bool, error)
}

ObjectStorage 对象存储接口

type StorageAdapter

type StorageAdapter interface {
	// 会话管理
	SaveSession(ctx context.Context, session *audit.Session) error
	GetSession(ctx context.Context, id string) (*audit.Session, error)
	UpdateSession(ctx context.Context, session *audit.Session) error
	QuerySessions(ctx context.Context, req *audit.QuerySessionRequest) (*audit.SessionSet, error)

	// 事件记录
	SaveEvent(ctx context.Context, event *audit.OperationEvent) error
	BatchSaveEvents(ctx context.Context, events []*audit.OperationEvent) error
	QueryEvents(ctx context.Context, sessionID string) ([]*audit.OperationEvent, error)
}

StorageAdapter 存储适配器接口

Jump to

Keyboard shortcuts

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