From c06a7aa4e189f220b9ea326369b74fd1871be52d Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 12 Aug 2016 17:43:06 +0200 Subject: [PATCH 1/3] Update docker image to v1.0.6 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index eea6bd7..b7e1899 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.2 +FROM alpine:3.4 MAINTAINER Jan Broer -ADD https://github.com/janeczku/go-dnsmasq/releases/download/1.0.0/go-dnsmasq_linux-amd64 /go-dnsmasq +ADD https://github.com/janeczku/go-dnsmasq/releases/download/1.0.6/go-dnsmasq-min_linux-amd64 /go-dnsmasq RUN chmod +x /go-dnsmasq ENV DNSMASQ_LISTEN=0.0.0.0 From 0808cf7eda60eb14822001dec0576c53a91635c3 Mon Sep 17 00:00:00 2001 From: janeczku Date: Sun, 2 Oct 2016 21:48:02 +0200 Subject: [PATCH 2/3] Fix: Restore /etc/resolv.conf after unclean program exit --- hostsfile/hostsfile.go | 7 ++++--- main.go | 7 ++++++- resolvconf/resolvconf.go | 9 ++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hostsfile/hostsfile.go b/hostsfile/hostsfile.go index 1ec718a..4beb823 100644 --- a/hostsfile/hostsfile.go +++ b/hostsfile/hostsfile.go @@ -55,9 +55,10 @@ func NewHostsfile(path string, config *Config) (*Hostsfile, error) { log.Debugf("Found host:ip pairs in %s:", h.file.path) for _, hostname := range *h.hosts { - log.Debugf("%s : %s", + log.Debugf("%s -> %s *=%t", hostname.domain, - hostname.ip.String()) + hostname.ip.String(), + hostname.wildcard) } return &h, nil @@ -67,7 +68,7 @@ func (h *Hostsfile) FindHosts(name string) (addrs []net.IP, err error) { name = strings.TrimSuffix(name, ".") h.hostMutex.RLock() defer h.hostMutex.RUnlock() - addrs = h.hosts.FindHosts(name); + addrs = h.hosts.FindHosts(name) return } diff --git a/main.go b/main.go index 1b10a07..c889207 100644 --- a/main.go +++ b/main.go @@ -252,6 +252,7 @@ func main() { Verbose: c.Bool("verbose"), } + resolvconf.Clean() if err := server.ResolvConf(config, c); err != nil { if !os.IsNotExist(err) { log.Warnf("Error parsing resolv.conf: %s", err.Error()) @@ -322,7 +323,11 @@ func main() { if err != nil { log.Warnf("Failed to register as default nameserver: %s", err) } - defer resolvconf.Clean() + + defer func() { + log.Info("Restoring /etc/resolv.conf") + resolvconf.Clean() + }() } go func() { diff --git a/resolvconf/resolvconf.go b/resolvconf/resolvconf.go index fa3d00e..3ee150e 100644 --- a/resolvconf/resolvconf.go +++ b/resolvconf/resolvconf.go @@ -24,13 +24,12 @@ const RESOLVCONF_PATH = "/etc/resolv.conf" var resolvConfPattern = regexp.MustCompile("(?m:^.*" + regexp.QuoteMeta(RESOLVCONF_COMMENT_ADD) + ")(?:$|\n)") func StoreAddress(address string) error { - log.Info("Setting host nameserver to %s", address) + log.Infof("Setting host nameserver to %s", address) resolveConfEntry := fmt.Sprintf("nameserver %s %s\n", address, RESOLVCONF_COMMENT_ADD) return updateResolvConf(resolveConfEntry, RESOLVCONF_PATH) } func Clean() { - log.Info("Restoring /etc/resolv.conf") updateResolvConf("", RESOLVCONF_PATH) } @@ -60,17 +59,17 @@ func updateResolvConf(insert, path string) error { for _, line := range lines { switch insert { case "": - // Uncomment lines we commented + // uncomment lines we commented if strings.Contains(line, RESOLVCONF_COMMENT_OUT) { line = strings.Replace(line, RESOLVCONF_COMMENT_OUT, "", -1) line = strings.TrimLeft(line, " ") } default: - // Comment out active nameservers only + // comment out active nameservers only if strings.HasPrefix(strings.ToLower(strings.TrimSpace(line)), "nameserver") { line = fmt.Sprintf("%s %s", RESOLVCONF_COMMENT_OUT, line) } - } + } if _, err = f.WriteString(line); err != nil { return err From 4ec175c3090c3d52bf982e7a8149c350865ce120 Mon Sep 17 00:00:00 2001 From: janeczku Date: Sun, 2 Oct 2016 21:50:14 +0200 Subject: [PATCH 3/3] Bump v.1.0.7 --- Dockerfile | 2 +- Dockerfile.build | 2 -- VERSION | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7e1899..4d3867e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.4 MAINTAINER Jan Broer -ADD https://github.com/janeczku/go-dnsmasq/releases/download/1.0.6/go-dnsmasq-min_linux-amd64 /go-dnsmasq +ADD https://github.com/janeczku/go-dnsmasq/releases/download/1.0.7/go-dnsmasq-min_linux-amd64 /go-dnsmasq RUN chmod +x /go-dnsmasq ENV DNSMASQ_LISTEN=0.0.0.0 diff --git a/Dockerfile.build b/Dockerfile.build index 5009897..d87d9a7 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -22,5 +22,3 @@ COPY scripts/upx /usr/local/bin/ RUN chmod +x /usr/local/bin/upx WORKDIR /go/src/github.com/janeczku/go-dnsmasq - -#RUN go get -d ./... diff --git a/VERSION b/VERSION index ece61c6..f9cbc01 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.6 \ No newline at end of file +1.0.7 \ No newline at end of file