Documentation
¶
Index ¶
- func ConfigureTrustedProxies(engine *gin.Engine, raw string)
- func GzipMiddleware() gin.HandlerFunc
- func ResolveTrustedProxies(raw string) (proxies []string, mode string, err error)
- type APIHandler
- func (h *APIHandler) AckReports(c *gin.Context)
- func (h *APIHandler) AppendWorkflowFeedback(c *gin.Context)
- func (h *APIHandler) ArchiveSession(c *gin.Context)
- func (h *APIHandler) CancelSession(c *gin.Context)
- func (h *APIHandler) CreateCredential(c *gin.Context)
- func (h *APIHandler) CreateNorm(c *gin.Context)
- func (h *APIHandler) CreateTask(c *gin.Context)
- func (h *APIHandler) DeleteCredential(c *gin.Context)
- func (h *APIHandler) DeleteNorm(c *gin.Context)
- func (h *APIHandler) DeleteSession(c *gin.Context)
- func (h *APIHandler) DeleteWorkflowDraft(c *gin.Context)
- func (h *APIHandler) GetCredential(c *gin.Context)
- func (h *APIHandler) GetCurrentSession(c *gin.Context)
- func (h *APIHandler) GetNorm(c *gin.Context)
- func (h *APIHandler) GetSession(c *gin.Context)
- func (h *APIHandler) GetSessionImage(c *gin.Context)
- func (h *APIHandler) GetSettings(c *gin.Context)
- func (h *APIHandler) GetTask(c *gin.Context)
- func (h *APIHandler) GetWorkflowDraft(c *gin.Context)
- func (h *APIHandler) GetWorkflowPhase(c *gin.Context)
- func (h *APIHandler) GetWorkflowSessions(c *gin.Context)
- func (h *APIHandler) GetWorkflowSheet(c *gin.Context)
- func (h *APIHandler) KeepaliveSession(c *gin.Context)
- func (h *APIHandler) ListCredentials(c *gin.Context)
- func (h *APIHandler) ListNorms(c *gin.Context)
- func (h *APIHandler) ListQueuedFeedbacks(c *gin.Context)
- func (h *APIHandler) ListSessions(c *gin.Context)
- func (h *APIHandler) ListTasks(c *gin.Context)
- func (h *APIHandler) ReadReports(c *gin.Context)
- func (h *APIHandler) ReadTaskFeedbacks(c *gin.Context)
- func (h *APIHandler) RegenerateCredentialToken(c *gin.Context)
- func (h *APIHandler) RenameSession(c *gin.Context)
- func (h *APIHandler) RestoreSession(c *gin.Context)
- func (h *APIHandler) RevokeQueuedFeedback(c *gin.Context)
- func (h *APIHandler) RevokeSession(c *gin.Context)
- func (h *APIHandler) SaveWorkflowDraft(c *gin.Context)
- func (h *APIHandler) SaveWorkflowSheet(c *gin.Context)
- func (h *APIHandler) SendTaskFeedback(c *gin.Context)
- func (h *APIHandler) SetWorkflowPhase(c *gin.Context)
- func (h *APIHandler) SubmitFeedback(c *gin.Context)
- func (h *APIHandler) TranscribeAudio(c *gin.Context)
- func (h *APIHandler) UnarchiveSession(c *gin.Context)
- func (h *APIHandler) UpdateCredential(c *gin.Context)
- func (h *APIHandler) UpdateNorm(c *gin.Context)
- func (h *APIHandler) UpdateSessionMaxChecks(c *gin.Context)
- func (h *APIHandler) UpdateSessionPromptWait(c *gin.Context)
- func (h *APIHandler) UpdateSessionUserPresence(c *gin.Context)
- func (h *APIHandler) UpdateSessionWaitCountdown(c *gin.Context)
- func (h *APIHandler) UpdateSettings(c *gin.Context)
- func (h *APIHandler) UpdateTaskStages(c *gin.Context)
- type AckReportsRequest
- type AuthHandler
- func (a *AuthHandler) ChangeCredentials(c *gin.Context)
- func (a *AuthHandler) ClearAllBlockedIPs(c *gin.Context)
- func (a *AuthHandler) GetBlockedIPs(c *gin.Context)
- func (a *AuthHandler) GetEffectiveCredentials(c *gin.Context) (username string, password string)
- func (a *AuthHandler) Login(c *gin.Context)
- func (a *AuthHandler) Middleware() gin.HandlerFunc
- func (a *AuthHandler) ResetCredentials(c *gin.Context)
- func (a *AuthHandler) Status(c *gin.Context)
- func (a *AuthHandler) UnblockIP(c *gin.Context)
- func (a *AuthHandler) VerifyJWTToken(tokenString string) (*jwt.MapClaims, bool)
- func (a *AuthHandler) VerifyToken(tokenString string) bool
- type BlockedIPInfo
- type ChangeCredentialsRequest
- type CreateTaskRequest
- type IPAttempt
- type LoginRequest
- type RateLimitedWriter
- type RateLimiter
- func (rl *RateLimiter) CheckLocked(ip string) (isLocked bool, remaining time.Duration)
- func (rl *RateLimiter) ClearAll()
- func (rl *RateLimiter) Close()
- func (rl *RateLimiter) GetBlockedIPs() []BlockedIPInfo
- func (rl *RateLimiter) RecordFailure(ip string, maxAttempts int, lockoutDuration time.Duration) (isLocked bool, remaining time.Duration)
- func (rl *RateLimiter) RecordSuccess(ip string)
- func (rl *RateLimiter) UnblockIP(ip string)
- type SSEBroker
- type SaveWorkflowSheetRequest
- type SendTaskFeedbackRequest
- type Server
- type SubmitFeedbackRequest
- type TranscribeAudioRequest
- type UpdateTaskStagesRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureTrustedProxies ¶ added in v1.6.3
ConfigureTrustedProxies 按 RELAYMESH_TRUSTED_PROXIES 设置 Gin 的可信代理网段。
背景:Gin 默认信任全部代理,此时 c.ClientIP() 会采信客户端自带的 X-Forwarded-For 最左项, 而登录反爆破(RateLimiter)与终端预认证限流都以它为键,攻击者每次换一个头值即可绕过锁定。 配置错误时回退为默认网段(回环 + 私网)而不是 Gin 的「信任全部」,宁可少信任也不多信任。
func GzipMiddleware ¶ added in v1.3.0
func GzipMiddleware() gin.HandlerFunc
GzipMiddleware 为 HTTP 响应提供动态 Gzip 压缩,显著缩减大 JSON 和富文本在小带宽服务器上的网络传输体积
func ResolveTrustedProxies ¶ added in v1.6.3
ResolveTrustedProxies 解析 RELAYMESH_TRUSTED_PROXIES,返回可直接传给 gin.Engine.SetTrustedProxies 的列表。
- 空值:默认网段(回环 + 私网);
- none:不信任任何代理,ClientIP() 恒为直连对端地址(返回 nil 列表);
- *:信任全部代理(升级前的旧行为;X-Forwarded-For 可被任意客户端伪造,仅在明确知道后果时使用);
- 其他:逗号 / 空白分隔的 IP 或 CIDR,关键字 default 展开为默认网段(例如 "default,203.0.113.0/24")。 显式列出即完全以所列为准,不会隐式追加默认网段。
none 与 * 必须单独出现。任何无法识别的条目都会返回错误,由调用方决定回退策略。
Types ¶
type APIHandler ¶
type APIHandler struct {
// contains filtered or unexported fields
}
func NewAPIHandler ¶
func (*APIHandler) AckReports ¶
func (h *APIHandler) AckReports(c *gin.Context)
func (*APIHandler) AppendWorkflowFeedback ¶
func (h *APIHandler) AppendWorkflowFeedback(c *gin.Context)
func (*APIHandler) ArchiveSession ¶
func (h *APIHandler) ArchiveSession(c *gin.Context)
func (*APIHandler) CancelSession ¶
func (h *APIHandler) CancelSession(c *gin.Context)
func (*APIHandler) CreateCredential ¶ added in v1.1.0
func (h *APIHandler) CreateCredential(c *gin.Context)
func (*APIHandler) CreateNorm ¶ added in v1.1.0
func (h *APIHandler) CreateNorm(c *gin.Context)
func (*APIHandler) CreateTask ¶ added in v1.1.0
func (h *APIHandler) CreateTask(c *gin.Context)
func (*APIHandler) DeleteCredential ¶ added in v1.1.0
func (h *APIHandler) DeleteCredential(c *gin.Context)
func (*APIHandler) DeleteNorm ¶ added in v1.1.0
func (h *APIHandler) DeleteNorm(c *gin.Context)
func (*APIHandler) DeleteSession ¶ added in v1.6.0
func (h *APIHandler) DeleteSession(c *gin.Context)
func (*APIHandler) DeleteWorkflowDraft ¶
func (h *APIHandler) DeleteWorkflowDraft(c *gin.Context)
func (*APIHandler) GetCredential ¶ added in v1.1.0
func (h *APIHandler) GetCredential(c *gin.Context)
func (*APIHandler) GetCurrentSession ¶
func (h *APIHandler) GetCurrentSession(c *gin.Context)
func (*APIHandler) GetNorm ¶ added in v1.1.0
func (h *APIHandler) GetNorm(c *gin.Context)
func (*APIHandler) GetSession ¶
func (h *APIHandler) GetSession(c *gin.Context)
func (*APIHandler) GetSessionImage ¶ added in v1.3.0
func (h *APIHandler) GetSessionImage(c *gin.Context)
func (*APIHandler) GetTask ¶
func (h *APIHandler) GetTask(c *gin.Context)
func (*APIHandler) GetWorkflowDraft ¶
func (h *APIHandler) GetWorkflowDraft(c *gin.Context)
Workflow Drafts Handlers
func (*APIHandler) GetWorkflowPhase ¶ added in v1.1.0
func (h *APIHandler) GetWorkflowPhase(c *gin.Context)
func (*APIHandler) GetWorkflowSessions ¶ added in v1.3.0
func (h *APIHandler) GetWorkflowSessions(c *gin.Context)
func (*APIHandler) GetWorkflowSheet ¶ added in v1.5.0
func (h *APIHandler) GetWorkflowSheet(c *gin.Context)
func (*APIHandler) KeepaliveSession ¶
func (h *APIHandler) KeepaliveSession(c *gin.Context)
func (*APIHandler) ListCredentials ¶ added in v1.1.0
func (h *APIHandler) ListCredentials(c *gin.Context)
func (*APIHandler) ListNorms ¶ added in v1.1.0
func (h *APIHandler) ListNorms(c *gin.Context)
func (*APIHandler) ListQueuedFeedbacks ¶
func (h *APIHandler) ListQueuedFeedbacks(c *gin.Context)
func (*APIHandler) ListSessions ¶
func (h *APIHandler) ListSessions(c *gin.Context)
func (*APIHandler) ReadReports ¶
func (h *APIHandler) ReadReports(c *gin.Context)
func (*APIHandler) ReadTaskFeedbacks ¶ added in v1.1.0
func (h *APIHandler) ReadTaskFeedbacks(c *gin.Context)
func (*APIHandler) RegenerateCredentialToken ¶ added in v1.1.0
func (h *APIHandler) RegenerateCredentialToken(c *gin.Context)
func (*APIHandler) RenameSession ¶
func (h *APIHandler) RenameSession(c *gin.Context)
func (*APIHandler) RestoreSession ¶ added in v1.6.0
func (h *APIHandler) RestoreSession(c *gin.Context)
func (*APIHandler) RevokeQueuedFeedback ¶
func (h *APIHandler) RevokeQueuedFeedback(c *gin.Context)
func (*APIHandler) RevokeSession ¶
func (h *APIHandler) RevokeSession(c *gin.Context)
func (*APIHandler) SaveWorkflowDraft ¶
func (h *APIHandler) SaveWorkflowDraft(c *gin.Context)
func (*APIHandler) SaveWorkflowSheet ¶ added in v1.5.0
func (h *APIHandler) SaveWorkflowSheet(c *gin.Context)
func (*APIHandler) SendTaskFeedback ¶
func (h *APIHandler) SendTaskFeedback(c *gin.Context)
func (*APIHandler) SetWorkflowPhase ¶ added in v1.1.0
func (h *APIHandler) SetWorkflowPhase(c *gin.Context)
func (*APIHandler) SubmitFeedback ¶
func (h *APIHandler) SubmitFeedback(c *gin.Context)
func (*APIHandler) TranscribeAudio ¶
func (h *APIHandler) TranscribeAudio(c *gin.Context)
func (*APIHandler) UnarchiveSession ¶
func (h *APIHandler) UnarchiveSession(c *gin.Context)
func (*APIHandler) UpdateCredential ¶ added in v1.1.0
func (h *APIHandler) UpdateCredential(c *gin.Context)
func (*APIHandler) UpdateNorm ¶ added in v1.1.0
func (h *APIHandler) UpdateNorm(c *gin.Context)
func (*APIHandler) UpdateSessionMaxChecks ¶
func (h *APIHandler) UpdateSessionMaxChecks(c *gin.Context)
func (*APIHandler) UpdateSessionPromptWait ¶
func (h *APIHandler) UpdateSessionPromptWait(c *gin.Context)
func (*APIHandler) UpdateSessionUserPresence ¶
func (h *APIHandler) UpdateSessionUserPresence(c *gin.Context)
func (*APIHandler) UpdateSessionWaitCountdown ¶
func (h *APIHandler) UpdateSessionWaitCountdown(c *gin.Context)
func (*APIHandler) UpdateSettings ¶
func (h *APIHandler) UpdateSettings(c *gin.Context)
func (*APIHandler) UpdateTaskStages ¶ added in v1.1.0
func (h *APIHandler) UpdateTaskStages(c *gin.Context)
type AckReportsRequest ¶
type AckReportsRequest struct {
ThroughSequence int64 `json:"through_sequence"`
}
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(cfg *config.Config, st *store.Store, limiter *RateLimiter) *AuthHandler
func (*AuthHandler) ChangeCredentials ¶
func (a *AuthHandler) ChangeCredentials(c *gin.Context)
ChangeCredentials 修改管理账号和密码(需提供旧密码进行鉴权验证)
func (*AuthHandler) ClearAllBlockedIPs ¶
func (a *AuthHandler) ClearAllBlockedIPs(c *gin.Context)
func (*AuthHandler) GetBlockedIPs ¶
func (a *AuthHandler) GetBlockedIPs(c *gin.Context)
func (*AuthHandler) GetEffectiveCredentials ¶
func (a *AuthHandler) GetEffectiveCredentials(c *gin.Context) (username string, password string)
GetEffectiveCredentials 获取当前生效的账号和密码(优先数据库,兜底环境变量)
func (*AuthHandler) Login ¶
func (a *AuthHandler) Login(c *gin.Context)
func (*AuthHandler) Middleware ¶
func (a *AuthHandler) Middleware() gin.HandlerFunc
func (*AuthHandler) ResetCredentials ¶
func (a *AuthHandler) ResetCredentials(c *gin.Context)
ResetCredentials 重置账号密码回退至环境变量初始值
func (*AuthHandler) Status ¶
func (a *AuthHandler) Status(c *gin.Context)
func (*AuthHandler) UnblockIP ¶
func (a *AuthHandler) UnblockIP(c *gin.Context)
func (*AuthHandler) VerifyJWTToken ¶ added in v1.6.0
func (a *AuthHandler) VerifyJWTToken(tokenString string) (*jwt.MapClaims, bool)
VerifyJWTToken 校验 JWT 并返回 claims
func (*AuthHandler) VerifyToken ¶
func (a *AuthHandler) VerifyToken(tokenString string) bool
type BlockedIPInfo ¶
type CreateTaskRequest ¶ added in v1.1.0
type CreateTaskRequest struct {
TaskID string `json:"task_id,omitempty"`
Title string `json:"title,omitempty"`
Mode string `json:"mode,omitempty"`
Stages model.TaskStages `json:"stages,omitempty"`
Segments []model.Segment `json:"segments,omitempty"`
WaitPolicy *model.WaitPolicy `json:"wait_policy,omitempty"`
}
type LoginRequest ¶
type RateLimitedWriter ¶ added in v1.6.0
type RateLimitedWriter struct {
// contains filtered or unexported fields
}
RateLimitedWriter 实现带上下文感知与平滑分块输出的流式限速器,为核心 SSE 与 API 预留生存带宽
func NewRateLimitedWriter ¶ added in v1.6.0
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶
func NewRateLimiter() *RateLimiter
func (*RateLimiter) CheckLocked ¶
func (rl *RateLimiter) CheckLocked(ip string) (isLocked bool, remaining time.Duration)
CheckLocked 检查该 IP 是否处于封禁锁定期
func (*RateLimiter) Close ¶
func (rl *RateLimiter) Close()
func (*RateLimiter) GetBlockedIPs ¶
func (rl *RateLimiter) GetBlockedIPs() []BlockedIPInfo
GetBlockedIPs 获取当前所有处于封禁状态的 IP 列表
func (*RateLimiter) RecordFailure ¶
func (rl *RateLimiter) RecordFailure(ip string, maxAttempts int, lockoutDuration time.Duration) (isLocked bool, remaining time.Duration)
RecordFailure 记录一次登录失败,若达到阈值则自动封禁
func (*RateLimiter) RecordSuccess ¶
func (rl *RateLimiter) RecordSuccess(ip string)
RecordSuccess 登录成功,清除该 IP 的所有失败记录
type SSEBroker ¶
type SSEBroker struct {
// contains filtered or unexported fields
}
func NewSSEBroker ¶
func NewSSEBroker() *SSEBroker
type SaveWorkflowSheetRequest ¶ added in v1.5.0
type SaveWorkflowSheetRequest struct {
Content string `json:"content"`
}
type SendTaskFeedbackRequest ¶
type SendTaskFeedbackRequest struct {
Body string `json:"body"`
ExpectedRevision int64 `json:"expected_revision"`
Source string `json:"source,omitempty"`
References []model.PathReference `json:"references"`
}
type SubmitFeedbackRequest ¶
type SubmitFeedbackRequest struct {
ResponseText string `json:"response_text"`
UserMessages []string `json:"user_messages"`
Images []model.SessionImage `json:"images"`
}
type TranscribeAudioRequest ¶
type UpdateTaskStagesRequest ¶ added in v1.1.0
type UpdateTaskStagesRequest struct {
ExpectedRevision int64 `json:"expected_revision,omitempty"`
CurrentStageID string `json:"current_stage_id,omitempty"`
Stages model.TaskStages `json:"stages"`
}