From b5f955ddc23f405c459313784a0c8594b4102481 Mon Sep 17 00:00:00 2001 From: Patrick Szeleczki Date: Wed, 2 Oct 2024 12:57:30 +0300 Subject: [PATCH] include ipv6 in ip validation and add headers --- adapters/connatix/connatix.go | 14 +++++++++++++- .../connatixtest/exemplary/banner-web.json | 10 ++++++++-- .../connatix/connatixtest/exemplary/video-web.json | 12 ++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/adapters/connatix/connatix.go b/adapters/connatix/connatix.go index 772d6853b0e..2c11f06ae50 100644 --- a/adapters/connatix/connatix.go +++ b/adapters/connatix/connatix.go @@ -39,7 +39,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E }} } - if request.Device != nil && request.Device.IP == "" { + if request.Device != nil && request.Device.IP == "" && request.Device.IPv6 == "" { return nil, []error{&errortypes.BadInput{ Message: "Device IP is required", }} @@ -155,6 +155,18 @@ func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, uri string headers.Add("Content-Type", "application/json") headers.Add("Accept", "application/json") + if len(request.Device.UA) > 0 { + headers.Add("User-Agent", request.Device.UA) + } + + if len(request.Device.IPv6) > 0 { + headers.Add("X-Forwarded-For", request.Device.IPv6) + } + + if len(request.Device.IP) > 0 { + headers.Add("X-Forwarded-For", request.Device.IP) + } + for impsLeft { endInd := startInd + maxImpsPerReq if endInd >= len(imps) { diff --git a/adapters/connatix/connatixtest/exemplary/banner-web.json b/adapters/connatix/connatixtest/exemplary/banner-web.json index e375393c069..a48ef5b1be5 100644 --- a/adapters/connatix/connatixtest/exemplary/banner-web.json +++ b/adapters/connatix/connatixtest/exemplary/banner-web.json @@ -3,7 +3,7 @@ "id": "some-request-id", "device": { "ua": "test-user-agent", - "ip": "123.123.123.123", + "ipv6": "test-ip-v6", "language": "en", "dnt": 0 }, @@ -37,11 +37,17 @@ { "expectedRequest": { "uri": "http://example.com", + "headers": { + "Content-Type": ["application/json"], + "X-Forwarded-For": ["test-ip-v6"], + "Accept": ["application/json"], + "User-Agent": ["test-user-agent"] + }, "body": { "id": "some-request-id", "device": { "ua": "test-user-agent", - "ip": "123.123.123.123", + "ipv6": "test-ip-v6", "language": "en", "dnt": 0 }, diff --git a/adapters/connatix/connatixtest/exemplary/video-web.json b/adapters/connatix/connatixtest/exemplary/video-web.json index 544a14b136a..b1ab16d0b9a 100644 --- a/adapters/connatix/connatixtest/exemplary/video-web.json +++ b/adapters/connatix/connatixtest/exemplary/video-web.json @@ -3,7 +3,8 @@ "id": "some-request-id", "device": { "ua": "test-user-agent", - "ip": "123.123.123.123", + "ip": "test-ip-v4", + "ipv6": "test-ip-v6", "language": "en", "dnt": 0 }, @@ -46,7 +47,8 @@ "id": "some-request-id", "device": { "ua": "test-user-agent", - "ip": "123.123.123.123", + "ip": "test-ip-v4", + "ipv6": "test-ip-v6", "language": "en", "dnt": 0 }, @@ -81,6 +83,12 @@ }, "tmax": 1000 }, + "headers": { + "Content-Type": ["application/json"], + "X-Forwarded-For": ["test-ip-v6", "test-ip-v4"], + "Accept": ["application/json"], + "User-Agent": ["test-user-agent"] + }, "impIDs":["some-impression-id"] }, "mockResponse": {