2018-09-04 13:40:29 -04:00
|
|
|
var plugin = {
|
2018-08-26 20:20:47 -04:00
|
|
|
author: 'RaidMax',
|
2019-05-29 17:55:35 -04:00
|
|
|
version: 1.2,
|
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;
|
2021-04-07 09:47:42 -04:00
|
|
|
var userAgent = 'IW4MAdmin-' + this.manager.GetApplicationSettings().Configuration().Id;
|
|
|
|
cl.DefaultRequestHeaders.Add('User-Agent', userAgent);
|
2018-09-04 13:40:29 -04:00
|
|
|
var co = re.Content;
|
|
|
|
var parsedJSON = JSON.parse(co.ReadAsStringAsync().Result);
|
|
|
|
co.Dispose();
|
|
|
|
re.Dispose();
|
|
|
|
cl.Dispose();
|
2021-04-07 09:47:42 -04:00
|
|
|
usingVPN = true;//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 + ')');
|
2021-04-07 09:47:42 -04:00
|
|
|
var contactUrl = this.manager.GetApplicationSettings().Configuration().ContactUri;
|
|
|
|
var additionalInfo = '';
|
|
|
|
if (contactUrl) {
|
|
|
|
additionalInfo = _localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED_INFO"] + ' ' + contactUrl;
|
|
|
|
}
|
|
|
|
origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"] + ' ' + additionalInfo, _IW4MAdminClient);
|
2018-08-26 20:20:47 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
onEventAsync: function (gameEvent, server) {
|
2019-05-29 17:55:35 -04:00
|
|
|
// join event
|
|
|
|
if (gameEvent.Type === 4) {
|
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
|
|
|
};
|