Also fixing id_matches_direction() function to check both connection endpoints when determining direction respectful of local network.