Пример #1
0
func main() {
	flag.Parse()
	server.AddChecker(socks5.Check)
	server.AddChecker(shadowsocks.Check)
	server.AddChecker(torpt.Check)
	server.RunService()
}
Пример #2
0
func TestServiceClientFail(t *testing.T) {
	if os.Getenv("ALKASIR_SERVICE") == "transport" {
		failToStart = false
		server.AddChecker(MockTransportCheck)
		if !server.CheckServiceEnv() {
			lg.Infoln("error no support")
		}
		server.RunService()
		return
	}
	service.UpdateConnections(testConnections)
	service.UpdateTransports(testTransports)
	service.Arg = "-test.run=TestServiceClientFail"

	connection := shared.Connection{
		Transport: "socks5",
	}
	connection1Proxy, err := service.NewTransportService(connection)
	if err != nil {
		t.Fatalf("could not start %v", err)
	}

	err = connection1Proxy.Start()
	if err != nil {
		panic(err)
	}

	if err != nil {
		t.Fatalf("process ran with err %v, want exit status 0", err)
	}
}
Пример #3
0
func main() {
	rand.Seed(time.Now().UnixNano())

	var errors []error
	errors = append(errors,
		flag.Set("logtomemory", "true"),
	)

	// set more flag defaults if debug is not enabled
	if os.Getenv("ALKASIR_DEBUG") == "" {
		errors = append(errors,
			flag.Set("logtofile", "false"),
			flag.Set("v", "19"),
		)
	}
	for _, err := range errors {
		if err != nil {
			panic(err)
		}
	}

	flag.Parse()
	flagenv.Prefix = "ALKASIR_"
	flagenv.Parse()

	server.AddChecker(torpt.Check)
	server.AddChecker(shadowsocks.Check)

	if server.CheckServiceEnv() {
		torpt.SetConfigDir(client.ConfigPath("torpt"))
		server.RunService()
	} else if obfs4proxy.Check() {
		obfs4proxy.Run(obfs4proxy.Config{})
	} else {
		ui.Set(wm.New())
		client.SetUpgradeArtifact("alkasir-gui")
		client.Run()
	}
}
Пример #4
0
func TestServerFail(t *testing.T) {
	if os.Getenv("__TEST_SUBCMD") == "1" {
		server.AddChecker(MockTransportCheck)
		failToStart = true
		if !server.CheckServiceEnv() {
			lg.Infoln("error no support")
		}
		server.RunService()
		return
	}
	cmd := exec.Command(os.Args[0], "-test.run=TestServerFail")
	env := append(os.Environ(), "__TEST_SUBCMD=1")
	cmd.Env = env
	// cmd.Stdout = os.Stdout
	err := cmd.Run()
	if e, ok := err.(*exec.ExitError); ok && !e.Success() {
		return
	}
	t.Fatalf("process ran with err %v, want exit status 1", err)
}
Пример #5
0
func TestServerSuccess(t *testing.T) {
	if os.Getenv("__TEST_SUBCMD") == "1" {
		failToStart = false
		server.AddChecker(MockTransportCheck)
		if !server.CheckServiceEnv() {
			lg.Infoln("error no support")
		}
		server.RunService()
		return
	}
	cmd := exec.Command(os.Args[0], "-test.run=TestServerSuccess")
	env := append(os.Environ(), "__TEST_SUBCMD=1")
	env = append(env, "ALKASIR_SERVICE=transport")
	env = append(env, "ALKASIR_TRANSPORT=socks5")
	cmd.Env = env
	// cmd.Stdout = os.Stdout
	err := cmd.Run()
	if err != nil {
		t.Fatalf("process ran with err %v, want exit status 0", err)
	}
}