Documentation
¶
Index ¶
- type AuditServiceImpl
- func (i *AuditServiceImpl) CloseConnection(ctx context.Context, event *audit.ConnectionCloseEvent) error
- func (i *AuditServiceImpl) GetObjectStorage() audit.ObjectStorage
- func (i *AuditServiceImpl) GetSession(ctx context.Context, req *audit.GetSessionRequest) (*audit.Session, error)
- func (i *AuditServiceImpl) GetSessionReplay(ctx context.Context, req *audit.GetSessionReplayRequest) (*audit.SessionReplay, error)
- func (i *AuditServiceImpl) Init() error
- func (i *AuditServiceImpl) Name() string
- func (i *AuditServiceImpl) Priority() int
- func (i *AuditServiceImpl) QuerySessions(ctx context.Context, req *audit.QuerySessionRequest) (*audit.SessionSet, error)
- func (i *AuditServiceImpl) RecordConnection(ctx context.Context, event *audit.ConnectionEvent) error
- func (i *AuditServiceImpl) RecordDataFlow(ctx context.Context, event *audit.DataFlowEvent) error
- func (i *AuditServiceImpl) RecordEvent(ctx context.Context, event *audit.OperationEvent) error
- type EventBuffer
- type EventBufferConfig
- type MinIOConfig
- type MinIOStorage
- func (s *MinIOStorage) BatchDownload(ctx context.Context, paths []string, destDir string) error
- func (s *MinIOStorage) Delete(ctx context.Context, path string) error
- func (s *MinIOStorage) DeleteRecording(ctx context.Context, path string) error
- func (s *MinIOStorage) Download(ctx context.Context, path string) ([]byte, error)
- func (s *MinIOStorage) DownloadRecording(ctx context.Context, path string) (io.ReadCloser, error)
- func (s *MinIOStorage) Exists(ctx context.Context, path string) (bool, error)
- func (s *MinIOStorage) FileExists(ctx context.Context, path string) (bool, error)
- func (s *MinIOStorage) GetPresignedURL(ctx context.Context, path string, expiry int) (string, error)
- func (s *MinIOStorage) GetURL(ctx context.Context, path string, expiry time.Duration) (string, error)
- func (s *MinIOStorage) ListObjectsWithPrefix(ctx context.Context, prefix string) ([]string, error)
- func (s *MinIOStorage) Upload(ctx context.Context, path string, data io.Reader) error
- func (s *MinIOStorage) UploadRecording(ctx context.Context, path string, data io.Reader, contentType string) error
- type MySQLStorage
- func (s *MySQLStorage) BatchSaveEvents(ctx context.Context, events []*audit.OperationEvent) error
- func (s *MySQLStorage) GetSession(ctx context.Context, id string) (*audit.Session, error)
- func (s *MySQLStorage) QueryEvents(ctx context.Context, sessionID string) ([]*audit.OperationEvent, error)
- func (s *MySQLStorage) QuerySessions(ctx context.Context, req *audit.QuerySessionRequest) (*audit.SessionSet, error)
- func (s *MySQLStorage) SaveEvent(ctx context.Context, event *audit.OperationEvent) error
- func (s *MySQLStorage) SaveSession(ctx context.Context, session *audit.Session) error
- func (s *MySQLStorage) UpdateSession(ctx context.Context, session *audit.Session) error
- type ObjectStorage
- type StorageAdapter
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 ¶
func (i *AuditServiceImpl) GetSession(ctx context.Context, req *audit.GetSessionRequest) (*audit.Session, error)
GetSession 获取会话记录
func (*AuditServiceImpl) GetSessionReplay ¶
func (i *AuditServiceImpl) GetSessionReplay(ctx context.Context, req *audit.GetSessionReplayRequest) (*audit.SessionReplay, error)
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 ¶
func (i *AuditServiceImpl) QuerySessions(ctx context.Context, req *audit.QuerySessionRequest) (*audit.SessionSet, error)
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) 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 配置
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 ¶
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) DownloadRecording ¶
func (s *MinIOStorage) DownloadRecording(ctx context.Context, path string) (io.ReadCloser, error)
DownloadRecording 下载录像文件
func (*MinIOStorage) FileExists ¶
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 ¶
ListObjectsWithPrefix 列出指定前缀的所有对象
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 (*MySQLStorage) BatchSaveEvents ¶
func (s *MySQLStorage) BatchSaveEvents(ctx context.Context, events []*audit.OperationEvent) error
BatchSaveEvents 批量保存事件
func (*MySQLStorage) GetSession ¶
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 ¶
SaveSession 保存会话
func (*MySQLStorage) UpdateSession ¶
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 存储适配器接口