KF [Mutator] Another Country tags mut

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

King Sumo

FNG / Fresh Meat
Jan 8, 2011
505
15
0
Brazil
www.youtube.com
This mutator works with the help of nodejs which provides the GeoIP information via HTTP. This way the country database can be updated without changing the mutator or even without needing to restart the Killing Floor server.

Pros:
- Full country information for admins (City/Latitude/Longitude);
- The country database can be updated without restarting the KillingFloor server;
- The NodeJS application can serve several KillingFloor servers;
- Also for a farm of KF Servers the database can be updated with zero downtime;
- The NodeJS application is using native code (C++) for Country lookup;
- Automatic detection of LAN clients: they use ServerCountryTag config as tag (no need for Country lookup in this case);
- Support for other databases (IP2Location, WEBNet77, etc) can be added without touching Mutator source code.

Cons:
- Requires an additional application (NodeJS) running in the host;

INSTALL / RUNNING: (NodeJS app)

- LINUX (tested in Ubuntu 12.04.3 LTS):
1. Install prerequisites:
apt-get install nodejs npm g++ libgeoip1 libgeoip-dev

2. Copy the geoLiteCityApp.js to some folder;

3. Install the restify/geoip modules in the same folder:
cd <path-to-your-geoLiteCityApp.js-file>
npm install restify
npm install geoip@0.4.5

3. Download the Country database and gunzip the file:
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

4. Run the NodeJS application:
node geoLiteCityApp.js

5. Test if the NodeJS application is ok, by opening the following link in browser:
http://127.0.0.1:3000/geoip/8.8.8.8

- WINDOWS:
See next post.

INSTALL / RUNNING: (KillingFloor server)
mutator: SumoCtryTags.SumoCtryTags
configuration: SumoCtryTags.ini
- if you have LAN users (including you) then change the ServerCountryTag;
- change the GeoIPServerAddress/GeoIPServerPort if you want to run the NodeJS application in other machine (see also "server.listen" in the javascript geoLiteCityApp.js)
- admins can see the full country/city/latitude information by typing:
mutate geoip

REMARKS:
- The geoLiteCityApp.js application is set to listen in localhost (127.0.0.1) - don't put this app in internet, in this case use at your own risk. This application needs some security hardening. See... this application is a HelloWorld like example...
- Use the geoipApp.js if you don't need/want the City information - in this case the database link is the following:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Good luck! :D

And OFC, thanks to Marco for the original KFCtryTags concept/idea :)
 

Attachments

  • SumoCtryTags.zip
    9.1 KB · Views: 0
Last edited:

King Sumo

FNG / Fresh Meat
Jan 8, 2011
505
15
0
Brazil
www.youtube.com
Here are the install instructions for Windows :)

1. Install the "Visual C++ Redistributable for VS2012" from Microsoft - download the x86 version (32-bit):
http://www.microsoft.com/en-us/download/details.aspx?id=30679
(or click here to download from my dropbox)
DOWNLOAD THE 32-BIT (X86) VERSION

2. Download the ALL-IN-ONE package (nodejs+geoip+restify) from here:
https://dl.dropboxusercontent.com/u/47693068/SumoCtryTags/SumoCtryTagsServer.zip

3. Unzip the SumoCtryTagsServer.zip to some folder;

4. OPTIONAL: you can update the "GeoLiteCity.dat" geoip database (the database is from 2013-12-10), download from here:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

5. Click in the "start-server" BAT file to run the server, see the API in-action by using the following link:
http://127.0.0.1:3000/geoip/7.7.7.7

Expected output:
Code:
"country_code":"US","country_code3":"USA","country_name":"United States","region":"OH","city":"Columbus","postal_code":"43218","latitude":39.96120071411133,"longitude":-82.9988021850586,"metro_code":535,"dma_code":535,"area_code":614,"continent_code":"NA","time_zone":"America/New_York"}

6. Now the SumoCtryTags mutator is ready to retrieve the geo-location information, start the KillingFloor server and check if everything is ok.

PS.
- I have tested this in Windows 7 and in Windows Vista.
- geoip location information changes frequently, just update the database:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
 
Last edited:

King Sumo

FNG / Fresh Meat
Jan 8, 2011
505
15
0
Brazil
www.youtube.com
Yes, I guess it is compatible from windows XP and newer (both 32bit/64bit), needs testing...
In case of problems, one can install nodejs from http://nodejs.org/ - In this case just erase the node.exe file.

