diff --git a/README.MD b/README.MD index 84e5c7c..049029e 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,4 @@ -# HMAC File Server 2.5-Stable +# HMAC File Server 2.6-Stable ## Overview The **HMAC File Server** ensures secure file uploads and downloads using HMAC authentication. It incorporates rate limiting, CORS support, retries, file versioning, and Unix socket support for enhanced flexibility. Redis integration provides efficient caching and session management. Prometheus metrics and a graceful shutdown mechanism ensure reliable and efficient file handling. diff --git a/cmd/server/main.go b/cmd/server/main.go index b7d0215..9497bc6 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2092,6 +2092,7 @@ func handleChunkedUpload(tempFilename string, r *http.Request, chunkSize int) er buffer := make([]byte, chunkSize) totalBytes := int64(0) + originalIP := r.RemoteAddr for { n, err := r.Body.Read(buffer) if err != nil && err != io.EOF { @@ -2101,6 +2102,12 @@ func handleChunkedUpload(tempFilename string, r *http.Request, chunkSize int) er break } + currentIP := r.RemoteAddr + if currentIP != originalIP { + log.Warnf("IP changed from %s to %s, terminating transfer", originalIP, currentIP) + return fmt.Errorf("client IP changed during transfer") + } + _, err = writer.Write(buffer[:n]) if err != nil { return fmt.Errorf("failed to write to file: %v", err)