forked from Licoy/fetch-github-hosts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (42 loc) · 1.05 KB
/
Copy pathmain.go
File metadata and controls
48 lines (42 loc) · 1.05 KB
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
package main
import (
"embed"
"fmt"
"github.com/getlantern/elevate"
"os"
"runtime"
)
//go:embed assets
var assetsFs embed.FS
var _cliLog = &FetchLog{w: os.Stdout}
func main() {
args := ParseBootArgs()
if !args.DontEscalate && !args.Escalate && runtime.GOOS != Linux {
cmd := elevate.Command(os.Args[0], "--escalate")
cmd.Run()
os.Exit(0)
}
isGui := args.Mode == ""
if isGui {
bootGui()
} else {
bootCli(args)
}
}
func bootCli(args *CmdArgs) {
if !IsDebug() {
if err := GetCheckPermissionResult(); err != nil {
_cliLog.Print(err.Error())
return
}
}
_cliLog.Print(fmt.Sprintf("开始程序监听,当前以%d分钟更新一次Github-Hosts!", args.FetchInterval))
_cliLog.Print("请不要关闭此窗口以保持再前台运行")
_cliLog.Print("可以将此程序注册为服务,具体请参考项目说明:https://github.com/Licoy/fetch-github-hosts")
ticker := NewFetchTicker(args.FetchInterval)
if args.Mode == "server" {
startServer(ticker, args.Port, _cliLog)
} else {
startClient(ticker, args.Url, _cliLog)
}
}