more updates for script plugin helper and corresponding VPNDetection update to properly send user gent

This commit is contained in:
RaidMax 2023-04-13 23:36:29 -05:00
parent 520a76a15e
commit c3be7f7de5
2 changed files with 7 additions and 15 deletions

View File

@ -34,11 +34,6 @@ public class ScriptPluginHelper
RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback); RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback);
} }
public void GetUrl(string url, Dictionary<string, string> headers, Delegate callback)
{
RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback);
}
public void PostUrl(string url, string body, string bearerToken, Delegate callback) public void PostUrl(string url, string body, string bearerToken, Delegate callback)
{ {
var headers = new Dictionary<string, string> { { "Authorization", $"Bearer {bearerToken}" } }; var headers = new Dictionary<string, string> { { "Authorization", $"Bearer {bearerToken}" } };
@ -46,11 +41,6 @@ public class ScriptPluginHelper
new ScriptPluginWebRequest(url, body, "POST", Headers: headers), callback); new ScriptPluginWebRequest(url, body, "POST", Headers: headers), callback);
} }
public void PostUrl(string url, string body, Dictionary<string, string> headers, Delegate callback)
{
RequestUrl(new ScriptPluginWebRequest(url, body, "POST", Headers: headers), callback);
}
public void RequestUrl(ScriptPluginWebRequest request, Delegate callback) public void RequestUrl(ScriptPluginWebRequest request, Delegate callback)
{ {
Task.Run(() => Task.Run(() =>

View File

@ -191,13 +191,15 @@ const plugin = {
} }
const userAgent = `IW4MAdmin-${this.manager.getApplicationSettings().configuration().id}`; const userAgent = `IW4MAdmin-${this.manager.getApplicationSettings().configuration().id}`;
const headers = { const stringDict = System.Collections.Generic.Dictionary(System.String, System.String);
'User-Agent': userAgent const headers = new stringDict();
}; headers.add('User-Agent', userAgent);
const pluginScript = importNamespace('IW4MAdmin.Application.Plugin.Script');
const request = new pluginScript.ScriptPluginWebRequest(`https://api.xdefcon.com/proxy/check/?ip=${origin.IPAddressString}`,
null, 'GET', 'application/json', headers);
try { try {
this.pluginHelper.getUrl(`https://api.xdefcon.com/proxy/check/?ip=${origin.IPAddressString}`, headers, this.pluginHelper.requestUrl(request, (response) => this.onVpnResponse(response, origin));
(response) => this.onVpnResponse(response, origin));
} catch (ex) { } catch (ex) {
this.logger.logWarning('There was a problem checking client IP ({IP}) for VPN - {message}', this.logger.logWarning('There was a problem checking client IP ({IP}) for VPN - {message}',