root/vidalia/tags/vidalia-0.0.15/pkg/build-geoip-cache.sh
| Revision 1623, 1.5 kB (checked in by edmanm, 2 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | #!/bin/sh |
| 2 | # |
| 3 | # $Id$ |
| 4 | # |
| 5 | # Vidalia is distributed under the following license: |
| 6 | # |
| 7 | # Copyright (C) 2006, Matt Edman, Justin Hipple |
| 8 | # |
| 9 | # This program is free software; you can redistribute it and/or |
| 10 | # modify it under the terms of the GNU General Public License |
| 11 | # as published by the Free Software Foundation; either version 2 |
| 12 | # of the License, or (at your option) any later version. |
| 13 | # |
| 14 | # This program is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | # GNU General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
| 20 | # along with this program; if not, write to the Free Software |
| 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 22 | # 02110-1301, USA. |
| 23 | ################################################################# |
| 24 | |
| 25 | DIRURL="http://tor.noreply.org/tor/status/all" |
| 26 | GEOIPURL="http://geoip.vidalia-project.net/cgi-bin/geoip" |
| 27 | CACHEFILE="geoip-cache" |
| 28 | |
| 29 | if [ "$1" == "-notimestamp" -o "$1" == "--notimestamp" ]; then |
| 30 | timestamp="" |
| 31 | else |
| 32 | timestamp=":$(date +%s)" |
| 33 | fi |
| 34 | |
| 35 | # Fetch a list of server IP addresses |
| 36 | ipaddrs=$(wget -q -O - "$DIRURL" | awk '$1 == "r" { print $7 }' | sort | uniq | tr "\n" ",") |
| 37 | |
| 38 | # Get GeoIP information for each IP address |
| 39 | geoips=$(wget -q -O - --post-data="ip=$ipaddrs" "$GEOIPURL") |
| 40 | |
| 41 | # Cache the GeoIP information with timestamps |
| 42 | IFS=$'\n' |
| 43 | rm -f $CACHEFILE |
| 44 | for geoip in $geoips; do |
| 45 | echo "$geoip""$timestamp" >> "$CACHEFILE" |
| 46 | done |
Note: See TracBrowser
for help on using the browser.
