示例#1
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Int("vv", 0, "vv")
	var fs = flag.NewFlagSet("deblocus", flag.ErrorHandling(0xffff))
	var null, _ = os.Open(os.DevNull)
	defer null.Close()
	fs.SetOutput(null)
	var v int
	fs.IntVar(&v, "vv", 0, "log verbose")
	var deblocusArgs []string
	deblocusArgs = append(deblocusArgs, os.Args[1:]...)
	fs.Parse(deblocusArgs)

	log.SetLogOutput("")
	log.SetLogVerbose(v)
	cltAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	svrAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	dstAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	fmt.Println("=== deblocus TEST ===")
	printArgLine("logV", v)
	printArgLine("cltAddr", cltAddr)
	printArgLine("svrAddr", svrAddr)
	printArgLine("dstAddr", dstAddr)
	fmt.Println("\n")
}
示例#2
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	v := initAddonArgs(0)
	log.SetLogOutput("")
	log.SetLogVerbose(v)
	cltAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	svrAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	dstAddr += strconv.FormatInt(randomRange(1, 1<<13)+3e4, 10)
	fmt.Println("=== deblocus TEST ===")
	printArgLine("logV", v)
	printArgLine("cltAddr", cltAddr)
	printArgLine("svrAddr", svrAddr)
	printArgLine("dstAddr", dstAddr)
	fmt.Println("\n")
}
示例#3
0
func main() {
	var output, logDir string
	var showVersion bool
	flag.Usage = showUsage
	flag.StringVar(&context.config, "config", "", "indicate Config path if it in nontypical path")
	flag.StringVar(&output, "o", "", "output file")
	flag.BoolVar(&context.csc, "csc", false, "Server;;Create Server Config")
	flag.BoolVar(&context.ccc, "ccc", false, "Server;;Create Client Config for user//-ccc <ServerAddress:Port> <User>")
	flag.BoolVar(&context.isServ, "serv", false, "Server;;run as Server explicitly")
	flag.BoolVar(&showVersion, "V", false, "show Version")
	flag.IntVar(&context.vFlag, "v", -1, "Verbose log level")
	flag.StringVar(&logDir, "logdir", "", "write log into the directory")
	flag.BoolVar(&context.debug, "debug", false, "debug")
	flag.Parse()

	if showVersion {
		fmt.Println(versionString())
		fmt.Println(buildInfo(), "\n")
		return
	}

	context.parse()
	// toStd bool, logDir string
	log.SetLogOutput(logDir)

	if context.csc {
		context.cscHandler(output)
		return
	}

	if context.ccc {
		context.cccHandler(output)
		return
	}

	if context.isServ {
		go context.startServer()
	} else {
		go context.startClient()
	}
	waitSignal()
}