2018-08-26 20:20:47 -04:00
|
|
|
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
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
let usingVPN = false;
|
|
|
|
|
|
|
|
try {
|
2018-09-02 17:59:27 -04:00
|
|
|
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();
|
2018-08-26 20:20:47 -04:00
|
|
|
usingVPN = parsedJSON['success'] && parsedJSON['proxy'];
|
|
|
|
} catch (e) {
|
|
|
|
this.logger.WriteError(e.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usingVPN) {
|
2018-09-02 17:59:27 -04:00
|
|
|
this.logger.WriteInfo(origin + ' is using a VPN (' + origin.IPAddressString + ')');
|
2018-08-26 20:20:47 -04:00
|
|
|
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) {
|
2018-08-30 21:53:00 -04:00
|
|
|
this.checkForVpn(gameEvent.Origin);
|
2018-08-26 20:20:47 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoadAsync(manager) {
|
|
|
|
this.manager = manager;
|
|
|
|
this.logger = manager.GetLogger();
|
|
|
|
},
|
|
|
|
|
2018-08-30 21:53:00 -04:00
|
|
|
onUnloadAsync() { },
|
2018-08-26 20:20:47 -04:00
|
|
|
|
2018-08-30 21:53:00 -04:00
|
|
|
onTickAsync(server) { }
|
|
|
|
};
|