Author Topic: IP to Country (GeoIP)  (Read 3666 times)

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-74
    • View Profile
IP to Country (GeoIP)
« on: December 22, 2011, 06:43:22 pm »
I've never worked with any C language, so I don't know how to build modules for LU, so I decided to take another route to getting a country name from an IP address. Currently, I am using a custom PHP socket server that listens on a certain port for incoming connections and data from already established connections.

As of now, the socket listens for something like "GEOIP 127.0.0.1". This server will send the name of the country back to the socket, which could be used to display a user's country on player join or something.

Anybody who is interested in using this, feel free. I am making this service public for all, so you can translate an IP to a country name in your script.

Here is a Squirrel snippet to help (if you need it):
Code: [Select]
function GeoIPProcess(socket,data)
{
LAST_COUNTRY <- data;
}

function onScriptLoad()
{
GeoIPSocket <- NewSocket("GeoIPProcess");
GeoIPSocket.Connect( "206.217.206.245", 2302 );
LAST_COUNTRY <- "";
}

function onPlayerConnect(player)
{
GeoIPSocket.Send("GEOIP " + player.IP);
}

function onPlayerJoin(player)
{
Message(player.Name + " has joined the server from " + LAST_COUNTRY,Colour(255,255,255));
}

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: IP to Country (GeoIP)
« Reply #1 on: December 23, 2011, 01:20:18 pm »
First of all, even though you have no experience in making a Module, this is totally the wrong way to do it.
PHP wasn't made for a server listener, You can better parse an already existing site that gives you the country.
That squirrel snippet is wrongly made too. If 2 players join at the same time, and one request is faster then other one, the country names can be switched. Use arrays and player IDs for this.

VetalYA

  • Guest
Re: IP to Country (GeoIP)
« Reply #2 on: December 24, 2011, 12:38:49 am »
I find everything that you said is  correct, but do not be so angry, it's only initial release :)

SugarD

  • Asshat Gaming Founder
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: IP to Country (GeoIP)
« Reply #3 on: December 24, 2011, 04:35:20 am »
Jeez Thijn, why are you so upset? D:

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: IP to Country (GeoIP)
« Reply #4 on: December 24, 2011, 03:27:07 pm »
I wasn't upset, Its just my honest opinion..

SugarD

  • Asshat Gaming Founder
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: IP to Country (GeoIP)
« Reply #5 on: December 24, 2011, 05:43:32 pm »
I wasn't upset, Its just my honest opinion..
Your opinion became slightly irritated then D:

 

© Liberty Unleashed Team.