-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (39 loc) · 961 Bytes
/
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
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/tech-thinker/telepath/cmd"
"github.com/tech-thinker/telepath/config"
"github.com/tech-thinker/telepath/constants"
"github.com/tech-thinker/telepath/daemon"
"github.com/tech-thinker/telepath/handler"
"github.com/urfave/cli/v2"
)
var (
AppVersion = "v0.0.0"
CommitHash = "unknown"
BuildDate = "unknown"
)
func main() {
cfg := config.InitConfig()
handler := handler.NewHandler(cfg)
pidFilePath := filepath.Join(cfg.ConfigDir(), constants.PID_FILE)
socketPath := filepath.Join(cfg.ConfigDir(), constants.SOCKET_FILE)
daemonMgr := daemon.NewDaemonMgr(pidFilePath, socketPath, handler)
appCmd := cmd.NewApp(daemonMgr)
app := &cli.App{
Name: "telepath",
Version: AppVersion,
Commands: []*cli.Command{
appCmd.Daemon(),
appCmd.Crediential(),
appCmd.Host(),
appCmd.Tunnel(),
},
}
if err := app.Run(os.Args); err != nil {
fmt.Println(err)
os.Exit(1)
}
}