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
c78d114767
commit
d33377087f
3 changed files with 24 additions and 26 deletions
|
|
@ -1,44 +1,38 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"ghproxy/config"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Blacklist []string `json:"blacklist"`
|
||||
}
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
configfile = "/data/ghproxy/config/config.yaml"
|
||||
blacklist *config.Blist
|
||||
cfg *config.Config
|
||||
configfile = "/data/ghproxy/config/config.yaml"
|
||||
blacklistfile = "/data/ghproxy/config/blacklist.json"
|
||||
blacklist *Config
|
||||
)
|
||||
|
||||
func init() {
|
||||
loadBlacklistConfig()
|
||||
}
|
||||
blacklist = &Config{}
|
||||
|
||||
func loadConfig() {
|
||||
var err error
|
||||
// 初始化配置
|
||||
cfg, err = config.LoadConfig(configfile)
|
||||
data, err := os.ReadFile(blacklistfile)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load config: %v", err)
|
||||
logw("Failed to read blacklist file: %v", err)
|
||||
}
|
||||
fmt.Printf("Loaded config: %v\n", cfg)
|
||||
}
|
||||
|
||||
func loadBlacklistConfig() {
|
||||
var err error
|
||||
// 初始化黑名单配置
|
||||
blacklist, err = config.LoadBlacklistConfig(cfg.Blacklist.BlacklistFile)
|
||||
err = json.Unmarshal(data, blacklist)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load blacklist: %v", err)
|
||||
logw("Failed to unmarshal blacklist JSON: %v", err)
|
||||
}
|
||||
logw("Loaded blacklist: %v", blacklist)
|
||||
}
|
||||
|
||||
func CheckBlacklist(fullrepo string) bool {
|
||||
forRangeCheck(blacklist.Blacklist, fullrepo)
|
||||
return false
|
||||
return forRangeCheck(blacklist.Blacklist, fullrepo)
|
||||
}
|
||||
|
||||
func forRangeCheck(blist []string, fullrepo string) bool {
|
||||
|
|
|
|||
8
config/blacklist.json
Normal file
8
config/blacklist.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"blacklist": [
|
||||
"test/test1",
|
||||
"example/repo2",
|
||||
"another/repo3"
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
blacklist:
|
||||
- test/test1
|
||||
- example/repo2
|
||||
- another/repo3
|
||||
Loading…
Add table
Add a link
Reference in a new issue