-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (53 loc) · 1.22 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
DDNS_Run "dnspro/Run"
"dnspro/Run/yamlConfig"
"dnspro/Run/yamlConfig/struct"
"github.com/urfave/cli/v2"
"log"
"os"
"time"
)
func main() {
var pathConfig string
app := &cli.App{
Name: "DDNS Pro",
Version: structConstant.Version,
Compiled: time.Now(),
Authors: []*cli.Author{
&cli.Author{
Name: "xinjiajuan",
Email: "[email protected]",
},
},
Copyright: "(c) 2022 xinjiajuan",
Usage: "多服务商动态 IP 地址解析",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
//Value: "config.yaml",
Usage: "指定YAML配置文件路径",
Aliases: []string{"c"},
Required: true,
Destination: &pathConfig,
},
},
Action: func(cCtx *cli.Context) error {
//判断文件夹是否存在
_, err := os.Stat(cCtx.String("config")) //os.Stat获取文件信息
if err != nil {
return cli.Exit("配置文件不存在!", 86)
} else {
config := yamlconfig_ddnspro.ReadYamlConfig(cCtx.String("config"))
for i, domain := range yamlconfig_ddnspro.CreateDomainList(config) {
go DDNS_Run.RunTicker(i, domain)
}
select {}
}
return nil
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}