Ulysses

Ulysses Stuff => Releases => Topic started by: Bytewave on October 25, 2014, 03:23:20 PM

Title: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 25, 2014, 03:23:20 PM
Hello, everyone!

I'd recently made a geo-IP location tool for ULX, and thought I'd release it for public use.

So, without further adieu, I present ULX GeoIP.

This tool allows you to query a GeoIP database (the script uses this one (http://ip-api.com/)) to get semi-detailed geographical location on a user.

The applications? Lag testing, debugging, et cetera.

BIG SCARY NOTE: Please provide some kind of easily visible disclaimer to your server's MOTD or similar to prevent potential legal issues. I take no responsibility for misuse of this addon.

This script is provided free of charge, under the note that- if used maliciously, it could result in legal action against you. Again, I take no responsibility for the misuse of this script.

Some information this script provides (results may vary depending on ISP and country, also not 100% accurate):

Commands:
ulx geoip <player>/!geoip <player> - Print the GeoIP data of a user to your console.

This script works for both client and server. Default access is for superadmins only.

Links:

I will reiterate once more: I do not take any responsibility whatsoever for the misuse of this addon. Any and all misuse is the fault of the end-user.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Megiddo on October 25, 2014, 04:52:08 PM
This is pretty sweet!
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 25, 2014, 04:56:03 PM
This is pretty sweet!
Happy to hear that!
I'd used FreeGeoIP for quite a while, and- because they have a REST API- thought "Hey, why not build a Lua script so I don't have to tab out every time I want to get someone's location (for lag purposes)?"
So I did, and here we are.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JamminR on October 25, 2014, 07:17:59 PM
Without me going and looking, do they have a limited TOS?
Meaning, only so many look ups per day/timeframe?
I've seen server IPs banned from some tools like this due to TOS abuse.

Either way, nice idea.
If there is a TOS limit, perhaps add the limit to the script.
Would hate to hit it, but, at least it would tell us instead of an odd error/complaint here asking 'it breaks randomly'

EDIT - WOW.
1) It doesn't just list the lat/long of where my ISP is located, but, it lists the actual location of where the cable plant office/ splits for of my IP (I've rarely seen this accuracy in geo services)
2) Quote from the site "Limits - API usage is limited to 10,000 queries per hour."

Though it might be good to include that in the script anyway, 10000 is likely never to be hit, even if one were to set up the command for all player joins.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Decicus on October 25, 2014, 07:23:17 PM
Without me going and looking, do they have a limited TOS?
Meaning, only so many look ups per day/timeframe?
I've seen server IPs banned from some tools like this due to TOS abuse.

Either way, nice idea.
If there is a TOS limit, perhaps add the limit to the script.
Would hate to hit it, but, at least it would tell us instead of an odd error/complaint here asking 'it breaks randomly'
Their website (http://freegeoip.net/) says it's 10,000 queries per hour, so it's highly unlikely anyone is going to hit that.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JamminR on October 25, 2014, 07:54:17 PM
Sadly, it doesn't seem to support IPv6 (not that many sites do)
It's my understanding that one of the first 4 :blah: subsets in a ipv6 address actually tells some type of location information.
2601:e:c580:cb2:d94b:xxxx:yyyy:zzzz (part of my current v6 ip)
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 25, 2014, 08:47:30 PM
Sadly, it doesn't seem to support IPv6 (not that many sites do)
It's my understanding that one of the first 4 :blah: subsets in a ipv6 address actually tells some type of location information.
2601:e:c580:cb2:d94b:xxxx:yyyy:zzzz (part of my current v6 ip)

Possibly.
I might try and find a GeoIP database for IPv6 and implement it, based on if a : is detected. I'll look into that.
Without me going and looking, do they have a limited TOS?
Meaning, only so many look ups per day/timeframe?
I've seen server IPs banned from some tools like this due to TOS abuse.

Either way, nice idea.
If there is a TOS limit, perhaps add the limit to the script.
Would hate to hit it, but, at least it would tell us instead of an odd error/complaint here asking 'it breaks randomly'

EDIT - WOW.
1) It doesn't just list the lat/long of where my ISP is located, but, it lists the actual location of where the cable plant office/ splits for of my IP (I've rarely seen this accuracy in geo services)
2) Quote from the site "Limits - API usage is limited to 10,000 queries per hour."

Though it might be good to include that in the script anyway, 10000 is likely never to be hit, even if one were to set up the command for all player joins.
That's why I never included it- 10,000 shouldn't ever be hit in an hour, even by large servers. I'll add that limit, I guess, if the issue arises.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 25, 2014, 09:29:17 PM
Looks like I may have found an IPv6 GeoIP database with a Rest API. Gonna implement this into the script here shortly.

EDIT: Though it might take a few tries to get right... problem I currently face is trying to discern whether an IP is IPv6 or IPv4. Was going to see if a ":" existed in the IP, but then I realized LocalPlayer():IPAddress() returns IP + port... making the returned string "127.0.0.1:27005". :/
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JamminR on October 26, 2014, 12:06:36 PM
Does Gmod/Source server even allow for IPv6?
Though adding it would be a nice future proof...I think my statement was more a note than a 'it should be included'.

