forked from fossabot/clash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (41 loc) · 884 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
47
48
49
50
package main
import (
"flag"
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/Dreamacro/clash/config"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/hub"
"github.com/Dreamacro/clash/proxy"
"github.com/Dreamacro/clash/tunnel"
log "github.com/sirupsen/logrus"
)
var (
homedir string
)
func init() {
flag.StringVar(&homedir, "d", "", "set configuration directory")
flag.Parse()
}
func main() {
tunnel.Instance().Run()
proxy.Instance().Run()
hub.Run()
if homedir != "" {
if !filepath.IsAbs(homedir) {
currentDir, _ := os.Getwd()
homedir = filepath.Join(currentDir, homedir)
}
C.SetHomeDir(homedir)
}
config.Init()
err := config.Instance().Parse()
if err != nil {
log.Fatalf("Parse config error: %s", err.Error())
}
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
<-sigCh
}