From c4b8b29681f2140a4f5ca2fd7202c77330398d91 Mon Sep 17 00:00:00 2001 From: George Shammas Date: Wed, 4 Mar 2015 08:15:24 -0500 Subject: [PATCH] Add Country Code Support, power by cloudflare --- main.go | 1 + templates/index.html | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/main.go b/main.go index 6d521d6..ef7cc73 100644 --- a/main.go +++ b/main.go @@ -70,6 +70,7 @@ func mainHandler(c *gin.Context) { c.Set("mime", c.Request.Header.Get("Accept")) c.Set("referer", c.Request.Header.Get("Referer")) c.Set("forwarded", c.Request.Header.Get("X-Forwarded-For")) + c.Set("country_code", c.Request.Header.Get("CF-IPCountry")) // Only lookup hostname if the results are going to need it. if stringInSlice(fields[0], []string{"", "all", "host"}) { diff --git a/templates/index.html b/templates/index.html index fbf95bb..e61f2a3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -26,6 +26,9 @@
  • Remote Host
    {{ .host }}
  • +
  • +
    Country Code
    {{ .country_code }}
    +
  • User Agent
    {{ .ua }}
  • @@ -66,6 +69,9 @@
  • $ curl ifconfig.io/host
    {{ .host }}
  • +
  • +
    $ curl ifconfig.io/country_code
    {{ .country_code }}
    +
  • $ curl ifconfig.io/ua
    {{ .ua }}