Add Country Code Support, power by cloudflare

This commit is contained in:
George Shammas 2015-03-04 08:15:24 -05:00
parent 2373062a39
commit c4b8b29681
2 changed files with 7 additions and 0 deletions

View File

@ -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"}) {

View File

@ -26,6 +26,9 @@
<li class="list-group-item">
<div class="col-sm-3">Remote Host</div><div class="col-sm-9">{{ .host }}</div>
</li>
<li class="list-group-item">
<div class="col-sm-3">Country Code</div><div class="col-sm-9">{{ .country_code }}</div>
</li>
<li class="list-group-item">
<div class="col-sm-3">User Agent</div><div class="col-sm-9">{{ .ua }}</div>
</li>
@ -66,6 +69,9 @@
<li class="list-group-item">
<div class="col-sm-4">$ curl ifconfig.io/host</div><div class="col-sm-8">{{ .host }}</div>
</li>
<li class="list-group-item">
<div class="col-sm-4">$ curl ifconfig.io/country_code</div><div class="col-sm-8">{{ .country_code }}</div>
</li>
<li class="list-group-item">
<div class="col-sm-4">$ curl ifconfig.io/ua</div><div class="col-sm-8">{{ .ua }}</div>
</li>