示例#1
0
文件: main.go 项目: GeorgFleig/gretun
// destroy GRE tunnel
func destroy(tun *gretun.Tunnel) {
	if tun.Destroy() {
		log.Println("GRE Tunnel destroyed.")
	} else {
		log.Println("Failed destroying GRE Tunnel.")
	}
}
示例#2
0
文件: main.go 项目: GeorgFleig/gretun
// register at server and create GRE tunnel
func register(tun *gretun.Tunnel) {
	log.Println("Requesting GRE IP from server ..")
	var greIp net.IP = nil
	statusCode, body := httpReq("http://" + serverIp + ":8080/reg")
	if statusCode != 0 {
		log.Printf("Response: %d (%s): %s\n", statusCode, http.StatusText(statusCode), body)
		greIp = net.ParseIP(string(body))
	}
	if greIp != nil {
		tun.CGreIp = greIp
		if tun.Create() {
			log.Println("GRE Tunnel created.")
		} else {
			log.Println("Failed creating GRE Tunnel.")
		}
	} else {
		log.Fatalln("Did not get a GRE IP address from server.")
	}
}
示例#3
0
文件: main.go 项目: GeorgFleig/gretun
// unsets remote IP to free GRE IP
func (tunList *TunList) free(tun *gretun.Tunnel) {
	tun.RemoteIp = nil
}