-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
239 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/geoip-lookup-service | ||
**/geoip-lookup | ||
**/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
package cnf | ||
|
||
const PORT = 7069 | ||
|
||
var LOOKUP_MAPPING = map[uint8]interface{}{ | ||
DB_TYPE_IPINFO: map[string]interface{}{ | ||
"country_asn": IPINFO_COUNTRY_ASN, | ||
"country": IPINFO_COUNTRY, | ||
"city": IPINFO_CITY, | ||
"asn": IPINFO_ASN, | ||
"privacy": IPINFO_PRIVACY, | ||
}, | ||
DB_TYPE_MAXMIND: map[string]interface{}{ | ||
"country_asn": nil, | ||
"country": MAXMIND_COUNTRY, | ||
"city": MAXMIND_CITY, | ||
"asn": MAXMIND_ASN, | ||
"privacy": MAXMIND_PRIVACY, | ||
}, | ||
} | ||
|
||
var LOOKUP = LOOKUP_MAPPING[DB_TYPE].(map[string]interface{}) | ||
const VERSION = 0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
PORT=10069 | ||
|
||
DB_TYPE='ipinfo' | ||
if [ -n "$1" ] | ||
then | ||
DB_TYPE="$1" | ||
fi | ||
|
||
DB_DIR='/etc/geoip' | ||
if [ -n "$2" ] | ||
then | ||
DB_DIR="$2" | ||
fi | ||
|
||
set -u | ||
|
||
DB_CO="${DB_DIR}/${DB_TYPE}_country.mmdb" | ||
DB_AS="${DB_DIR}/${DB_TYPE}_asn.mmdb" | ||
DB_CI="${DB_DIR}/${DB_TYPE}_city.mmdb" | ||
|
||
if ! [ -f "$DB_CO" ] || ! [ -f "$DB_AS" ] || ([[ "$DB_TYPE" == "maxmind" ]] && ! [ -f "$DB_CI" ]) | ||
then | ||
echo "ERROR: Required databases missing (${DB_DIR}/${DB_TYPE}_*)" | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
binary="/tmp/geoip_lookup_$(date +"%s")" | ||
|
||
cd "$(dirname "$0")/../main" | ||
go build -o "$binary" | ||
chmod +x "$binary" | ||
|
||
echo "RUNNING GeoIP Lookup: ${DB_DIR}/${DB_TYPE}_*" | ||
"$binary" -t "$DB_TYPE" -p "$PORT" -country "$DB_CO" -asn "$DB_AS" -city "$DB_CI" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
cd "$(dirname "$0")" | ||
|
||
echo '' | ||
echo "### TESTING IPINFO DATBASES ###" | ||
|
||
./build_run.sh "ipinfo" > /dev/null & | ||
sleep 1 | ||
export DB_TYPE="IPINFO" | ||
./test_requests_base.sh | ||
./test_requests_ipinfo.sh | ||
|
||
pkill -f "/tmp/geoip_lookup_*" > /dev/null | ||
sleep 1 | ||
|
||
echo '' | ||
echo "### TESTING MAXMIND DATBASES ###" | ||
|
||
./build_run.sh "maxmind" > /dev/null & | ||
sleep 1 | ||
export DB_TYPE="MAXMIND" | ||
./test_requests_base.sh | ||
./test_requests_maxmind.sh | ||
|
||
pkill -f "/tmp/geoip_lookup_*" > /dev/null | ||
sleep 1 | ||
|
||
echo '' | ||
echo 'FINISHED' | ||
echo '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
|
||
echo "${DB_TYPE}: Testing COUNTRY" | ||
curl "http://127.0.0.1:10069/?ip=8.8.8.8&lookup=country" | ||
sleep 1 | ||
|
||
echo "${DB_TYPE}: Testing ASN" | ||
curl "http://127.0.0.1:10069/?ip=8.8.8.8&lookup=asn" | ||
sleep 1 |
Oops, something went wrong.