introduce 'weave connect' to connect a running router to other peers

Getting this to work with 'wget' is just too cumbersome especially
when it comes to getting the error message out. So 'curl' only.
This commit is contained in:
Matthias Radestock committed 2014-10-27 09:15:14 +00:00
1 parent acbabc4f9e
commit 6393e545ae
2 files changed
+38 -15

No files matched your search

+8
View File
@@ -141,6 +141,14 @@ func handleHttp(router *weave.Router) {
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, router.Status())
})
http.HandleFunc("/connect", func (w http.ResponseWriter, r *http.Request) {
peer := r.FormValue("peer")
if addr, err := net.ResolveTCPAddr("tcp4", weave.NormalisePeerAddr(peer)); err == nil {
router.ConnectionMaker.InitiateConnection(addr.String())
} else {
http.Error(w, fmt.Sprint("invalid peer address: ", err), http.StatusBadRequest)
}
})
address := fmt.Sprintf(":%d", weave.HttpPort)
err := http.ListenAndServe(address, nil)
if err != nil {