1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00
nali/cmd/update.go

55 lines
1.2 KiB
Go
Raw Normal View History

2020-07-17 12:12:04 +08:00
package cmd
import (
"log"
"path/filepath"
2021-08-02 12:01:25 +08:00
"github.com/zu1k/nali/internal/constant"
2020-07-22 07:25:01 +08:00
"github.com/zu1k/nali/pkg/cdn"
"github.com/zu1k/nali/pkg/zxipv6wry"
2020-07-17 13:49:11 +08:00
"github.com/zu1k/nali/pkg/qqwry"
2020-07-17 12:12:04 +08:00
"github.com/spf13/cobra"
)
// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "update chunzhen ip database",
Long: `update chunzhen ip database`,
Run: func(cmd *cobra.Command, args []string) {
2020-07-22 07:25:01 +08:00
// Chunzhen ipv4
2020-07-17 12:12:04 +08:00
filePath := filepath.Join(constant.HomePath, "qqwry.dat")
2020-07-22 07:25:01 +08:00
log.Println("正在下载最新 纯真 IPv4数据库...")
_, err := qqwry.Download(filePath)
2020-07-17 12:12:04 +08:00
if err != nil {
log.Fatalln("下载失败", err.Error())
return
}
2020-07-22 07:25:01 +08:00
// ZX ipv6
2021-08-02 12:01:25 +08:00
filePath = filepath.Join(constant.HomePath, "ipv6wry.database")
2020-07-22 07:25:01 +08:00
log.Println("正在下载最新 ZX IPv6数据库...")
_, err = zxipv6wry.Download(filePath)
if err != nil {
log.Fatalln("下载失败", err.Error())
return
2020-07-17 12:12:04 +08:00
}
2020-07-22 07:25:01 +08:00
// cdn
filePath = filepath.Join(constant.HomePath, "cdn.json")
log.Println("正在下载最新 CDN服务提供商数据库...")
_, err = cdn.Download(filePath)
if err != nil {
log.Fatalln("下载失败", err.Error())
return
2020-07-17 12:12:04 +08:00
}
},
}
func init() {
rootCmd.AddCommand(updateCmd)
}