def join_host_strings(user, host, port=None):
    """
    Turns user/host/port strings into ``user@host:port`` combined string.

    This function is not responsible for handling missing user/port strings;
    for that, see the ``normalize`` function.

    If ``host`` looks like IPv6 address, it will be enclosed in square brackets

    If ``port`` is omitted, the returned string will be of the form
    ``user@host``.
    """
    if port:
        template = '%s@[%s]:%s' if host.count(':') > 1 else '%s@%s:%s'
        return template % (user, host, port)
    else:
        return '%s@%s' % (user, host)
