fix: force

This commit is contained in:
Alexander Renz 2025-01-31 10:58:18 +01:00
parent 5751f1d0c7
commit 31a157ea96
2 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# HMAC File Server 2.5-Stable # HMAC File Server 2.6-Stable
## Overview ## 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. 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.

View File

@ -2092,6 +2092,7 @@ func handleChunkedUpload(tempFilename string, r *http.Request, chunkSize int) er
buffer := make([]byte, chunkSize) buffer := make([]byte, chunkSize)
totalBytes := int64(0) totalBytes := int64(0)
originalIP := r.RemoteAddr
for { for {
n, err := r.Body.Read(buffer) n, err := r.Body.Read(buffer)
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
@ -2101,6 +2102,12 @@ func handleChunkedUpload(tempFilename string, r *http.Request, chunkSize int) er
break 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]) _, err = writer.Write(buffer[:n])
if err != nil { if err != nil {
return fmt.Errorf("failed to write to file: %v", err) return fmt.Errorf("failed to write to file: %v", err)