File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed
Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 11GIT_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
36all : certgraph
47
58fmt :
69 gofmt -s -w -l .
710
811certgraph : certgraph.go
9- go build -o $@ $^
12+ go build $( BUILD_FLAGS ) -o $@ $^
1013
1114certgraph.linux : certgraph.go
12- GOOS=linux go build -o $@ $^
15+ GOOS=linux go build $( BUILD_FLAGS ) -o $@ $^
1316
1417certgraph.mac : certgraph.go
15- GOOS=darwin go build -o $@ $^
18+ GOOS=darwin go build $( BUILD_FLAGS ) -o $@ $^
1619
1720certgraph.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
2026certgraph.linux.$(GIT_DATE ) .zip : certgraph.linux
2127 zip $@ $^
@@ -26,4 +32,10 @@ certgraph.mac.$(GIT_DATE).zip: certgraph.mac
2632certgraph.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
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ var markedDomains = make(map[string]bool)
3131var domainGraph = make (map [string ]* DomainNode )
3232var depth uint
3333var save bool
34+ var git_date = "none"
35+ var git_hash = "DEADBEEF"
3436
3537// flags
3638var port string
@@ -43,6 +45,7 @@ var sortCerts bool
4345var savePath string
4446var list bool
4547var printJSON bool
48+ var ver bool
4649
4750// domain node conection status
4851type domainStatus int
@@ -109,6 +112,7 @@ func (d *DomainNode) String() string {
109112}
110113
111114func 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
You can’t perform that action at this time.
0 commit comments