Skip to content

Commit d120090

Browse files
authored
Merge pull request #22 from steffenfritz/checkversion
Closing #21
2 parents e588c12 + bf79548 commit d120090

File tree

9 files changed

+47
-41
lines changed

9 files changed

+47
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
22

33
BINARY=mxcheck
4-
VERSION=1.5.1
4+
VERSION=v1.5.2
55

66
BUILD=`git rev-parse --short HEAD`
77
PLATFORMS=darwin linux windows

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ You can set mailFrom, mailTo, the DNS server, DKIM selector and output a report
2222
-s, --service string The service host to check (mandatory flag)
2323
-S, --dkim-selector The DKIM selector. If set a dkim check is performed on the provided service domain
2424
-v, --version Version and license
25+
-u, --updatecheck Check if a new version of mxcheck is available
2526
-w, --write-tsv Write tsv formated report to file
2627

2728

2829

2930
# Version
3031

31-
v1.5.1
32+
v1.5.2
3233

3334
[![Go Report Card](https://goreportcard.com/badge/github.com/steffenfritz/mxcheck)](https://goreportcard.com/report/github.com/steffenfritz/mxcheck)
3435
[![Go Reference](https://pkg.go.dev/badge/github.com/steffenfritz/mxcheck.svg)](https://pkg.go.dev/github.com/steffenfritz/mxcheck)

checkversion.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"net/http"
6+
)
7+
8+
type MXCVersion struct {
9+
Tag_name string
10+
}
11+
12+
func getLatestVersion() {
13+
url := "https://api.github.com/repos/steffenfritz/mxcheck/releases/latest"
14+
resp, err := http.Get(url)
15+
if err != nil {
16+
InfoLogger.Fatalln(err)
17+
}
18+
19+
var mxcv MXCVersion
20+
jsondec := json.NewDecoder(resp.Body)
21+
err = jsondec.Decode(&mxcv)
22+
if err != nil {
23+
InfoLogger.Fatalln(err)
24+
}
25+
26+
if mxcv.Tag_name == Version {
27+
InfoLogger.Println("You have the most recent version installed. Version: " + Version)
28+
} else {
29+
InfoLogger.Println("A newer version is available.")
30+
InfoLogger.Println("Installed version: " + Version)
31+
InfoLogger.Println("Available version: " + mxcv.Tag_name)
32+
}
33+
}

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func main() {
7777
noprompt := flag.BoolP("no-prompt", "n", false, "Answer yes to all questions")
7878
targetHostName := flag.StringP("service", "s", "",
7979
"The service host to check")
80+
updatecheck := flag.BoolP("updatecheck", "u", false, "Check for new version of mxcheck")
8081
version := flag.BoolP("version", "v", false, "Version and license")
8182
writetsv := flag.BoolP("write-tsv", "w", false, "Write tsv formated report to file")
8283

@@ -87,6 +88,11 @@ func main() {
8788
return
8889
}
8990

91+
if *updatecheck {
92+
getLatestVersion()
93+
return
94+
}
95+
9096
if len(*targetHostName) == 0 {
9197
ErrorLogger.Println("The service flag is mandatory.")
9298
return

mxcheck.1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
.\" %%%LICENSE_END
2323

2424

25-
.TH mxcheck 1 "May 2023" "version 1.5.1"
25+
.TH mxcheck 1 "June 2023" "version 1.5.2"
26+
2627

2728
.SH NAME
2829
mxcheck
@@ -58,6 +59,9 @@ mxcheck
5859
.BR \-t,\ --mailto\fR
5960
Set the mailTo address (default "[email protected]").
6061

62+
.BR \-u,\ --updatecheck\fR
63+
Check if a new version of mxcheck is available.
64+
6165
.BR \-v,\ --version\fR
6266
Print the version and build and a license notice.
6367

public/categories/index.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

public/index.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

public/sitemap.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

public/tags/index.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)