From 7408f72de2be00a2a5c55a46b33b41beb40e13a4 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Fri, 23 Oct 2015 15:10:07 +0100 Subject: [PATCH 1/2] Check weaveDNS subdomain on REST PUT --- nameserver/http.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nameserver/http.go b/nameserver/http.go index 29311d4c..5cd70f5a 100644 --- a/nameserver/http.go +++ b/nameserver/http.go @@ -35,6 +35,11 @@ func (n *Nameserver) HandleHTTP(router *mux.Router, dockerCli *docker.Client) { return } + if !dns.IsSubDomain(n.domain, hostname) { + n.infof("Ignoring registration %s %s %s (not a subdomain of %s)", hostname, ipStr, container, n.domain) + return + } + if err := n.AddEntry(hostname, container, n.ourName, ip); err != nil { n.badRequest(w, fmt.Errorf("Unable to add entry: %v", err)) return From 4792fe639163595125ea554293bdc06f9298109e Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Mon, 26 Oct 2015 10:54:51 +0000 Subject: [PATCH 2/2] Improved detection of router container restart Use the container name in addition to the entrypoint to avoid triggering reattachment unnecessarily. --- proxy/common.go | 1 + proxy/proxy.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/common.go b/proxy/common.go index 1dfe787e..29db23ef 100644 --- a/proxy/common.go +++ b/proxy/common.go @@ -21,6 +21,7 @@ var ( containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*") weaveWaitEntrypoint = []string{"/w/w"} weaveEntrypoint = "/home/weave/weaver" + weaveContainerName = "/weave" ) func callWeave(args ...string) ([]byte, []byte, error) { diff --git a/proxy/proxy.go b/proxy/proxy.go index dc6bcfcf..f087d769 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -315,7 +315,8 @@ func containerShouldAttach(container *docker.Container) bool { } func containerIsWeaveRouter(container *docker.Container) bool { - return len(container.Config.Entrypoint) > 0 && container.Config.Entrypoint[0] == weaveEntrypoint + return container.Name == weaveContainerName && + len(container.Config.Entrypoint) > 0 && container.Config.Entrypoint[0] == weaveEntrypoint } func (proxy *Proxy) createWait(r *http.Request, ident string) {