Sync OpenVPN OAuth gateway routes on tunnel changes

This commit is contained in:
opsx committed 2026-10-22 19:50:24 +08:00
1 parent 9e26358df0
commit ff2db503ab
6 files changed
+106 -9

No files matched your search

+14 -5
View File
@@ -121,6 +121,9 @@ func (s *Server) executeBatchAction(action taskmgr.TaskAction, tunnelID uint, us
t.LastError = ""
store.DB.Save(&t)
store.Audit(username, "batch_start", t.Name, "")
if err := s.syncAuthGatewayForTunnel(&t); err != nil {
return fmt.Errorf("专线已启动,但公网认证入口同步失败: %w", err)
}
case taskmgr.ActionStop:
p, err := s.mgr.Get(t.Protocol)
@@ -136,6 +139,9 @@ func (s *Server) executeBatchAction(action taskmgr.TaskAction, tunnelID uint, us
t.State = "stopped"
store.DB.Save(&t)
store.Audit(username, "batch_stop", t.Name, "")
if err := s.syncAuthGatewayForTunnel(&t); err != nil {
return fmt.Errorf("专线已停止,但公网认证入口同步失败: %w", err)
}
case taskmgr.ActionDelete:
if p, err := s.mgr.Get(t.Protocol); err == nil {
@@ -147,6 +153,9 @@ func (s *Server) executeBatchAction(action taskmgr.TaskAction, tunnelID uint, us
s.mgr.RemoveStatus(t.ID)
store.DB.Delete(&t)
store.Audit(username, "batch_delete", t.Name, "")
if err := s.syncAuthGatewayForTunnel(&t); err != nil {
return fmt.Errorf("专线已删除,但公网认证入口同步失败: %w", err)
}
}
return nil
@@ -185,11 +194,11 @@ func parseTunnelIDs(c *gin.Context) ([]uint, error) {
// batchTrafficPolicy 批量设置流量策略
type batchPolicyRequest struct {
TunnelIDs []uint `json:"tunnel_ids" binding:"required,min=1"`
RateLimitMbps int `json:"rate_limit_mbps"`
QuotaBytes int64 `json:"quota_bytes"`
ActionOnExceed string `json:"action_on_exceed"`
ResetCycle string `json:"reset_cycle"`
TunnelIDs []uint `json:"tunnel_ids" binding:"required,min=1"`
RateLimitMbps int `json:"rate_limit_mbps"`
QuotaBytes int64 `json:"quota_bytes"`
ActionOnExceed string `json:"action_on_exceed"`
ResetCycle string `json:"reset_cycle"`
}
func (s *Server) batchSetPolicy(c *gin.Context) {