import ipaddress


def ip_port_to_string(record: dict) -> str:
    """
    Generates string from dict containing ip and port as parameters.
    :param record: ip, port record as dict
    :return: given record as string
    """
    if not record['ip']:
        return ''
    
    ip = ipaddress.ip_address(record['ip'])

    if not record['port']:  # address without port
        return record['ip']

    if ip.version == 4:  # ipv4
        return '{ip}:{port}'.format(
                ip = record['ip'],
                port = record['port']
            )
    else:  # ipv6
        return '[{ip}]:{port}'.format(
                ip = record['ip'],
                port = record['port']
            )