-1

I'm using Varnish4 with the geoip vmod and I'm trying to use client.ip as a string.

geoip.country_code(client.ip);

When doing this, I am presented with the error Wrong argument type. Expected STRING. Got IP.

If I really wanted I could just do something like

set req.http.X-Client-IP = client.ip;
geoip.country_code(req.http.X-Client-IP);

and the problem would go away but that doesn't seem like a clean implementation.

Is there a way to return client.ip as a string instead of type IP that doesn't involved setting another variable or is that the proper way to do that?

As a note, I'd prefer not to use req.http.X-Forwarded-For because I'm testing wether or not I get predictable results using that vs client.ip.

castis
  • 8,154
  • 4
  • 41
  • 63

1 Answers1

2

Turns out, you can just concat with a blank string to return a string.

set req.http.X-Country-Code = geoip.country_code("" + client.ip);
castis
  • 8,154
  • 4
  • 41
  • 63