Hostname syntax is validated before resolving it

Fix for issue #120

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>