64 lines
1.5 KiB
Go
Raw Normal View History

2015-09-12 11:51:42 +02:00
package main
2015-09-12 20:36:21 +02:00
import (
"flag"
2015-09-18 11:59:36 +02:00
"fmt"
2015-09-12 20:36:21 +02:00
"github.com/v2ray/v2ray-core"
jsonconf "github.com/v2ray/v2ray-core/io/config/json"
2015-09-12 20:36:21 +02:00
"github.com/v2ray/v2ray-core/log"
2015-09-13 20:01:50 +02:00
// The following are neccesary as they register handlers in their init functions.
2015-09-12 20:36:21 +02: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 22:11:54 +02:00
configFile = flag.String("config", "", "Config file for this Point server.")
2015-09-16 00:06:22 +02:00
logLevel = flag.String("loglevel", "", "Level of log info to be printed to console, available value: debug, info, warning, error")
2015-09-18 11:59:36 +02:00
version = flag.Bool("version", false, "Show current version of V2Ray.")
2015-09-12 20:36:21 +02:00
)
2015-09-12 11:51:42 +02:00
func main() {
2015-09-12 20:36:21 +02:00
flag.Parse()
2015-09-16 00:06:22 +02:00
2015-09-18 11:59:36 +02:00
if *version {
fmt.Printf("V2Ray version %s (%s): %s", core.Version, core.Codename, core.Intro)
fmt.Println()
return
}
2015-09-16 00:06:22 +02: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 20:36:21 +02:00
if configFile == nil || len(*configFile) == 0 {
panic(log.Error("Config file is not set."))
}
config, err := jsonconf.LoadConfig(*configFile)
2015-09-12 20:36:21 +02:00
if err != nil {
panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
}
vPoint, err := core.NewPoint(config)
2015-09-12 20:36:21 +02:00
if err != nil {
2015-09-12 22:11:54 +02:00
panic(log.Error("Failed to create Point server: %v", err))
2015-09-12 20:36:21 +02:00
}
err = vPoint.Start()
if err != nil {
2015-09-12 22:11:54 +02:00
log.Error("Error starting Point server: %v", err)
2015-09-12 20:36:21 +02:00
}
2015-09-12 11:51:42 +02:00
2015-09-12 20:36:21 +02:00
finish := make(chan bool)
<-finish
2015-09-12 11:51:42 +02:00
}