Beispiel #1
0
func main() {
	flag.Parse()

	core.PrintVersion()

	if *version {
		return
	}

	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)
	default:
		fmt.Println("Unknown log level: " + *logLevel)
		return
	}

	if len(configFile) == 0 {
		log.Error("Config file is not set.")
		return
	}
	config, err := jsonconf.LoadConfig(configFile)
	if err != nil {
		log.Error("Failed to read config file (%s): %v", configFile, err)
		return
	}

	if config.LogConfig() != nil && len(config.LogConfig().AccessLog()) > 0 {
		log.InitAccessLogger(config.LogConfig().AccessLog())
	}

	vPoint, err := point.NewPoint(config)
	if err != nil {
		log.Error("Failed to create Point server: %v", err)
		return
	}

	err = vPoint.Start()
	if err != nil {
		log.Error("Error starting Point server: %v", err)
		return
	}

	finish := make(chan bool)
	<-finish
}
Beispiel #2
0
func TestDetourConfig(t *testing.T) {
	assert := unit.Assert(t)

	// TODO: fix for Windows
	baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"

	pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_dns_detour.json"))
	assert.Error(err).IsNil()

	detours := pointConfig.InboundDetours()
	assert.Int(len(detours)).Equals(1)

	detour := detours[0]
	assert.String(detour.Protocol()).Equals("dokodemo-door")
	assert.Uint16(detour.PortRange().From()).Equals(uint16(28394))
	assert.Uint16(detour.PortRange().To()).Equals(uint16(28394))
	assert.Pointer(detour.Settings()).IsNotNil()
}
Beispiel #3
0
func TestServerSampleConfig(t *testing.T) {
	assert := unit.Assert(t)

	// TODO: fix for Windows
	baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"

	pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
	assert.Error(err).IsNil()

	assert.Uint16(pointConfig.Port()).Positive()
	assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
	assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()

	assert.String(pointConfig.InboundConfig().Protocol()).Equals("vmess")
	assert.Pointer(pointConfig.InboundConfig().Settings()).IsNotNil()

	assert.String(pointConfig.OutboundConfig().Protocol()).Equals("freedom")
	assert.Pointer(pointConfig.OutboundConfig().Settings()).IsNotNil()
}