Skip to content

Commit

Permalink
Merge pull request #3 from Connatix/add-cnx-adapter
Browse files Browse the repository at this point in the history
include ipv6 in ip validation and add headers
  • Loading branch information
patrickszeleczki authored Oct 2, 2024
2 parents 28ed966 + b5f955d commit 4c7a620
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
14 changes: 13 additions & 1 deletion adapters/connatix/connatix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}}
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions adapters/connatix/connatixtest/exemplary/banner-web.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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
},
Expand Down
12 changes: 10 additions & 2 deletions adapters/connatix/connatixtest/exemplary/video-web.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 4c7a620

Please sign in to comment.