-
Notifications
You must be signed in to change notification settings - Fork 0
/
tunnel.go
74 lines (64 loc) · 2.65 KB
/
tunnel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"encoding/xml"
"fmt"
"os"
)
//Tunnels is the struct holding all found Hurricane Electric Tunnels in the account
type Tunnels struct {
XMLName xml.Name `xml:"tunnels"`
TunnelList []Tunnel `xml:"tunnel"`
}
//Tunnel holds individual tunnel data
type Tunnel struct {
XMLName xml.Name `xml:"tunnel" json:"-"`
ID string `xml:"id,attr"`
Description string `xml:"description"`
ServerV4 string `xml:"serverv4"`
ClientV4 string `xml:"clientv4"`
ServerV6 string `xml:"serverv6"`
ClientV6 string `xml:"clientv6"`
Routed64 string `xml:"routed64"`
Routed48 string `xml:"routed48"`
Rdns1 string `xml:"rdns1"`
Rdns2 string `xml:"rdns2"`
Rdns3 string `xml:"rdns3"`
Rdns4 string `xml:"rdns4"`
Rdns5 string `xml:"rdns5"`
}
func listTunnels(username, password string) {
rawXML := getDATA("https://tunnelbroker.net/tunnelInfo.php", username, password)
var tunnels Tunnels
err := xml.Unmarshal([]byte(rawXML), &tunnels)
if err != nil {
fmt.Println(err)
fmt.Println("No Data Returned - Check Username & Password")
os.Exit(1)
}
var printTunnels [][]string
for k := range tunnels.TunnelList {
printTunnels = append(printTunnels, []string{tunnels.TunnelList[k].ID, tunnels.TunnelList[k].Description, tunnels.TunnelList[k].ServerV4, tunnels.TunnelList[k].ClientV4, tunnels.TunnelList[k].ServerV6, tunnels.TunnelList[k].ClientV6, tunnels.TunnelList[k].Routed64, tunnels.TunnelList[k].Routed48})
}
printTunnelInfo(printTunnels)
}
func listTunnelbyID(tunnelID, username, password string) {
rawXML := getDATA("https://tunnelbroker.net/tunnelInfo.php?tid="+tunnelID, username, password)
var tunnels Tunnels
err := xml.Unmarshal([]byte(rawXML), &tunnels)
if err != nil {
fmt.Println(err)
fmt.Println("No Data Returned - Check Username & Password")
os.Exit(1)
}
var TunnelbyID [][]string
TunnelbyID = append(TunnelbyID, []string{tunnels.TunnelList[0].ID, tunnels.TunnelList[0].Description, tunnels.TunnelList[0].ServerV4, tunnels.TunnelList[0].ClientV4, tunnels.TunnelList[0].ServerV6, tunnels.TunnelList[0].ClientV6, tunnels.TunnelList[0].Routed64, tunnels.TunnelList[0].Routed48})
printTunnelInfo(TunnelbyID)
fmt.Println("")
var rDNS [][]string
rDNS = append(rDNS, []string{tunnels.TunnelList[0].Rdns1, tunnels.TunnelList[0].Rdns2, tunnels.TunnelList[0].Rdns3, tunnels.TunnelList[0].Rdns4, tunnels.TunnelList[0].Rdns5})
printTunnelrDNS(rDNS)
}
func updateTunnelIPv4(TunnelID, currentIPv4, username, password string) {
rawReply := getDATA("https://ipv4.tunnelbroker.net/nic/update?hostname="+TunnelID+"&myip="+currentIPv4, username, password)
fmt.Println(rawReply)
}