Factor out common funtions from dnshook