mirror of https://github.com/perkeep/perkeep.git
add handler to return IP address. for ec2 wiring.
Change-Id: I346ba2764166b507dd96530061eb64bcbdc09bad
This commit is contained in:
parent
b223044009
commit
43cd36a7f2
|
@ -279,13 +279,13 @@ func main() {
|
|||
})
|
||||
}
|
||||
mux.Handle("/r/", gerritHandler)
|
||||
mux.HandleFunc("/debugz/ip", ipHandler)
|
||||
|
||||
testCgi := &cgi.Handler{Path: filepath.Join(*root, "test.cgi"),
|
||||
Root: "/test.cgi",
|
||||
}
|
||||
mux.Handle("/test.cgi", testCgi)
|
||||
mux.Handle("/test.cgi/foo", testCgi)
|
||||
|
||||
mux.Handle("/code", http.RedirectHandler("/code/", http.StatusFound))
|
||||
if *gitwebScript != "" {
|
||||
env := os.Environ()
|
||||
|
@ -365,3 +365,19 @@ func rsyncFromGerrit(dest string) {
|
|||
time.Sleep(10e9)
|
||||
}
|
||||
}
|
||||
|
||||
func ipHandler(w http.ResponseWriter, r *http.Request) {
|
||||
out, _ := exec.Command("ip", "-f", "inet", "addr", "show", "dev", "eth0").Output()
|
||||
str := string(out)
|
||||
pos := strings.Index(str, "inet ")
|
||||
if pos == -1 {
|
||||
return
|
||||
}
|
||||
str = str[pos + 5:]
|
||||
pos = strings.Index(str, "/")
|
||||
if pos == -1 {
|
||||
return
|
||||
}
|
||||
str = str[:pos]
|
||||
w.Write([]byte(str))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue