Generate correct isInNetEx calls. See #67.

This commit is contained in:
FelisCatus 2016-10-24 22:36:34 -04:00
parent 8dcad1697e
commit d489e2eeaf
2 changed files with 7 additions and 5 deletions

View File

@ -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.

View File

@ -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"