diff --git a/dist/plannersync b/dist/plannersync index 007f402..a42e037 100755 Binary files a/dist/plannersync and b/dist/plannersync differ diff --git a/sync/service/handler.go b/sync/service/handler.go index b288dbb..2f351ae 100644 --- a/sync/service/handler.go +++ b/sync/service/handler.go @@ -100,7 +100,7 @@ func (s *Server) SyncGet(w http.ResponseWriter, r *http.Request) { } fmt.Fprint(w, string(body)) - s.logger.Info("served sync get", "count", len(items), "remoteAddr", r.RemoteAddr) + s.logger.Info("served sync get", "count", len(items), "remoteAddr", getClientIP(r)) } func (s *Server) SyncPost(w http.ResponseWriter, r *http.Request) { @@ -155,7 +155,7 @@ func (s *Server) SyncPost(w http.ResponseWriter, r *http.Request) { } w.WriteHeader(http.StatusNoContent) - s.logger.Info("served sync post", "count", len(items), "remoteAddr", r.RemoteAddr) + s.logger.Info("served sync post", "count", len(items), "remoteAddr", getClientIP(r)) } // ShiftPath splits off the first component of p, which will be cleaned of @@ -178,3 +178,11 @@ func Index(w http.ResponseWriter, r *http.Request) { func fmtError(msg string) string { return fmt.Sprintf(`{"error":%q}`, msg) } + +func getClientIP(r *http.Request) string { + ip := r.Header.Get("X-Real-IP") + if ip == "" { + ip = strings.Split(r.RemoteAddr, ":")[0] + } + return ip +}