diff --git a/omega-pac/src/conditions.coffee b/omega-pac/src/conditions.coffee index 655db40..23df3cb 100644 --- a/omega-pac/src/conditions.coffee +++ b/omega-pac/src/conditions.coffee @@ -520,13 +520,15 @@ module.exports = exports = new U2.AST_String value: cache.mask ] ) - if cache.addr.v6 + if not cache.addr.v4 + # Example: isInNetEx(host,"fefe:13::abc/33") + # For documentation on the isInNetEx function, see: + # https://msdn.microsoft.com/en-us/library/windows/desktop/gg308479(v=vs.85).aspx hostIsInNetEx = new U2.AST_Call( expression: new U2.AST_SymbolRef name: 'isInNetEx' args: [ new U2.AST_SymbolRef name: 'host' - new U2.AST_String value: cache.normalized - new U2.AST_String value: cache.mask + new U2.AST_String value: cache.normalized + cache.addr.subnet ] ) # Use isInNetEx if possible. diff --git a/omega-pac/test/conditions.coffee b/omega-pac/test/conditions.coffee index 4fb91c1..b28682b 100644 --- a/omega-pac/test/conditions.coffee +++ b/omega-pac/test/conditions.coffee @@ -268,8 +268,8 @@ describe 'Conditions', -> Conditions.match(cond, request).should.be.true compiled = Conditions.compile(cond).print_to_string() - compiled_args = compiled.substr(compiled.lastIndexOf('(')) - compiled_args.should.eql('(host,"fefe:13::abc","ffff:ffff:8000::")') + compiled.should.contain('isInNet(host,"fefe:13::abc","ffff:ffff:8000::")') + compiled.should.contain('isInNetEx(host,"fefe:13::abc/33")') it 'should support IPv6 subnet with zero prefixLength', -> cond = conditionType: "IpCondition"