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