main.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package main
  2. import (
  3. "flag"
  4. "io/ioutil"
  5. "path"
  6. "github.com/v2ray/v2ray-core"
  7. "github.com/v2ray/v2ray-core/log"
  8. _ "github.com/v2ray/v2ray-core/net/freedom"
  9. _ "github.com/v2ray/v2ray-core/net/socks"
  10. _ "github.com/v2ray/v2ray-core/net/vmess"
  11. )
  12. var (
  13. configFile = flag.String("config", "", "Config file for this Point server.")
  14. )
  15. func main() {
  16. flag.Parse()
  17. log.SetLogLevel(log.DebugLevel)
  18. if configFile == nil || len(*configFile) == 0 {
  19. panic(log.Error("Config file is not set."))
  20. }
  21. rawVConfig, err := ioutil.ReadFile(*configFile)
  22. if err != nil {
  23. panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
  24. }
  25. vconfig, err := core.LoadConfig(rawVConfig)
  26. if err != nil {
  27. panic(log.Error("Failed to parse Config: %v", err))
  28. }
  29. if !path.IsAbs(vconfig.InboundConfig.File) && len(vconfig.InboundConfig.File) > 0 {
  30. vconfig.InboundConfig.File = path.Join(path.Dir(*configFile), vconfig.InboundConfig.File)
  31. }
  32. if !path.IsAbs(vconfig.OutboundConfig.File) && len(vconfig.OutboundConfig.File) > 0 {
  33. vconfig.OutboundConfig.File = path.Join(path.Dir(*configFile), vconfig.OutboundConfig.File)
  34. }
  35. vPoint, err := core.NewPoint(vconfig)
  36. if err != nil {
  37. panic(log.Error("Failed to create Point server: %v", err))
  38. }
  39. err = vPoint.Start()
  40. if err != nil {
  41. log.Error("Error starting Point server: %v", err)
  42. }
  43. finish := make(chan bool)
  44. <-finish
  45. }