main.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. import (
  3. "forward-core/Utils"
  4. "github.com/astaxie/beego"
  5. "github.com/astaxie/beego/logs"
  6. )
  7. func main() {
  8. logs.SetLogger(logs.AdapterConsole, `{"level":7}`)
  9. logs.SetLogger(logs.AdapterFile, `{"filename":"app.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10}`)
  10. //输出文件名和行号
  11. logs.EnableFuncCallDepth(true)
  12. logs.SetLogFuncCallDepth(3)
  13. //为了让日志输出不影响性能,开启异步日志
  14. logs.Async()
  15. //远端外网服务
  16. magicServerAddr := beego.AppConfig.String("magic.server")
  17. logs.Debug("★★★★★★★★★★★★★★★★★★★★")
  18. logs.Debug(" tcp-forward 启动")
  19. logs.Debug("")
  20. logs.Debug("项目地址:https://github.com/tavenli/port-forward")
  21. logs.Debug("")
  22. logs.Debug("请求远端控制服务器:", magicServerAddr)
  23. logs.Debug("")
  24. logs.Debug("★★★★★★★★★★★★★★★★★★★★")
  25. if Utils.IsEmpty(magicServerAddr){
  26. magicServerAddr = "forward.apiclub.top:7000"
  27. }
  28. agentService := new(AgentServiceV1)
  29. agentService.MagicServerAddr = magicServerAddr
  30. agentService.AgentOnline = false
  31. go agentService.ConnToMagicServer()
  32. go agentService.ConnectToMagicLoop()
  33. select {
  34. }
  35. }
粤ICP备19079148号