mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
24w09a
This commit is contained in:
parent
999016be2b
commit
815b86c6c6
5 changed files with 11 additions and 33 deletions
|
|
@ -19,9 +19,6 @@ import (
|
|||
|
||||
var logw = logger.Logw
|
||||
|
||||
//var cfg *config.Config
|
||||
//var blacklist *config.Blacklist
|
||||
|
||||
var exps = []*regexp.Regexp{
|
||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:releases|archive)/.*`),
|
||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:blob|raw)/.*`),
|
||||
|
|
@ -30,7 +27,7 @@ var exps = []*regexp.Regexp{
|
|||
regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/.+?/.+`),
|
||||
}
|
||||
|
||||
func NoRouteHandler(cfg *config.Config, blist *config.Blist) gin.HandlerFunc {
|
||||
func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
rawPath := strings.TrimPrefix(c.Request.URL.RequestURI(), "/")
|
||||
re := regexp.MustCompile(`^(http:|https:)?/?/?(.*)`)
|
||||
|
|
@ -62,11 +59,9 @@ func NoRouteHandler(cfg *config.Config, blist *config.Blist) gin.HandlerFunc {
|
|||
// 黑名单检查
|
||||
blacklistpass := auth.CheckBlacklist(fullrepo)
|
||||
if blacklistpass {
|
||||
c.AbortWithStatusJSON(404, gin.H{"error": "Not found"})
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
logw("Blacklisted repo: %s", fullrepo)
|
||||
return
|
||||
} else {
|
||||
logw("Not blacklisted: %s", fullrepo)
|
||||
}
|
||||
|
||||
matches = CheckURL(rawPath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue