1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00
v2fly/release/server/main.go

65 lines
1.5 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"
2015-09-18 05:59:36 -04:00
"fmt"
2015-09-12 14:36:21 -04:00
"github.com/v2ray/v2ray-core"
2015-09-19 18:50:21 -04:00
"github.com/v2ray/v2ray-core/common/log"
jsonconf "github.com/v2ray/v2ray-core/config/json"
2015-09-12 14:36:21 -04:00
2015-09-13 14:01:50 -04:00
// The following are neccesary as they register handlers in their init functions.
_ "github.com/v2ray/v2ray-core/proxy/freedom"
_ "github.com/v2ray/v2ray-core/proxy/socks"
_ "github.com/v2ray/v2ray-core/proxy/vmess"
2015-09-12 14:36:21 -04:00
)
var (
2015-09-12 16:11:54 -04:00
configFile = flag.String("config", "", "Config file for this Point server.")
2015-09-15 18:06:22 -04:00
logLevel = flag.String("loglevel", "", "Level of log info to be printed to console, available value: debug, info, warning, error")
2015-09-18 05:59:36 -04:00
version = flag.Bool("version", false, "Show current version of V2Ray.")
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()
2015-09-15 18:06:22 -04:00
2015-09-18 05:59:36 -04:00
if *version {
2015-09-29 05:52:34 -04:00
fmt.Printf("V2Ray %s (%s) %s", core.Version(), core.Codename, core.Build())
2015-09-18 05:59:36 -04:00
fmt.Println()
2015-09-29 05:52:34 -04:00
fmt.Println(core.Intro)
2015-09-18 05:59:36 -04:00
return
}
2015-09-15 18:06:22 -04:00
switch *logLevel {
case "debug":
log.SetLogLevel(log.DebugLevel)
case "info":
log.SetLogLevel(log.InfoLevel)
case "warning":
log.SetLogLevel(log.WarningLevel)
case "error":
log.SetLogLevel(log.ErrorLevel)
}
2015-09-12 14:36:21 -04:00
if configFile == nil || len(*configFile) == 0 {
panic(log.Error("Config file is not set."))
}
2015-09-19 09:35:20 -04:00
config, err := jsonconf.LoadConfig(*configFile)
2015-09-12 14:36:21 -04:00
if err != nil {
panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
}
vPoint, err := core.NewPoint(config)
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
}