From acaede1a040025413101d480852dd338197c4734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 08:54:01 +0200 Subject: [PATCH 1/7] add go modules file --- go.mod | 9 +++++++++ go.sum | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3e6392b --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module dnsheaven + +go 1.14 + +require ( + github.com/greenboxal/dns-heaven v1.0.0 + github.com/miekg/dns v1.1.29 // indirect + github.com/sirupsen/logrus v1.6.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4f04c21 --- /dev/null +++ b/go.sum @@ -0,0 +1,28 @@ +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/greenboxal/dns-heaven v1.0.0 h1:lz0TEiLMNVmr7f/iLPK1RGQSaPw4VAxzhcGP1XuEoHE= +github.com/greenboxal/dns-heaven v1.0.0/go.mod h1:5ihO99PJIW5JvuQJYHSumkX8v8QxCs3mETrPAcq7pvY= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg= +github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 551d84db4615228301cfc9743e0dbfd8abc086a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 08:54:17 +0200 Subject: [PATCH 2/7] add version flag --- cmd/dns-heaven/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/dns-heaven/main.go b/cmd/dns-heaven/main.go index 3936999..a22a418 100644 --- a/cmd/dns-heaven/main.go +++ b/cmd/dns-heaven/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "os" "os/signal" @@ -11,16 +12,24 @@ import ( ) var config = &dnsheaven.Config{} +var Version = "unknown" +var showVersion bool = false func init() { flag.StringVar(&config.Address, "address", "127.0.0.1:53", "address to listen") flag.IntVar(&config.Timeout, "timeout", 2000, "request timeout") flag.IntVar(&config.Interval, "interval", 1000, "interval between requests") + flag.BoolVar(&showVersion, "version", false, "show version") } func main() { flag.Parse() + if showVersion { + fmt.Printf("%s - %s\n", os.Args[0], Version) + return + } + resolver, err := osx.New(config) if err != nil { From 12b21db8d4c374eab5fe5f79f20f92a1818d4c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 08:55:21 +0200 Subject: [PATCH 3/7] fix archive goreleaser parameter --- .goreleaser.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 9af5a52..03c5735 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,17 @@ builds: - darwin goarch: - amd64 + ldflags: |- + -X main.Version={{.Version}} -archive: - format: binary - +archives: + - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip From 791cb92cdb2eeedbd6b6983c4913345337516063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 08:55:51 +0200 Subject: [PATCH 4/7] add homebrew code --- .goreleaser.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 03c5735..e184892 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -19,3 +19,35 @@ archives: format_overrides: - goos: windows format: zip + +brews: + - name: dns-heaven + url_template: "https://github.com/greenboxal/dns-heaven/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + homepage: "https://github.com/greenboxal/dns-heaven" + description: "Fixes stupid macOS DNS stack (/etc/resolv.conf)" + github: + owner: jduepmeier + name: homebrew-dns-heaven + skip_upload: true + folder: Formula + dependencies: + - name: go + plist: | + + + + + Label + com.greenboxal.dnsheaven + ProgramArguments + + #{bin}/dns-heaven + + KeepAlive + + RunAtLoad + + + + test: | + system "#{bin}/dns-heaven -version" From cf7472a55f109f03f9020236341d875792df8114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 09:12:28 +0200 Subject: [PATCH 5/7] use own repo for tests --- .goreleaser.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e184892..6df388c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -17,13 +17,13 @@ archives: 386: i386 amd64: x86_64 format_overrides: - - goos: windows - format: zip + - goos: windows + format: zip brews: - name: dns-heaven - url_template: "https://github.com/greenboxal/dns-heaven/releases/download/{{ .Tag }}/{{ .ArtifactName }}" - homepage: "https://github.com/greenboxal/dns-heaven" + url_template: "https://github.com/jduepmeier/dns-heaven/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + homepage: "https://github.com/jduepmeier/dns-heaven" description: "Fixes stupid macOS DNS stack (/etc/resolv.conf)" github: owner: jduepmeier From 4089ea06243517a8e7bdcfbcbafc724995b13bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Wed, 17 Jun 2020 09:14:09 +0200 Subject: [PATCH 6/7] add changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..20b9015 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# CHANGELOG dns-heaven + +# v1.1.0 + +* add `-version` flag +* generate brew formula From 3a38e6cb0430753b579490b8bd4652e3fda5fc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=CC=88pmeier=2C=20Jan?= Date: Thu, 18 Jun 2020 08:26:34 +0200 Subject: [PATCH 7/7] remove not needed replacements from goreleaser archives --- .goreleaser.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 6df388c..09b9c6d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,13 +12,7 @@ archives: - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' replacements: darwin: Darwin - linux: Linux - windows: Windows - 386: i386 amd64: x86_64 - format_overrides: - - goos: windows - format: zip brews: - name: dns-heaven