Move disconnect calculation into disconnect sub
Support the IPv6 connection variable trusted_ip6

This allows logging when the source connection is over IPv6.

Fixes issue #3.