From 925f60d9c352caec37ae52d5a755833d71d793ea Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Tue, 3 Nov 2015 21:23:35 +0000 Subject: [PATCH] Add support for header holding IP address --- cmd/strelaypoolsrv/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/strelaypoolsrv/main.go b/cmd/strelaypoolsrv/main.go index bbb3a0f1d..79fd4b35b 100644 --- a/cmd/strelaypoolsrv/main.go +++ b/cmd/strelaypoolsrv/main.go @@ -67,6 +67,7 @@ var ( getLimit time.Duration postLimit time.Duration permRelaysFile string + ipHeader string getMut sync.RWMutex = sync.NewRWMutex() getLRUCache *lru.Cache @@ -94,6 +95,7 @@ func main() { flag.IntVar(&postLimitAvg, "post-limit-avg", 2, "Allowed average post request rate, per minute") flag.Int64Var(&postLimitBurst, "post-limit-burst", postLimitBurst, "Allowed burst post requests") flag.StringVar(&permRelaysFile, "perm-relays", "", "Path to list of permanent relays") + flag.StringVar(&ipHeader, "ip-header", "", "Name of header which holds clients ip:port. Only meaningful when running behind a reverse proxy.") flag.Parse() @@ -236,6 +238,9 @@ func mimeTypeForFile(file string) string { } func handleRequest(w http.ResponseWriter, r *http.Request) { + if ipHeader != "" { + r.RemoteAddr = r.Header.Get(ipHeader) + } w.Header().Set("Access-Control-Allow-Origin", "*") switch r.Method { case "GET":