Exemplo n.º 1
0
func main() {
	// parse argument and check
	options := argsCheck()

	app := tunnel.NewApp(options)
	if options.TunnelServer {
		var tunnelServer *tunnel.TunnelServer
		if options.Front {
			tunnelServer = tunnel.NewTunnelServer(tunnel.NewFrontDoor)
		} else {
			tunnelServer = tunnel.NewTunnelServer(tunnel.NewBackDoor)
		}
		app.Add(tunnelServer)
	} else {
		var tunnelClient *tunnel.TunnelClient
		if options.Front {
			tunnelClient = tunnel.NewTunnelClient(tunnel.NewFrontDoor)
		} else {
			tunnelClient = tunnel.NewTunnelClient(tunnel.NewBackDoor)
		}
		app.Add(tunnelClient)
	}

	err := app.Start()
	if err != nil {
		fmt.Printf("start gotunnel failed:%s\n", err.Error())
		return
	}
	go handleSignal(app)

	app.Wait()
}
Exemplo n.º 2
0
func main() {
	// parse argument and check
	options := argsCheck()

	app := tunnel.NewApp(options)
	if options.Server == "" {
		app.Add(tunnel.NewTunnelServer())
	} else {
		app.Add(tunnel.NewTunnelClient())
	}

	err := app.Start()
	if err != nil {
		fmt.Printf("start gotunnel failed:%s\n", err.Error())
		return
	}
	go handleSignal(app)

	app.Wait()
}