From a9a6b51a3ffc88ee5392f135a0de3d60b3ac19b1 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 29 Oct 2017 13:40:00 +1300 Subject: [PATCH] show yatwiki version in Server header --- Makefile | 5 ++++- WikiServer.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 07695ee..baa74fc 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,10 @@ SOURCES:=Makefile \ cmd $(wildcard cmd/yatwiki-server/*.go) \ $(wildcard *.go) -GOFLAGS := -ldflags='-s -w' -gcflags='-trimpath=$(GOPATH)' -asmflags='-trimpath=$(GOPATH)' +GOFLAGS:=-a \ + -ldflags "-s -w -X code.ivysaur.me/yatwiki.SERVER_HEADER=YATWiki/$(VERSION)" \ + -gcflags '-trimpath=$(GOPATH)' \ + -asmflags '-trimpath=$(GOPATH)' # # Phony targets diff --git a/WikiServer.go b/WikiServer.go index 8937aba..effd1d9 100644 --- a/WikiServer.go +++ b/WikiServer.go @@ -14,6 +14,8 @@ import ( "time" ) +var SERVER_HEADER string = "YATWiki/0.0.0-devel" + type WikiServer struct { db *WikiDB opts *ServerOptions @@ -79,7 +81,7 @@ func (this *WikiServer) Close() { } func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Server", "YATWiki3") + w.Header().Set("Server", SERVER_HEADER) if len(this.bans) > 0 { remoteIP := RemoteAddrToIPAddress(r.RemoteAddr)