1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/release/server/main.go

59 lines
1.4 KiB
Go
Raw Normal View History

2015-09-12 05:51:42 -04:00
package main
2015-09-12 14:36:21 -04:00
import (
"flag"
"io/ioutil"
"path"
"github.com/v2ray/v2ray-core"
"github.com/v2ray/v2ray-core/log"
2015-09-12 18:14:14 -04:00
// The following are neccesary as they register handlers in their init functions.
2015-09-12 14:36:21 -04:00
_ "github.com/v2ray/v2ray-core/net/freedom"
_ "github.com/v2ray/v2ray-core/net/socks"
_ "github.com/v2ray/v2ray-core/net/vmess"
)
var (
2015-09-12 16:11:54 -04:00
configFile = flag.String("config", "", "Config file for this Point server.")
2015-09-12 14:36:21 -04:00
)
2015-09-12 05:51:42 -04:00
func main() {
2015-09-12 14:36:21 -04:00
flag.Parse()
log.SetLogLevel(log.DebugLevel)
if configFile == nil || len(*configFile) == 0 {
panic(log.Error("Config file is not set."))
}
rawVConfig, err := ioutil.ReadFile(*configFile)
if err != nil {
panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
}
2015-09-12 16:11:54 -04:00
vconfig, err := core.LoadConfig(rawVConfig)
2015-09-12 14:36:21 -04:00
if err != nil {
2015-09-12 16:11:54 -04:00
panic(log.Error("Failed to parse Config: %v", err))
2015-09-12 14:36:21 -04:00
}
if !path.IsAbs(vconfig.InboundConfig.File) && len(vconfig.InboundConfig.File) > 0 {
vconfig.InboundConfig.File = path.Join(path.Dir(*configFile), vconfig.InboundConfig.File)
}
if !path.IsAbs(vconfig.OutboundConfig.File) && len(vconfig.OutboundConfig.File) > 0 {
vconfig.OutboundConfig.File = path.Join(path.Dir(*configFile), vconfig.OutboundConfig.File)
}
2015-09-12 16:11:54 -04:00
vPoint, err := core.NewPoint(vconfig)
2015-09-12 14:36:21 -04:00
if err != nil {
2015-09-12 16:11:54 -04:00
panic(log.Error("Failed to create Point server: %v", err))
2015-09-12 14:36:21 -04:00
}
err = vPoint.Start()
if err != nil {
2015-09-12 16:11:54 -04:00
log.Error("Error starting Point server: %v", err)
2015-09-12 14:36:21 -04:00
}
2015-09-12 05:51:42 -04:00
2015-09-12 14:36:21 -04:00
finish := make(chan bool)
<-finish
2015-09-12 05:51:42 -04:00
}