Example #1
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()
	}
}
func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	if obfs4proxy.Check() {
		obfs4proxy.Run(obfs4proxy.Config{
			LogLevel:      "INFO",
			EnableLogging: true,
			UnsafeLogging: false,
		})
		os.Exit(0)
	}

	// server := ptc.Server{
	// 	Config: ptc.Config{
	// 		StateLocation: ".",
	// 		Command:       os.Args[0],
	// 	},
	// 	ORPort: "127.0.0.1:23450",
	// 	Methods: []ptc.SMethod{ptc.SMethod{
	// 		MethodName: "obfs4",
	// 		BindAddr:   "127.0.0.1:4423",
	// 		Args: ptc.Args{
	// 			"node-id":     []string{"4d3e4561149907025571827a1277661b5f9fca46"},
	// 			"private-key": []string{"7886017adfd178cd139e91250dddee0b2af8ab6cf93f1fe9a7a469d3a13a3067"},
	// 			"public-key":  []string{"4393d7641042620a60881a72ebb47ef8c5a5840acb4f858e5c0026cb2e75fd6f"},
	// 			"drbg-seed":   []string{"c23e876ddc408cc392317e017a6796a96161f76d8dd90522"},
	// 			"iat-mode":    []string{"0"},
	// 		},
	// 	},
	// 	},
	// }

	configdir := os.Getenv("ALKASIR_TORPT_CONFIGDIR")
	configfile := filepath.Join(configdir, "alkasir-torpt-server.json")

	data, err := ioutil.ReadFile(configfile)
	if err != nil {
		panic(err)
	}

	server := ptc.Server{}
	err = json.Unmarshal(data, &server)
	if err != nil {
		panic(err)
	}
	server.Command = os.Args[0]

	go socks5server(server.ORPort)

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

	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()
		err := server.Wait()
		if err != nil {
			log.Println(err)
		}
	}()
	wg.Wait()

}
Example #3
0
func main() {

	lg.SetSrcHighlight("alkasir/cmd", "alkasir/pkg")
	lg.CopyStandardLogTo("INFO")
	lg.V(1).Info("Log v-level:", lg.Verbosity())
	lg.V(1).Info("Active country codes:", shared.CountryCodes)
	lg.Flush()

	if obfs4proxy.Check() {
		monitorBindAddr := flag.String("monitorAddr", "localhost:8037", "port to bind monitor server to")
		flag.Parse()
		go startMonitoring(*monitorBindAddr)

		obfs4proxy.Run(obfs4proxy.Config{
			LogLevel:      "INFO",
			EnableLogging: true,
			UnsafeLogging: false,
		})
		os.Exit(0)
	}

	monitorBindAddr := flag.String("monitorAddr", "localhost:8036", "port to bind monitor server to")
	flag.Parse()
	go startMonitoring(*monitorBindAddr)

	// server := ptc.Server{
	// 	Config: ptc.Config{
	// 		StateLocation: ".",
	// 		Command:       os.Args[0],
	// 	},
	// 	ORPort: "127.0.0.1:23450",
	// 	Methods: []ptc.SMethod{ptc.SMethod{
	// 		MethodName: "obfs4",
	// 		BindAddr:   "127.0.0.1:4423",
	// 		Args: ptc.Args{
	// 			"node-id":     []string{"4d3e4561149907025571827a1277661b5f9fca46"},
	// 			"private-key": []string{"7886017adfd178cd139e91250dddee0b2af8ab6cf93f1fe9a7a469d3a13a3067"},
	// 			"public-key":  []string{"4393d7641042620a60881a72ebb47ef8c5a5840acb4f858e5c0026cb2e75fd6f"},
	// 			"drbg-seed":   []string{"c23e876ddc408cc392317e017a6796a96161f76d8dd90522"},
	// 			"iat-mode":    []string{"0"},
	// 		},
	// 	},
	// 	},
	// }

	configdir := os.Getenv("ALKASIR_TORPT_CONFIGDIR")
	configfile := filepath.Join(configdir, "alkasir-torpt-server.json")

	data, err := ioutil.ReadFile(configfile)
	if err != nil {
		panic(err)
	}

	server := ptc.Server{}
	err = json.Unmarshal(data, &server)
	if err != nil {
		panic(err)
	}
	server.Command = os.Args[0]

	go socks5server(server.ORPort)

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

	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()
		err := server.Wait()
		if err != nil {
			log.Println(err)
		}
	}()
	wg.Wait()

}