server: set requestID for each request

This commit is contained in:
Cadey Ratio 2017-01-23 08:03:14 -08:00
parent 14f068eddb
commit 9b21edfbce
1 changed files with 10 additions and 1 deletions

View File

@ -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
}