From fc13363c9c03c9d30077fed8efc2ceb707a947f3 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 7 Apr 2021 08:47:42 -0500 Subject: [PATCH] add user agent header for vpn detection issue #195 --- Plugins/ScriptPlugins/VPNDetection.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugins/ScriptPlugins/VPNDetection.js b/Plugins/ScriptPlugins/VPNDetection.js index 3a5f9e98..600d7cd0 100644 --- a/Plugins/ScriptPlugins/VPNDetection.js +++ b/Plugins/ScriptPlugins/VPNDetection.js @@ -26,19 +26,26 @@ var plugin = { try { var cl = new System.Net.Http.HttpClient(); var re = cl.GetAsync('https://api.xdefcon.com/proxy/check/?ip=' + origin.IPAddressString).Result; + var userAgent = 'IW4MAdmin-' + this.manager.GetApplicationSettings().Configuration().Id; + cl.DefaultRequestHeaders.Add('User-Agent', userAgent); var co = re.Content; var parsedJSON = JSON.parse(co.ReadAsStringAsync().Result); co.Dispose(); re.Dispose(); cl.Dispose(); - usingVPN = parsedJSON.success && parsedJSON.proxy; + usingVPN = true;//parsedJSON.success && parsedJSON.proxy; } catch (e) { this.logger.WriteWarning('There was a problem checking client IP for VPN ' + e.message); } if (usingVPN) { this.logger.WriteInfo(origin + ' is using a VPN (' + origin.IPAddressString + ')'); - origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], _IW4MAdminClient); + 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); } },