ExitPolicy.can_exit_to() returns incorrect results when address is omitted
Note: this is with Stem version 1.3.0
When using ExitPolicy.can_exit_to(port=443, strict=False), an incorrect result is returned. Ex:
>>> policy = ExitPolicy('reject 1.0.0.0/8:*', 'accept *:*')
>>> policy.can_exit_to(port=443, strict=False)
>>> False
If an address is included, however, the results are as expected:
>>> policy = ExitPolicy('reject 1.0.0.0/8:*', 'accept *:*')
>>> policy.can_exit_to(address='8.8.8.8', port=443, strict=False)
>>> True
According to Stem's documentation for can_exit_to() for the 'strict' parameter:
strict (bool) -- if the address or port is excluded then check if we can exit to all instances of the defined address or port
I interpret this to mean:
If 'strict' is True, then can_exit_to() should return True iff exits to all possible IPs are allowed on the specified port when 'address' is omitted. If 'strict' is False, then can_exit_to() should return True if any exits to the specified port are allowed when 'address' is omitted.
Is this just a misunderstanding of the documentation on my part? Or is this actually a bug?
Attached: a script to reproduce the issue.
Trac:
Username: nskinkel