Notice the main logic is inside the "geoLiteCityApp.js" server-side javascript file. Today we have several apps other than nodejs which can be used, check here.
The javascript just tells to NodeJS to start the HTTP server on LOCALHOST and provide a simple REST API (using the 'restify' JS module). The geo-location lookup is done by the 'geoip' module.
The KillingFloor server just requests the geoip information by using that REST API (HTTP get /geoip/<IP-Address>).

Below is the geoLiteCityApp.js JS file content:
Code:
var geoip = require('geoip');
var City = geoip.City;
var CityDB = new City('GeoLiteCity.dat');
var http = require('http');
var sys = require('util');

var restify = require('restify');
var server = restify.createServer({ name: 'my-api' })

server.get('/geoip/:id', function (req, res, next) {
  var Obj = CityDB.lookupSync(req.params.id);
  res.send(Obj)
})

server.listen(3000, 'localhost', function () {
  console.log('%s listening at %s', server.name, server.url)
})
 

FluX

Grizzled Veteran
Oct 26, 2010
5,392
233
63
www.fluxiserver.co.uk
I tell you what Sumo, this is some decent work you are bringing out but I have one problem with them all. Aren't they a little too complicated to be a simple mod? I mean they tend to need programs that have their own code to use with etc etc. Not saying anything bad, just thinking it's too much just to add the mod to a server.

my opinion and it's kinda what keeps me from using this sorta thing.
 

King Sumo

FNG / Fresh Meat
Jan 8, 2011
505
15
0
Brazil
www.youtube.com
This is why I have released the mutator here at the Coding forum. :)

The main problem is the database which changes frequently - look the complains from users at Marco's Country Tags thread.
It is not possible to read the geoiplocation database by using UnrealScript (it is not possible to open files by using UnrealScript), so a kind of database preprocessing is required to create a suitable .INI file. Marco can confirm this (he is doing exactly this way in the Country Tags Mut). So the preprocessing also requires an additional program right? Updating the preprocessed database (.INI) will require a KF server restart.
I know, other option can be upload the database file to the KF Server by using TCP sockets and then do the preprocessing using unrealscript.

There's no easy way :) The mutator adds a simple functionality which requires alot of background.
 

Boltte

FNG / Fresh Meat
Mar 5, 2014
168
3
0
Perth, WA
King Sumo;n2291660 said:

Cool thanks!

Erm, shows me as BRA which would be Brazil? I'm not in Brazil...... Nevermind, I can set that through the ServerCountryTag config. :eek:

Also for the geoipApp.js and geoLiteCityApp.js, I need both of these along with SumoCtryTags.ini, SumoCtryTags.u and SumoCtryTags.ucl in the system folder right?

King Sumo;n2291660 said:
- The country database can be updated without restarting the KillingFloor server;
- Also for a farm of KF Servers the database can be updated with zero downtime;
But wouldn't you need to shutdown all KF and the node server for the changes to take place? Because if you're updating the dats file, you need to shutdown server?

Will test some more on my dedicated server to see if player's location tag is set correctly or not and not shown up as [???] or in a different country to what they're supposed to be in.

EDIT: I get
Code:
 {"country_code":"US","country_code3":"USA","country_name":"United States","latitude":37.750999450683594,"longitude":-97.8219985961914,"continent_code":"NA"}
instead of:
Code:
 {"country_code":"US","country_code3":"USA","country_name":"United States","region":"OH","city":"Columbus","postal_code":"43218","latitude":39.96120071411133,"longitude":-82.9988021850586,"metro_code":535,"dma_code":535,"area_code":614,"continent_code":"NA","time_zone":"America/New_York"}
when entering http://127.0.0.1:3000/geoip/7.7.7.7 on firefox, which showed correctly on my home server, any ideas?

EDIT2: I have a question, what if I already have Visual Studio installed but it's NOT 2012 but either a newer edition or older edition, like 2008 or 2017? Also another question, what if I had the 64-bit version installed already, do I still need to install the 32-bit version as well? Or....?
 
Last edited:

Boltte

FNG / Fresh Meat
Mar 5, 2014
168
3
0
Perth, WA
Ok, I guess I don't really need either geoipApp.js and or geoLiteCityApp.js in system folder(because I just tested it out and works fine without needing those two in it), they're for the server tag folder, right? Mmm.....

Also, this mut is greylisted for anyone else attempting the same as me....and wanting to know before downloading and using....
 
Last edited: