2018-09-04 13:40:29 -04:00
|
|
|
var plugin = {
|
2018-08-26 20:20:47 -04:00
|
|
|
author: 'RaidMax',
|
2019-04-18 15:19:50 -04:00
|
|
|
version: 1.1,
|
2018-09-04 13:40:29 -04:00
|
|
|
name: 'VPN Detection Plugin',
|
2018-08-26 20:20:47 -04:00
|
|
|
|
|
|
|
manager: null,
|
|
|
|
logger: null,
|
|
|
|
vpnExceptionIds: [],
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
checkForVpn: function (origin) {
|
|
|
|
var exempt = false;
|
2018-08-26 20:20:47 -04:00
|
|
|
// prevent players that are exempt from being kicked
|
2018-08-30 21:53:00 -04:00
|
|
|
this.vpnExceptionIds.forEach(function (id) {
|
2018-08-26 20:20:47 -04:00
|
|
|
if (id === origin.ClientId) {
|
|
|
|
exempt = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (exempt) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
var usingVPN = false;
|
2018-08-26 20:20:47 -04:00
|
|
|
|
|
|
|
try {
|
2018-09-04 13:40:29 -04:00
|
|
|
var cl = new System.Net.Http.HttpClient();
|
|
|
|
var re = cl.GetAsync('https://api.xdefcon.com/proxy/check/?ip=' + origin.IPAddressString).Result;
|
|
|
|
var co = re.Content;
|
|
|
|
var parsedJSON = JSON.parse(co.ReadAsStringAsync().Result);
|
|
|
|
co.Dispose();
|
|
|
|
re.Dispose();
|
|
|
|
cl.Dispose();
|
|
|
|
usingVPN = parsedJSON.success && parsedJSON.proxy;
|
2018-08-26 20:20:47 -04:00
|
|
|
} catch (e) {
|
2019-04-18 15:19:50 -04:00
|
|
|
this.logger.WriteWarning('There was a problem checking client IP for VPN ' + e.message);
|
2018-08-26 20:20:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (usingVPN) {
|
2018-09-02 17:59:27 -04:00
|
|
|
this.logger.WriteInfo(origin + ' is using a VPN (' + origin.IPAddressString + ')');
|
2018-10-07 22:34:30 -04:00
|
|
|
origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], _IW4MAdminClient);
|
2018-08-26 20:20:47 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
onEventAsync: function (gameEvent, server) {
|
2018-08-26 20:20:47 -04:00
|
|
|
// connect event
|
|
|
|
if (gameEvent.Type === 3) {
|
2018-08-30 21:53:00 -04:00
|
|
|
this.checkForVpn(gameEvent.Origin);
|
2018-08-26 20:20:47 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
onLoadAsync: function (manager) {
|
2018-08-26 20:20:47 -04:00
|
|
|
this.manager = manager;
|
2018-10-06 16:31:05 -04:00
|
|
|
this.logger = manager.GetLogger(0);
|
2018-08-26 20:20:47 -04:00
|
|
|
},
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
onUnloadAsync: function () {
|
|
|
|
},
|
2018-08-26 20:20:47 -04:00
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
onTickAsync: function (server) {
|
|
|
|
}
|
2018-08-30 21:53:00 -04:00
|
|
|
};
|