示例#1
0
func (context *bootContext) startServer() {
	defer func() {
		ex.CatchException(warning(recover()))
		sigChan <- t.Bye
	}()
	var conf = t.Parse_d5sFile(context.config)
	context.setLogVerbose(conf.Verbose)
	log.Infoln(versionString())
	log.Infoln("Server is listening on", conf.ListenAddr)

	ln, err := net.ListenTCP("tcp", conf.ListenAddr)
	if err != nil {
		log.Fatalln(err)
	}
	defer ln.Close()

	dhKeys := t.GenerateDHKeyPairs()
	server := t.NewServer(conf, dhKeys)
	context.statser = server
	for {
		conn, err := ln.AcceptTCP()
		if err == nil {
			go server.TunnelServe(conn)
		} else {
			t.SafeClose(conn)
		}
	}
}
示例#2
0
func (c *bootContext) icc_process(output string) {
	defer func() {
		if e := recover(); e != nil {
			fmt.Println(e)
		}
	}()
	if flag.NArg() >= 2 {
		addr := flag.Arg(0)
		if v, e := t.IsValidHost(addr); !v {
			panic(e)
		}
		var d5sc = t.Parse_d5sFile(c.config)
		d5sc.Listen = addr
		for i, arg := range flag.Args() {
			if i > 0 {
				t.CreateClientCredential(output, d5sc, arg)
			}
		}
		return
	} else {
		fmt.Println("Which user do you issue client credential for?")
	}
}