summaryrefslogtreecommitdiff
path: root/ip.go
diff options
context:
space:
mode:
Diffstat (limited to 'ip.go')
-rw-r--r--ip.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/ip.go b/ip.go
index 967d5cf..1dd1aeb 100644
--- a/ip.go
+++ b/ip.go
@@ -12,6 +12,10 @@ func init() {
func ip(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
+ remote := r.Header.Get("X-Forwarded-For")
+ if remote == "" {
+ remote = r.RemoteAddr
+ }
addr, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)