@@ -196,6 +196,8 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
196196 return
197197 }
198198
199+ injectServerIP (r , req , deps .privateNetworkIPValidator )
200+
199201 if rejectErr := hookexecution .FindFirstRejectOrNil (errL ); rejectErr != nil {
200202 ao .RequestWrapper = req
201203 labels , ao = rejectAuctionRequest (* rejectErr , w , hookExecutor , req .BidRequest , account , labels , ao )
@@ -2101,3 +2103,30 @@ func (deps *endpointDeps) processGDPR(req *openrtb_ext.RequestWrapper, accountGD
21012103
21022104 return tcf2Config , gdprSignal , gdprEnforced , gdprErrs
21032105}
2106+
2107+ func injectServerIP (httpReq * http.Request , r * openrtb_ext.RequestWrapper , ipValidator iputil.IPValidator ) {
2108+ if ip , _ := httputil .FindIP (httpReq , ipValidator ); ip != nil {
2109+ reqExt , err := r .GetRequestExt ()
2110+ if err != nil {
2111+ return
2112+ }
2113+ extMap := reqExt .GetExt ()
2114+
2115+ var mspExt map [string ]interface {}
2116+ if val , ok := extMap ["msp" ]; ok {
2117+ if err := json .Unmarshal (val , & mspExt ); err != nil {
2118+ mspExt = make (map [string ]interface {})
2119+ }
2120+ } else {
2121+ mspExt = make (map [string ]interface {})
2122+ }
2123+
2124+ mspExt ["server_ip" ] = ip .String ()
2125+
2126+ if mspBytes , err := json .Marshal (mspExt ); err == nil {
2127+ extMap ["msp" ] = json .RawMessage (mspBytes )
2128+ reqExt .SetExt (extMap )
2129+ r .RebuildRequest ()
2130+ }
2131+ }
2132+ }
0 commit comments