fix 自定义域名验证逻辑
This commit is contained in:
@@ -41,8 +41,8 @@ func main() {
|
|||||||
|
|
||||||
// 初始化用户
|
// 初始化用户
|
||||||
r.POST("/1/users/init", router.Handleinit)
|
r.POST("/1/users/init", router.Handleinit)
|
||||||
r.Any("/v1/chat/completions", router.HandleProy)
|
r.POST("/v1/chat/completions", router.HandleProy)
|
||||||
r.Any("/", router.HandleProy)
|
r.GET("/v1/models", router.HandleProy)
|
||||||
|
|
||||||
r.Run(":80")
|
r.Run(":80")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,15 +231,14 @@ func GenerateToken() string {
|
|||||||
func HandleProy(c *gin.Context) {
|
func HandleProy(c *gin.Context) {
|
||||||
var localuser bool
|
var localuser bool
|
||||||
auth := c.Request.Header.Get("Authorization")
|
auth := c.Request.Header.Get("Authorization")
|
||||||
if auth[:7] == "Bearer " {
|
if len(auth) > 7 && auth[:7] == "Bearer " {
|
||||||
if len(auth[7:]) < 1 {
|
if len(auth[7:]) < 1 {
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
|
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !store.IsExistAuthCache(auth[7:]) {
|
if store.IsExistAuthCache(auth[7:]) {
|
||||||
localuser = false
|
localuser = true
|
||||||
}
|
}
|
||||||
localuser = true
|
|
||||||
}
|
}
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
|
|||||||
Reference in New Issue
Block a user