Files
HY2XS_flamy/apps/controller/hysteria2.go
T

43 lines
1.0 KiB
Go

package controller
import (
"github.com/gin-gonic/gin"
"hy2xs-admin/model/dto"
"hy2xs-admin/model/vo"
"hy2xs-admin/service"
"time"
)
func Hysteria2Auth(c *gin.Context) {
var req dto.Hysteria2AuthDto
if err := c.ShouldBindJSON(&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 {
vo.Fail(err.Error(), c)
return
}
vo.Hysteria2AuthSuccess(username, c)
}
func Hysteria2ChangeVersion(c *gin.Context) {
vo.Fail("Смена версии Hysteria2 отключена: runtime управляется install-оркестратором HY2XS", c)
}
func ListRelease(c *gin.Context) {
vo.Success([]string{}, c)
}