Write correct 'mon_host' with IPv6 addresses

When the IP-address from a monitor is a IPv6 address, encapsulate
it with [ and ]

Fixes: #8309
Merge pull request #186 from wido/ipv6

Two IPv6 related fixes