2022-03-23 14:34:04 -04:00
|
|
|
const commands = [{
|
|
|
|
name: "whitelistvpn",
|
|
|
|
description: "whitelists a player's client id from VPN detection",
|
|
|
|
alias: "wv",
|
|
|
|
permission: "SeniorAdmin",
|
|
|
|
targetRequired: true,
|
|
|
|
arguments: [{
|
|
|
|
name: "players",
|
|
|
|
required: true
|
|
|
|
}],
|
|
|
|
execute: (gameEvent) => {
|
|
|
|
plugin.vpnExceptionIds.push(gameEvent.Target.ClientId);
|
|
|
|
plugin.configHandler.SetValue('vpnExceptionIds', plugin.vpnExceptionIds);
|
|
|
|
|
|
|
|
gameEvent.Origin.Tell(`Successfully whitelisted ${gameEvent.Target.Name}`);
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
const plugin = {
|
2018-08-26 20:20:47 -04:00
|
|
|
author: 'RaidMax',
|
2022-03-23 14:34:04 -04:00
|
|
|
version: 1.3,
|
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) {
|
2022-03-23 14:34:04 -04:00
|
|
|
let 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) {
|
2022-03-23 14:34:04 -04:00
|
|
|
this.logger.WriteInfo(`${origin} is whitelisted, so we are not checking VPN status`);
|
2018-08-26 20:20:47 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-23 14:34:04 -04:00
|
|
|
let usingVPN = false;
|
2018-08-26 20:20:47 -04:00
|
|
|
|
|
|
|
try {
|
2022-03-23 14:34:04 -04:00
|
|
|
const cl = new System.Net.Http.HttpClient();
|
|
|
|
const re = cl.GetAsync(`https://api.xdefcon.com/proxy/check/?ip=${origin.IPAddressString}`).Result;
|
|
|
|
const userAgent = `IW4MAdmin-${this.manager.GetApplicationSettings().Configuration().Id}`;
|
2021-04-07 09:47:42 -04:00
|
|
|
cl.DefaultRequestHeaders.Add('User-Agent', userAgent);
|
2022-03-23 14:34:04 -04:00
|
|
|
const co = re.Content;
|
|
|
|
const parsedJSON = JSON.parse(co.ReadAsStringAsync().Result);
|
2018-09-04 13:40:29 -04:00
|
|
|
co.Dispose();
|
|
|
|
re.Dispose();
|
|
|
|
cl.Dispose();
|
2021-04-07 10:53:32 -04:00
|
|
|
usingVPN = parsedJSON.success && parsedJSON.proxy;
|
2018-08-26 20:20:47 -04:00
|
|
|
} catch (e) {
|
2022-03-23 14:34:04 -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 + ')');
|
2022-03-23 14:34:04 -04:00
|
|
|
const contactUrl = this.manager.GetApplicationSettings().Configuration().ContactUri;
|
|
|
|
let additionalInfo = '';
|
2021-04-07 09:47:42 -04:00
|
|
|
if (contactUrl) {
|
2022-03-23 14:34:04 -04:00
|
|
|
additionalInfo = _localization.LocalizationIndex['SERVER_KICK_VPNS_NOTALLOWED_INFO'] + ' ' + contactUrl;
|
2021-04-07 09:47:42 -04:00
|
|
|
}
|
2022-03-23 14:34:04 -04:00
|
|
|
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
|
2022-03-23 14:34:04 -04:00
|
|
|
if (gameEvent.TypeName === 'Join') {
|
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);
|
2022-03-23 14:34:04 -04:00
|
|
|
|
|
|
|
this.configHandler = _configHandler;
|
|
|
|
this.configHandler.GetValue('vpnExceptionIds').forEach(element => this.vpnExceptionIds.push(element));
|
|
|
|
this.logger.WriteInfo(`Loaded ${this.vpnExceptionIds.length} ids into whitelist`);
|
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) {
|
|
|
|
}
|
2022-03-23 14:34:04 -04:00
|
|
|
};
|