mihomo/main.go

44 lines
906 B
Go
Raw Normal View History

2018-06-10 22:50:03 +08:00
package main
import (
"os"
"os/signal"
"syscall"
C "github.com/Dreamacro/clash/constant"
2018-06-14 01:00:58 +08:00
"github.com/Dreamacro/clash/proxy/http"
"github.com/Dreamacro/clash/proxy/socks"
2018-06-10 22:50:03 +08:00
"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())
}
2018-06-14 01:00:58 +08:00
go http.NewHttpProxy(port)
go socks.NewSocksProxy(socksPort)
2018-06-10 22:50:03 +08:00
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
<-sigCh
}