Proxy and Virtual machine filter using 3rd party API in Inno Setup

45 Views Asked by At

I am trying to use a 3rd party API to filter proxy traffic and Virtual machine and different file for each, I have use the following code ( https://pastebin.com/hWZX1Sxq ) JasonParser File (https://pastebin.com/hNspZxVY) but the function does not work also there is no error message while compiling.

function ProxyDetected(ip:string):Boolean;
var
  WinHttpReq: Variant;
  jsonText : String;
  JsonParser: TJsonParser;
  jBool : TJsonWord;
  I:integer;
begin    
    try 
      WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpReq.Open('GET', 'https://api.ipregistry.co/'+ip+'?key=roygrcxz372rjb&fields=security&pretty=true', False);
      WinHttpReq.Send;
      jsonText := Trim(WinHttpReq.ResponseText);
      Log(jsonText);
      ParseJson(JsonParser, jsonText);
      if GetArrayLength(JsonParser.Output.Errors) > 0 then
      begin
        Log('Error parsing JSON');
        for I := 0 to GetArrayLength(JsonParser.Output.Errors) - 1 do
        begin
          Log(JsonParser.Output.Errors[I]);
        end;
      end
      else
      begin
        //if FindJsonWord(JsonParser.Output, GetJsonRoot(JsonParser.Output), 'proxy', jBool) then
        if FindJsonWord(JsonParser.Output, GetJsonRoot(JsonParser.Output), 'is_cloud_provider', jBool) then
        begin
          if jBool = JWTrue then
            //Log('proxy:true')
            Log('is_cloud_provider:true')
          else
            //Log('proxy:false');
            Log('is_cloud_provider:false')
        end;
      end;
 
      ClearJsonParser(JsonParser);
 
 
      Result := (Trim(WinHttpReq.ResponseText) = '1');
    except
      Log(GetExceptionMessage);
      Result := false;
    end;
end;
0

There are 0 best solutions below