thorn.validators

Recipient Validators.

thorn.validators.ensure_protocol(*allowed)[source]

Only allow recipient URLs using specific protocols.

Example

>>> ensure_protocol('https', 'http://')
thorn.validators.ensure_port(*allowed)[source]

Validator that ensures port is member of set allowed.

thorn.validators.block_internal_ips()[source]

Block recipient URLs that have an internal IP address.

Warning

This does not check for private networks, it will only make sure the IP address is not in a reserved private block (e.g. 192.168.0.1/24).

thorn.validators.block_cidr_network(*blocked_networks)[source]

Block recipient URLs from a list of CIDR networks.

Example

>>> block_cidr_network('192.168.0.0/24', '132.34.23.0/24')