#!/usr/bin/gawk -f # # what-country.cgi -- 2008-08-19 # # IP geolocation CGI client for ip2cn-server # # Copyright (C) 2008 Grant Coady GPLv2 # BEGIN { printf "%s\r\n\r\n", "Content-type: text/plain" ARGV[ARGC++] = "/etc/ip2cn-server.conf" } /^inetport/ { service = "/inet/tcp/0/localhost/" $2 } END { print ENVIRON["REMOTE_ADDR"] |& service service |& getline printf "%s\r\n", $0 } # end