Documentation
¶
Index ¶
- Constants
- Variables
- func AddLoginFail(ip string)
- func ClearLoginFail(ip string)
- func GenerateNonce() (string, error)
- func GetLimiter(ip string) *rate.Limiter
- func IsIPBlocked(ip string) (bool, time.Duration)
- func JWTAuth() fiber.Handler
- func RecordChannelConnectionStart(channelID string)
- func RecordChannelError(channelID string, errType, code, message string)
- func RecordChannelReconnect(channelID string)
- func RecordChannelRequest(channelID string, success bool, duration time.Duration, errorType string)
- func UpdateDeviceMetrics(deviceID string, update func(*model.DeviceMetrics))
- func ValidateAndConsumeNonce(nonce string) bool
- type ChangePasswordRequest
- type Client
- type CustomClaims
- type DashboardSummary
- type EdgeLogQuery
- type Hub
- type JWT
- type LoginFailInfo
- type LoginRequest
- type LoginResponse
- type Server
- func (s *Server) AuthenticateLDAP(username, password string) (bool, *model.UserConfig, error)
- func (s *Server) BroadcastShadowPoint(channelID, deviceID, pointID string, point model.ShadowPoint)
- func (s *Server) BroadcastValue(v any)
- func (s *Server) GetListenPort() int
- func (s *Server) SetRuntimeStartHook(fn func())
- func (s *Server) SetShadowCore(sc *core.ShadowCore)
- func (s *Server) SetStorageAttachHook(fn func(*storage.Storage))
- func (s *Server) SetVirtualShadowEngine(vse *core.VirtualShadowEngine)
- func (s *Server) SetVirtualShadowManager(vsm *core.VirtualShadowManager)
- func (s *Server) Start(addr string) error
- func (s *Server) StopBackgroundTasks()
- func (s *Server) SwitchPort(newPort int) error
- func (s *Server) ValidateUser(username, password, nonce string) (*model.UserConfig, error)
- type SnapshotResponse
- type SystemStats
Constants ¶
const ( MaxLoginFailCount = 10 LoginBlockDuration = 3 * time.Minute )
Variables ¶
var DebugMode bool = true
========================== JWT Implementation ==========================
Functions ¶
func AddLoginFail ¶
func AddLoginFail(ip string)
func ClearLoginFail ¶
func ClearLoginFail(ip string)
func GenerateNonce ¶
func GetLimiter ¶
func RecordChannelConnectionStart ¶
func RecordChannelConnectionStart(channelID string)
RecordChannelConnectionStart 记录通道连接开始 (供 driver 调用)
func RecordChannelError ¶
RecordChannelError 记录通道错误 (供 driver 调用)
func RecordChannelReconnect ¶
func RecordChannelReconnect(channelID string)
RecordChannelReconnect 记录通道重连 (供 driver 调用)
func RecordChannelRequest ¶
RecordChannelRequest 记录通道请求指标 (供 driver 调用)
func UpdateDeviceMetrics ¶
func UpdateDeviceMetrics(deviceID string, update func(*model.DeviceMetrics))
UpdateDeviceMetrics 更新设备指标 (供 driver 调用)
func ValidateAndConsumeNonce ¶
Types ¶
type ChangePasswordRequest ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for WebSocket connections
type CustomClaims ¶
type CustomClaims struct {
Name string `json:"name"`
Email string `json:"email"`
jwt.RegisteredClaims
}
type DashboardSummary ¶
type DashboardSummary struct {
Channels []core.ChannelStatus `json:"channels"`
Northbound []core.NorthboundStatus `json:"northbound"`
EdgeRules core.EdgeComputeMetrics `json:"edge_rules"`
System SystemStats `json:"system"`
}
type EdgeLogQuery ¶
type EdgeLogQuery struct {
RuleID string `query:"rule_id"`
Category string `query:"category"`
ChannelID string `query:"channel_id"`
DeviceID string `query:"device_id"`
StartDate string `query:"start_date"` // Format: YYYY-MM-DD HH:mm
EndDate string `query:"end_date"` // Format: YYYY-MM-DD HH:mm
}
EdgeLogQuery represents query parameters
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
func (*JWT) ParserToken ¶
func (j *JWT) ParserToken(tokenString string) (*CustomClaims, error)
type LoginFailInfo ¶
type LoginRequest ¶
type LoginRequest struct {
LoginFlag bool `json:"loginFlag"`
LoginType string `json:"loginType"` // "local" or "ldap"
Data struct {
Username string `json:"username"`
Password string `json:"password"`
Nonce string `json:"nonce"`
} `json:"data"`
}
LoginRequest defines the login payload
type LoginResponse ¶
type LoginResponse struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data struct {
Username string `json:"username"`
Token string `json:"token"`
Permissions []string `json:"permissions"`
} `json:"data"`
}
LoginResponse defines the successful login response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(cm *core.ChannelManager, st *storage.Storage, pl *core.DataPipeline, nbm *core.NorthboundManager, ecm *core.EdgeComputeManager, sm *core.SystemManager, dsm *core.DeviceStorageManager, cfgManager *config.ConfigManager, syncManager *syncpkg.SyncManager, logBroadcaster *logger.LogBroadcaster) *Server
func (*Server) AuthenticateLDAP ¶
AuthenticateLDAP attempts to authenticate a user against the configured LDAP server
func (*Server) BroadcastShadowPoint ¶
func (s *Server) BroadcastShadowPoint(channelID, deviceID, pointID string, point model.ShadowPoint)
BroadcastShadowPoint 将影子点位快照推送到 WebSocket 客户端。
func (*Server) BroadcastValue ¶
BroadcastValue sends a value to all connected clients
func (*Server) GetListenPort ¶
func (*Server) SetRuntimeStartHook ¶ added in v0.0.7
func (s *Server) SetRuntimeStartHook(fn func())
SetRuntimeStartHook 注册数据采集/北向启动回调(安装完成后或正常启动时调用)。
func (*Server) SetShadowCore ¶
func (s *Server) SetShadowCore(sc *core.ShadowCore)
SetShadowCore 绑定影子设备核心,并订阅快照变更推送到 WebSocket。
func (*Server) SetStorageAttachHook ¶
SetStorageAttachHook 注册存储绑定回调(安装流程创建 DB 后回传 main 等组件)。
func (*Server) SetVirtualShadowEngine ¶
func (s *Server) SetVirtualShadowEngine(vse *core.VirtualShadowEngine)
SetVirtualShadowEngine 绑定虚拟影子引擎(公式点位增量计算)。
func (*Server) SetVirtualShadowManager ¶
func (s *Server) SetVirtualShadowManager(vsm *core.VirtualShadowManager)
func (*Server) StopBackgroundTasks ¶ added in v0.0.8
func (s *Server) StopBackgroundTasks()
StopBackgroundTasks 停止后台维护任务(定时 compact 等)。
func (*Server) SwitchPort ¶
func (*Server) ValidateUser ¶
func (s *Server) ValidateUser(username, password, nonce string) (*model.UserConfig, error)
Helper to check login from other parts of the system if needed
type SnapshotResponse ¶
type SnapshotResponse struct {
ID string `json:"id"`
Name string `json:"name"`
NodeID string `json:"node_id"`
NodeName string `json:"node_name"`
CapturedAt string `json:"captured_at"`
Size int64 `json:"size"`
Description string `json:"description"`
Tags []string `json:"tags"`
Data *syncpkg.NodeSnapshot `json:"data,omitempty"`
}
SnapshotResponse represents a snapshot API response
Source Files
¶
- ai_handler.go
- ai_settings_handler.go
- ai_task_handler.go
- auth.go
- cluster_handler.go
- device_scan_handler.go
- diagnostics_handler.go
- edge_events.go
- edge_logs.go
- install_handler.go
- ldap_auth.go
- metrics_handler.go
- modbus_handler.go
- runtime_compact.go
- server.go
- server_ext.go
- snapshot_handler.go
- sync_tree_handler.go
- system_handler.go
- virtual_shadow_handler.go