As for testing for it, check the IP for more than one colon and or no periods. Periods, to my knowledge, aren't in ipv6.
Presume end colon would be the port # after.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 26, 2014, 12:47:05 PM
Does Gmod/Source server even allow for IPv6?
Though adding it would be a nice future proof...I think my statement was more a note than a 'it should be included'.

As for testing for it, check the IP for more than one colon and or no periods. Periods, to my knowledge, aren't in ipv6.
Presume end colon would be the port # after.
Yeah... see this is why I shouldn't respond to a post at 10:34 PM CT. Obvious answer is obvious. :/
I'll check and see-- mostly by trail and error, because nothing is well-documented in the world of the Garry's Mod Wiki.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Megiddo on October 26, 2014, 01:01:23 PM
Based on some quick Googling, it doesn't look like Valve has enabled support for IPv6 yet.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 26, 2014, 03:43:41 PM
Based on some quick Googling, it doesn't look like Valve has enabled support for IPv6 yet.
Well then, looks like I won't need to add support for it yet. :P
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Chironex on October 29, 2014, 06:18:47 PM
Personally I do it like this:

Code: [Select]
http.Fetch(
    "http://www.telize.com/geoip/" .. ( ply:IPAddress():match("%d+%.%d+%.%d+%.%d+") or "" ),
    function( data )
        ply.GeoIpData = util.JSONToTable( data )
        ...

I find Telize superior to any other free geoip tools (because I think I tried them all) ;)

Karma++ for a good try ;)

Edit: also avoid the use of SendLua, use net messages instead.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on October 31, 2014, 04:07:49 PM
Personally I do it like this:

Code: [Select]
http.Fetch(
    "http://www.telize.com/geoip/" .. ( ply:IPAddress():match("%d+%.%d+%.%d+%.%d+") or "" ),
    function( data )
        ply.GeoIpData = util.JSONToTable( data )
        ...

I find Telize superior to any other free geoip tools (because I think I tried them all) ;)

Karma++ for a good try ;)

Edit: also avoid the use of SendLua, use net messages instead.

The code was more or less hastily scrapped together at midnight, and works now. Will refactor and add net messages in next update.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on November 08, 2014, 10:09:42 AM
After a bit of fiddling I think I've set up a system for net messages. Haven't tested it yet, still doing code work for my server.

Anyone willing to do a beta for me?
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on November 09, 2014, 12:33:46 PM
Update v1.0.1.0

Added net messages instead of SendLua, and changed GeoIP database. It's an easy swap back if you choose.
https://github.com/BytewaveMLP/ULXGeoIP/releases/tag/v1.0.1.0
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JabbaTheWut on January 13, 2015, 07:25:31 PM
How do I install it? I put the lua folder in the ulx lua folder but it did nothing. What I am i doing wrong??
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on January 13, 2015, 07:29:25 PM
How do I install it? I put the lua folder in the ulx lua folder but it did nothing. What I am i doing wrong??
Just extract the zip, drop the ULXGeoIP-master folder in your /addons/ folder and reboot your server.

NOTE: If your server runs on Linux, make sure to rename the folder to something in all lowercase.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JamminR on January 13, 2015, 08:15:55 PM
And never put stuff in the ulx\lua folder unless specifically told to by a ulx module developer.
(And then come tell us the bad developer telling you to, because, they should be using better practice)
/addons is virtualised for a reason.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JabbaTheWut on January 28, 2015, 05:25:25 PM
I cant target anyone when I try to I get an error: Command "ulx geoip", argument #1: you cannot target this person
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on January 28, 2015, 07:41:33 PM
I cant target anyone when I try to I get an error: Command "ulx geoip", argument #1: you cannot target this person

Sure your can_target is set correctly? As far as I know, this runs fine in my environment.
EDIT: Try re-cloning now. I changed a bit of the code that may have been causing issues.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: idontcare on November 18, 2015, 06:06:46 AM
The public API will permanently shut down on November 15th, 2015. More information can be found here.

To continue using Telize after this date, please spin up your own instance or subscribe to a paid plan.

http://www.telize.com/ (http://www.telize.com/)
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on November 18, 2015, 08:44:53 AM
The public API will permanently shut down on November 15th, 2015. More information can be found here.

To continue using Telize after this date, please spin up your own instance or subscribe to a paid plan.

http://www.telize.com/ (http://www.telize.com/)
Fortunately the GeoIP database is easy to change; it just parses the JSON object to a Lua array and prints it out. I can go ahead and revert it to FreeGeoIP (http://freegeoip.net/). Thank you for the heads up!
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: BobTheDuck on February 18, 2016, 04:40:06 PM
Fixed?
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on February 18, 2016, 04:58:28 PM
Fixed?
Fixed? Was it ever broken?
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: BobTheDuck on February 19, 2016, 08:26:23 AM
I get an error when using it.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on February 19, 2016, 02:46:45 PM
I get an error when using it.
Please post your error here. I can't do much more unless I have the error text in front of me.
Last I checked, the addon was working fine.
Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: JamminR on April 10, 2016, 10:28:25 AM
freegeoip.net no longer exists/connects for me.
telize.com no longer allows free lookups.

Title: Re: ULX GeoIP -- Look up geographical information on a user based on their IP
Post by: Bytewave on April 10, 2016, 10:51:57 AM
freegeoip.net no longer exists/connects for me.
telize.com no longer allows free lookups.


FreeGeoIP's been kinda flaky last I checked. I think there's another API out there I could swap over to.