lib/evaluator: add support for IP Address comparison

This commit is contained in:
Jens Langhammer
2020-07-12 16:36:49 +02:00
parent 0ff4545bab
commit 06f73512df
6 changed files with 21 additions and 4 deletions

View File

@ -53,3 +53,14 @@ Example:
```python
other_user = pb_user_by(username="other_user")
```
## Comparing IP Addresses
To compare IP Addresses or check if an IP Address is within a given subnet, you can use the functions `ip_address('192.0.2.1')` and `ip_network('192.0.2.0/24')`. With these objects you can do [arithmetic operations](https://docs.python.org/3/library/ipaddress.html#operators).
You can also check if an IP Address is within a subnet by writing the following:
```python
ip_address('192.0.2.1') in ip_network('192.0.2.0/24')
# evaluates to True
```