From 9b21edfbce2d4a089eb3e23d44be92a8e0e27fc3 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Mon, 23 Jan 2017 08:03:14 -0800 Subject: [PATCH] server: set requestID for each request --- server/server.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index b03c2ee..08a59c3 100644 --- a/server/server.go +++ b/server/server.go @@ -12,6 +12,7 @@ import ( "net/rpc" "os" "path/filepath" + "strings" "time" "git.xeserv.us/xena/route/database" @@ -143,7 +144,15 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Header.Set("X-Remote-IP", host) r.Header.Set("X-Request-Ingress", time.Now().String()) - if r.RequestURI == rpc.DefaultRPCPath && r.Host == "" { + rid := uuid.New() + r.Header.Set("X-Request-Id", rid) + w.Header().Set("X-Request-Id", rid) + + if strings.HasSuffix(r.Host, ".onion") { + w.Header().Add("DNT", "1") + } + + if r.RequestURI == rpc.DefaultRPCPath { s.rpcS.ServeHTTP(w, r) return }