anetPeerToString() refactoring and more explicit checks.

Related to PR #2010.