mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
fix
This commit is contained in:
parent
862b92a1c5
commit
eec50879e9
2 changed files with 7 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ type Config struct {
|
|||
}
|
||||
|
||||
type Blacklist struct {
|
||||
Blacklist map[string][]string `yaml:"blacklist"`
|
||||
Blist map[string][]string `yaml:"blacklist"`
|
||||
}
|
||||
|
||||
// LoadConfig 从 YAML 配置文件加载配置
|
||||
|
|
@ -48,11 +48,11 @@ func LoadConfig(filePath string) (*Config, error) {
|
|||
|
||||
// LoadBlacklistConfig 从 YAML 配置文件加载黑名单配置
|
||||
func LoadBlacklistConfig(filePath string) (*Blacklist, error) {
|
||||
var config Blacklist
|
||||
if err := loadYAML(filePath, &config); err != nil {
|
||||
var blacklist Blacklist
|
||||
if err := loadYAML(filePath, &blacklist); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &config, nil
|
||||
return &blacklist, nil
|
||||
}
|
||||
|
||||
// LoadyamlConfig 从 YAML 配置文件加载配置
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ func NoRouteHandler(cfg *config.Config, blacklist *config.Blacklist) gin.Handler
|
|||
repo := pathParts[2]
|
||||
logw("Blacklist Check > Username: %s, Repo: %s", username, repo)
|
||||
|
||||
if blacklist.Blacklist == nil {
|
||||
if blacklist.Blist == nil {
|
||||
logw("Warning: Blacklist map is nil")
|
||||
// 根据需要初始化或处理
|
||||
blacklist.Blacklist = make(map[string][]string)
|
||||
blacklist.Blist = make(map[string][]string)
|
||||
}
|
||||
|
||||
// 检查仓库是否在黑名单中
|
||||
if auth.IsBlacklisted(username, repo, blacklist.Blacklist, cfg.Blacklist.Enabled) {
|
||||
if auth.IsBlacklisted(username, repo, blacklist.Blist, cfg.Blacklist.Enabled) {
|
||||
c.String(http.StatusForbidden, "Access denied: repository is blacklisted.")
|
||||
logw("Blacklisted repository: %s/%s", username, repo)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue