package controller import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "hy2xs-admin/model/dto" "hy2xs-admin/model/vo" "hy2xs-admin/service" "time" ) func Hysteria2Auth(c *gin.Context) { var req dto.Hysteria2AuthDto if err := strictBindJSON(c, &req); err != nil { vo.Hysteria2AuthBadRequest(c) return } if req.Addr == nil || req.Auth == nil || req.Tx == nil { vo.Hysteria2AuthBadRequest(c) return } id, username, err := service.Hysteria2Auth(*req.Auth) if err != nil || username == "" { vo.Hysteria2AuthFail("", c) return } // Обновление времени последнего подключения now := time.Now().UnixMilli() if err = service.UpdatePeerLastConnectionAt(id, now); err != nil { logrus.WithError(err).Warnf("failed to update peer last_connection_at: peer_id=%d", id) } vo.Hysteria2AuthSuccess(username, c) }