Skip to content

Commit 938e635

Browse files
committed
added version support and openbsd compile
1 parent 085c921 commit 938e635

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
GIT_DATE := $(shell git log -1 --date=short --pretty='%cd' | tr -d -)
2+
GIT_HASH := $(shell git rev-parse HEAD)
3+
4+
BUILD_FLAGS := -ldflags "-X main.git_date=$(GIT_DATE) -X main.git_hash=$(GIT_HASH)"
25

36
all: certgraph
47

58
fmt:
69
gofmt -s -w -l .
710

811
certgraph: certgraph.go
9-
go build -o $@ $^
12+
go build $(BUILD_FLAGS) -o $@ $^
1013

1114
certgraph.linux: certgraph.go
12-
GOOS=linux go build -o $@ $^
15+
GOOS=linux go build $(BUILD_FLAGS) -o $@ $^
1316

1417
certgraph.mac: certgraph.go
15-
GOOS=darwin go build -o $@ $^
18+
GOOS=darwin go build $(BUILD_FLAGS) -o $@ $^
1619

1720
certgraph.exe: certgraph.go
18-
GOOS=windows GOARCH=386 go build -o certgraph.exe $^
21+
GOOS=windows GOARCH=386 go build $(BUILD_FLAGS) -o certgraph.exe $^
22+
23+
certgraph.openbsd: certgraph.go
24+
GOOS=openbsd go build $(BUILD_FLAGS) -o $@ $^
1925

2026
certgraph.linux.$(GIT_DATE).zip: certgraph.linux
2127
zip $@ $^
@@ -26,4 +32,10 @@ certgraph.mac.$(GIT_DATE).zip: certgraph.mac
2632
certgraph.win.$(GIT_DATE).zip: certgraph.exe
2733
zip $@ $^
2834

29-
release: certgraph.linux.$(GIT_DATE).zip certgraph.mac.$(GIT_DATE).zip certgraph.win.$(GIT_DATE).zip
35+
certgraph.openbsd.$(GIT_DATE).zip: certgraph.openbsd
36+
zip $@ $^
37+
38+
release: certgraph.linux.$(GIT_DATE).zip certgraph.mac.$(GIT_DATE).zip certgraph.win.$(GIT_DATE).zip certgraph.openbsd.$(GIT_DATE).zip
39+
40+
clean:
41+
rm certgraph certgraph.linux certgraph.mac certgraph.exe certgraph.openbsd certgraph.*.zip

certgraph.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var markedDomains = make(map[string]bool)
3131
var domainGraph = make(map[string]*DomainNode)
3232
var depth uint
3333
var save bool
34+
var git_date = "none"
35+
var git_hash = "DEADBEEF"
3436

3537
// flags
3638
var port string
@@ -43,6 +45,7 @@ var sortCerts bool
4345
var savePath string
4446
var list bool
4547
var printJSON bool
48+
var ver bool
4649

4750
// domain node conection status
4851
type domainStatus int
@@ -109,6 +112,7 @@ func (d *DomainNode) String() string {
109112
}
110113

111114
func main() {
115+
flag.BoolVar(&ver, "version", false, "print version and exit")
112116
portPtr := flag.Uint("port", 443, "tcp port to connect to")
113117
timeoutPtr := flag.Uint("timeout", 5, "tcp timeout in seconds")
114118
flag.BoolVar(&verbose, "verbose", false, "verbose logging")
@@ -123,8 +127,13 @@ func main() {
123127
fmt.Fprintf(os.Stderr, "Usage of %s: [OPTION]... HOST...\n", os.Args[0])
124128
flag.PrintDefaults()
125129
}
126-
127130
flag.Parse()
131+
132+
if ver {
133+
fmt.Printf("Git commit: [%s] %s\n", git_date, git_hash)
134+
return
135+
}
136+
128137
if printJSON {
129138
// these arguments conflict
130139
sortCerts = true

0 commit comments

Comments
 (0)