IP restriction doesn't block a domain which resolves restricted IP address.

Lookup the DNS of the hostname before fetching the URL. This ensures correct restricted IP address matching can be done. In addition minor refactoring to make the the code slightly cleaner.