Esempio n. 1
0
func processHoleClient(holeApp HoleApp, restart bool) {
	getCert("cert.pem", certFile)
	getCert("cert.key", privFile)

	var realAddr = holeApp.Lscheme + "://" + holeApp.Lhost + ":" + holeApp.Lport
	var serverAddr = holeApp.Scheme + "://" + holeApp.Host + ":" + holeApp.Port
	var client = hole.NewClient(realAddr)
	client.ConfigTLS(certFile, privFile)

	for {
		if err := client.Connect(serverAddr); err == nil {
			fmt.Printf("Publish: %s\n", serverAddr)
			client.Process()
			if !restart {
				killApp(os.Getpid())
			}
			reTryTimes = defaultReTryTime
		}
		reTryTimes = reTryTimes - 1
		if reTryTimes == 0 {
			log.Fatal("Error: unable to connect %s\n", serverAddr)
		}
		log.Printf("Retry after 2 second...")
		time.Sleep(2 * time.Second)
	}

}
Esempio n. 2
0
File: main.go Progetto: hd5970/hole
func main() {
	var client = hole.NewClient(realAddr)
	if useTLS {
		client.ConfigTLS(certFile, privFile)
	}

	for {
		if err := client.Connect(serverAddr); err != nil {
			reTryTimes = reTryTimes - 1
			if reTryTimes == 0 {
				break
			}
			log.Printf("Retry after 2 second...")
			time.Sleep(2 * time.Second)
			continue
		}
		client.Process()
		reTryTimes = defaultReTryTime
	}
}