mirror of
https://github.com/nxtrace/nali
synced 2024-11-22 18:34:22 +00:00
fix cdn db download
This commit is contained in:
parent
1e06f9cd61
commit
2fdf1b0b03
@ -12,7 +12,7 @@ func Download(filePath string) (data []byte, err error) {
|
||||
data, err = getData()
|
||||
if err != nil {
|
||||
log.Printf("CDN数据库下载失败,请手动下载解压后保存到本地: %s \n", filePath)
|
||||
log.Println("下载链接: https://cdn.jsdelivr.net/gh/SukkaLab/cdn/dist/cdn.json")
|
||||
log.Println("下载链接:", githubUrl)
|
||||
return
|
||||
}
|
||||
|
||||
@ -23,12 +23,22 @@ func Download(filePath string) (data []byte, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
const (
|
||||
githubUrl = "https://raw.githubusercontent.com/SukkaLab/cdn/master/dist/cdn.json"
|
||||
jsdelivrUrl = "https://cdn.jsdelivr.net/gh/SukkaLab/cdn/dist/cdn.json"
|
||||
)
|
||||
|
||||
func getData() (data []byte, err error) {
|
||||
//resp, err := http.Get("https://raw.githubusercontent.com/SukkaLab/cdn/master/dist/cdn.json")
|
||||
resp, err := http.Get("https://cdn.jsdelivr.net/gh/SukkaLab/cdn/dist/cdn.json")
|
||||
resp, err := http.Get(jsdelivrUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
resp, err = http.Get(githubUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
|
Loading…
Reference in New Issue
Block a user