IW4M-Admin/Plugins/ScriptPlugins/VPNDetection.js
RaidMax e77ef69ee8 Added additional properties method to allow easier extension to client properties
updated VPN plugin to use WebClient
message is sent to client trying to execute commands before they are authenticated
fixed rare issue with ToAdmins failing
record bullet distance fraction for client kills (_customcallbacks)
change client level/permissions through webfront
ability to tempban through webfront
2018-09-02 16:59:27 -05:00

63 lines
1.7 KiB
JavaScript

const plugin = {
author: 'RaidMax',
version: 1.0,
name: 'VPN Kick Plugin',
manager: null,
logger: null,
vpnExceptionIds: [],
checkForVpn(origin) {
let exempt = false;
// prevent players that are exempt from being kicked
this.vpnExceptionIds.forEach(function (id) {
if (id === origin.ClientId) {
exempt = true;
return false;
}
});
if (exempt) {
return;
}
let usingVPN = false;
try {
let cl = new System.Net.Http.HttpClient();
let re = cl.GetAsync('https://api.xdefcon.com/proxy/check/?ip=' + origin.IPAddressString).Result;
let co = re.Content;
let parsedJSON = JSON.parse(co.ReadAsStringAsync().Result);
//co.Dispose();
//re.Dispose();
//cl.Dispose();
usingVPN = parsedJSON['success'] && parsedJSON['proxy'];
} catch (e) {
this.logger.WriteError(e.message);
}
if (usingVPN) {
this.logger.WriteInfo(origin + ' is using a VPN (' + origin.IPAddressString + ')');
let library = importNamespace('SharedLibraryCore');
let kickOrigin = new library.Objects.Player();
kickOrigin.ClientId = 1;
origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], kickOrigin);
}
},
onEventAsync(gameEvent, server) {
// connect event
if (gameEvent.Type === 3) {
this.checkForVpn(gameEvent.Origin);
}
},
onLoadAsync(manager) {
this.manager = manager;
this.logger = manager.GetLogger();
},
onUnloadAsync() { },
onTickAsync(server) { }
};