diff --git a/router/connection_maker.go b/router/connection_maker.go
index 485177a2..50d62bba 100644
--- a/router/connection_maker.go
+++ b/router/connection_maker.go
@@ -52,6 +52,13 @@ func (cm *ConnectionMaker) InitiateConnection(address string) {
}
}
+func (cm *ConnectionMaker) ForgetConnection(address string) {
+ cm.actionChan <- func() bool {
+ delete(cm.cmdLineAddress, NormalisePeerAddr(address))
+ return false
+ }
+}
+
func (cm *ConnectionMaker) ConnectionTerminated(address string) {
cm.actionChan <- func() bool {
if target, found := cm.targets[address]; found {
diff --git a/site/features.md b/site/features.md
index cd62ba75..d95922b7 100644
--- a/site/features.md
+++ b/site/features.md
@@ -331,7 +331,15 @@ then on one of the existing hosts runs
host# weave connect $NEW_HOST
Other hosts in the weave network will automatically attempt to
-establish connections to the new host too.
+establish connections to the new host too. Conversely, it is possible
+to instruct a peer to forget a particular host that was specified
+to it via `weave launch` or `weave connect`:
+
+ host# weave forget $DECOMMISSIONED_HOST
+
+This will prevent the peer from trying to reconnect to that host once
+connectivity to it is lost, and thus can be used to administratively
+remove decommissioned peers from the network.
### Container mobility
diff --git a/weave b/weave
index c65ff8ae..cd13b1a5 100755
--- a/weave
+++ b/weave
@@ -18,6 +18,7 @@ usage() {
echo "weave launch [-password ] [-nickname ] ..."
echo "weave launch-dns "
echo "weave connect "
+ echo "weave forget "
echo "weave run [--with-dns] ..."
echo "weave start "
echo "weave attach "
@@ -597,6 +598,10 @@ case "$COMMAND" in
[ $# -eq 1 ] || usage
http_call $CONTAINER_NAME $HTTP_PORT POST /connect -d "peer=$1"
;;
+ forget)
+ [ $# -eq 1 ] || usage
+ http_call $CONTAINER_NAME $HTTP_PORT POST /forget -d "peer=$1"
+ ;;
status)
http_call $CONTAINER_NAME $HTTP_PORT GET /status || true
echo
diff --git a/weaver/main.go b/weaver/main.go
index 682509c7..791e0d26 100644
--- a/weaver/main.go
+++ b/weaver/main.go
@@ -180,6 +180,15 @@ func handleHTTP(router *weave.Router) {
}
})
+ muxRouter.Methods("POST").Path("/forget").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ peer := r.FormValue("peer")
+ if addr, err := net.ResolveTCPAddr("tcp4", weave.NormalisePeerAddr(peer)); err == nil {
+ router.ConnectionMaker.ForgetConnection(addr.String())
+ } else {
+ http.Error(w, fmt.Sprint("invalid peer address: ", err), http.StatusBadRequest)
+ }
+ })
+
http.Handle("/", muxRouter)
address := fmt.Sprintf(":%d", weave.HTTPPort)