forked from fossabot/clash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 860 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
package main
import (
"os"
"os/signal"
"syscall"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/proxy"
"github.com/Dreamacro/clash/tunnel"
log "github.com/sirupsen/logrus"
)
func main() {
cfg, err := C.GetConfig()
if err != nil {
log.Fatalf("Read config error: %s", err.Error())
}
port, socksPort := C.DefalutHTTPPort, C.DefalutSOCKSPort
section := cfg.Section("General")
if key, err := section.GetKey("port"); err == nil {
port = key.Value()
}
if key, err := section.GetKey("socks-port"); err == nil {
socksPort = key.Value()
}
err = tunnel.GetInstance().UpdateConfig()
if err != nil {
log.Fatalf("Parse config error: %s", err.Error())
}
go proxy.NewHttpProxy(port)
go proxy.NewSocksProxy(socksPort)
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
<-sigCh
}