package main import ( "net" "net/http" "strings" "strconv" ) func templateHeader(w http.ResponseWriter, r *http.Request, title string) { path := r.URL.Path if len(strings.Split(r.URL.Path, "/")) < 4 { path = "/ipv4/summary/" + strings.Join(settingServers[:], "+") + "/" } split := strings.Split(path, "/") split[1] = "ipv4" ipv4_url := strings.Join(split, "/") split = strings.Split(path, "/") split[1] = "ipv6" ipv6_url := strings.Join(split, "/") split = strings.Split(path, "/") split[3] = strings.Join(settingServers[:], "+") all_url := strings.Join(split, "/") split = strings.Split(path, "/") var serverAllActive string if split[3] == strings.Join(settingServers[:], "+") { serverAllActive = " active" } var serverNavigation string = `
"))
for _, line := range strings.Split(s, "\n") {
var tabPending bool = false
var isFirstWord bool = true
var isASes bool = false
for _, word := range strings.Split(line, " ") {
if len(word) == 0 {
tabPending = true
} else {
if isFirstWord {
isFirstWord = false
} else if tabPending {
w.Write([]byte("\t"))
tabPending = false
} else {
w.Write([]byte(" "))
}
if isIP(word) {
w.Write([]byte("" + word + ""))
} else if len(strings.Split(word, "%")) == 2 && isIP(strings.Split(word, "%")[0]) {
w.Write([]byte("" + strings.Split(word, "%")[0] + ""))
w.Write([]byte("%" + strings.Split(word, "%")[1]))
} else if len(strings.Split(word, "/")) == 2 && isIP(strings.Split(word, "/")[0]) {
w.Write([]byte("" + strings.Split(word, "/")[0] + ""))
w.Write([]byte("/" + strings.Split(word, "/")[1]))
} else if word == "AS:" || word == "\tBGP.as_path:" {
isASes = true
w.Write([]byte(word))
} else if isASes && isNumber(word) {
w.Write([]byte("" + word + ""))
} else {
w.Write([]byte(word))
}
}
}
w.Write([]byte("\n"))
}
w.Write([]byte(""))
}
func summaryTable(w http.ResponseWriter, isIPv6 bool, data string, serverName string) {
w.Write([]byte("| " + row[i] + " | ")) } w.Write([]byte("")) } else { if row[3] == "up" { w.Write([]byte("||
|---|---|---|
| " + row[0] + " | ")) } else { w.Write([]byte("" + row[0] + " | ")) } for i := 1; i < 6; i++ { w.Write([]byte("" + row[i] + " | ")) } w.Write([]byte("