diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 881b33d..e8a4b3d 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -123,9 +123,13 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) { } typ, _ := utils.NetworkType(r.Host) + ip := r.Header.Get("X-Real-IP") + if typ != "www" && typ != "ygg" { + ip = "" + } h.logFile.Printf("| up | %s | %s | %s | SHA256 %s | %s | %d | %s", - r.Header.Get("X-Real-IP"), typ, fHandler.Filename, fHash, fSaltedHash, fHandler.Size, r.UserAgent()) + ip, typ, fHandler.Filename, fHash, fSaltedHash, fHandler.Size, r.UserAgent()) w.WriteHeader(http.StatusCreated) } else { @@ -169,10 +173,14 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) { } defer fd.Close() - netTyp, _ := utils.NetworkType(r.Host) + typ, _ := utils.NetworkType(r.Host) + ip := r.Header.Get("X-Real-IP") + if typ != "www" && typ != "ygg" { + ip = "" + } h.logFile.Printf("| dw | %s | %s | %s | %s | %s", - r.Header.Get("X-Real-IP"), netTyp, name, saltedHash, r.UserAgent()) + ip, typ, name, saltedHash, r.UserAgent()) http.ServeContent(w, r, path, stat.ModTime(), fd) } @@ -199,10 +207,14 @@ func (h *UploadHandlers) Delete(w http.ResponseWriter, r *http.Request) { return } - netTyp, _ := utils.NetworkType(r.Host) + typ, _ := utils.NetworkType(r.Host) + ip := r.Header.Get("X-Real-IP") + if typ != "www" && typ != "ygg" { + ip = "" + } h.logFile.Printf("| dt | %s | %s | %s | %s", - r.Header.Get("X-Real-IP"), netTyp, saltedHash, r.UserAgent()) + ip, typ, saltedHash, r.UserAgent()) if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") { fmt.Fprintln(w, "File was successfully deleted.")