mirror of https://github.com/minio/minio.git
Populate host value from GetSourceIP directly (#7417)
This commit is contained in:
parent
0a44e70177
commit
e0a87e96de
|
@ -22,7 +22,6 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
@ -371,13 +370,6 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
|
||||||
// Write success response.
|
// Write success response.
|
||||||
writeSuccessResponseXML(w, encodedSuccessResponse)
|
writeSuccessResponseXML(w, encodedSuccessResponse)
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr failing which
|
|
||||||
// fill them with empty strings.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify deleted event for objects.
|
// Notify deleted event for objects.
|
||||||
for _, dobj := range deletedObjects {
|
for _, dobj := range deletedObjects {
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
|
@ -389,8 +381,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,12 +672,6 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||||
w.Header().Set("ETag", `"`+objInfo.ETag+`"`)
|
w.Header().Set("ETag", `"`+objInfo.ETag+`"`)
|
||||||
w.Header().Set("Location", location)
|
w.Header().Set("Location", location)
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object created event.
|
// Notify object created event.
|
||||||
defer sendEvent(eventArgs{
|
defer sendEvent(eventArgs{
|
||||||
EventName: event.ObjectCreatedPost,
|
EventName: event.ObjectCreatedPost,
|
||||||
|
@ -695,8 +680,7 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if successRedirect != "" {
|
if successRedirect != "" {
|
||||||
|
|
|
@ -839,7 +839,6 @@ type eventArgs struct {
|
||||||
ReqParams map[string]string
|
ReqParams map[string]string
|
||||||
RespElements map[string]string
|
RespElements map[string]string
|
||||||
Host string
|
Host string
|
||||||
Port string
|
|
||||||
UserAgent string
|
UserAgent string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +893,6 @@ func (args eventArgs) ToEvent() event.Event {
|
||||||
},
|
},
|
||||||
Source: event.Source{
|
Source: event.Source{
|
||||||
Host: args.Host,
|
Host: args.Host,
|
||||||
Port: args.Port,
|
|
||||||
UserAgent: args.UserAgent,
|
UserAgent: args.UserAgent,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -253,9 +252,6 @@ func deleteObject(ctx context.Context, obj ObjectLayer, cache CacheObjectLayer,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, _ := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
|
|
||||||
// Notify object deleted event.
|
// Notify object deleted event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectRemovedDelete,
|
EventName: event.ObjectRemovedDelete,
|
||||||
|
@ -265,8 +261,7 @@ func deleteObject(ctx context.Context, obj ObjectLayer, cache CacheObjectLayer,
|
||||||
},
|
},
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
goioutil "io/ioutil"
|
goioutil "io/ioutil"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -221,12 +220,6 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
|
||||||
s3Select.Evaluate(w)
|
s3Select.Evaluate(w)
|
||||||
s3Select.Close()
|
s3Select.Close()
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object accessed via a GET request.
|
// Notify object accessed via a GET request.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectAccessedGet,
|
EventName: event.ObjectAccessedGet,
|
||||||
|
@ -235,8 +228,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,12 +394,6 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object accessed via a GET request.
|
// Notify object accessed via a GET request.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectAccessedGet,
|
EventName: event.ObjectAccessedGet,
|
||||||
|
@ -416,8 +402,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,11 +547,6 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
// Notify object accessed via a HEAD request.
|
// Notify object accessed via a HEAD request.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectAccessedHead,
|
EventName: event.ObjectAccessedHead,
|
||||||
|
@ -575,8 +555,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,12 +1011,6 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
|
||||||
// Write success response.
|
// Write success response.
|
||||||
writeSuccessResponseXML(w, encodedSuccessResponse)
|
writeSuccessResponseXML(w, encodedSuccessResponse)
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if objInfo.IsCompressed() {
|
if objInfo.IsCompressed() {
|
||||||
objInfo.Size = actualSize
|
objInfo.Size = actualSize
|
||||||
}
|
}
|
||||||
|
@ -1050,8 +1023,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,12 +1275,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
|
||||||
|
|
||||||
writeSuccessResponseHeadersOnly(w)
|
writeSuccessResponseHeadersOnly(w)
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object created event.
|
// Notify object created event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectCreatedPut,
|
EventName: event.ObjectCreatedPut,
|
||||||
|
@ -1317,8 +1283,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2345,16 +2310,12 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
|
||||||
writeSuccessResponseXML(w, encodedSuccessResponse)
|
writeSuccessResponseXML(w, encodedSuccessResponse)
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
// Get host and port from Request.RemoteAddr.
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if objectAPI.IsEncryptionSupported() {
|
if objectAPI.IsEncryptionSupported() {
|
||||||
if crypto.IsEncrypted(objInfo.UserDefined) {
|
if crypto.IsEncrypted(objInfo.UserDefined) {
|
||||||
objInfo.Size, _ = objInfo.DecryptedSize()
|
objInfo.Size, _ = objInfo.DecryptedSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify object created event.
|
// Notify object created event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectCreatedCompleteMultipartUpload,
|
EventName: event.ObjectCreatedCompleteMultipartUpload,
|
||||||
|
@ -2363,8 +2324,7 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -983,12 +982,6 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object created event.
|
// Notify object created event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectCreatedPut,
|
EventName: event.ObjectCreatedPut,
|
||||||
|
@ -997,8 +990,7 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,12 +1108,6 @@ func (web *webAPIHandlers) Download(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host and port from Request.RemoteAddr.
|
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify object accessed via a GET request.
|
// Notify object accessed via a GET request.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectAccessedGet,
|
EventName: event.ObjectAccessedGet,
|
||||||
|
@ -1130,8 +1116,7 @@ func (web *webAPIHandlers) Download(w http.ResponseWriter, r *http.Request) {
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: handlers.GetSourceIP(r),
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,11 +1131,7 @@ type DownloadZipArgs struct {
|
||||||
|
|
||||||
// Takes a list of objects and creates a zip file that sent as the response body.
|
// Takes a list of objects and creates a zip file that sent as the response body.
|
||||||
func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) {
|
func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) {
|
||||||
// Get host and port from Request.RemoteAddr.
|
host := handlers.GetSourceIP(r)
|
||||||
host, port, err := net.SplitHostPort(handlers.GetSourceIP(r))
|
|
||||||
if err != nil {
|
|
||||||
host, port = "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := newContext(r, w, "WebDownloadZip")
|
ctx := newContext(r, w, "WebDownloadZip")
|
||||||
defer logger.AuditLog(w, r, "WebDownloadZip", mustGetClaimsFromToken(r))
|
defer logger.AuditLog(w, r, "WebDownloadZip", mustGetClaimsFromToken(r))
|
||||||
|
@ -1335,7 +1316,6 @@ func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) {
|
||||||
RespElements: extractRespElements(w),
|
RespElements: extractRespElements(w),
|
||||||
UserAgent: r.UserAgent(),
|
UserAgent: r.UserAgent(),
|
||||||
Host: host,
|
Host: host,
|
||||||
Port: port,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue