Пример #1
0
/* Create new friend_connections instance. */
Friend_Connections *new_friend_connections(const Mono_Time *mono_time, Onion_Client *onion_c,
        bool local_discovery_enabled)
{
    if (onion_c == nullptr) {
        return nullptr;
    }

    Friend_Connections *const temp = (Friend_Connections *)calloc(1, sizeof(Friend_Connections));

    if (temp == nullptr) {
        return nullptr;
    }

    temp->mono_time = mono_time;
    temp->dht = onion_get_dht(onion_c);
    temp->net_crypto = onion_get_net_crypto(onion_c);
    temp->onion_c = onion_c;
    temp->local_discovery_enabled = local_discovery_enabled;
    // Don't include default port in port range
    temp->next_lan_port = TOX_PORTRANGE_FROM + 1;

    new_connection_handler(temp->net_crypto, &handle_new_connections, temp);

    if (temp->local_discovery_enabled) {
        lan_discovery_init(temp->dht);
    }

    return temp;
}
Пример #2
0
/* Create new friend_connections instance. */
Friend_Connections *new_friend_connections(Onion_Client *onion_c)
{
    if (!onion_c)
        return NULL;

    Friend_Connections *temp = calloc(1, sizeof(Friend_Connections));

    if (temp == NULL)
        return NULL;

    temp->dht = onion_c->dht;
    temp->net_crypto = onion_c->c;
    temp->onion_c = onion_c;

    new_connection_handler(temp->net_crypto, &handle_new_connections, temp);

    return temp;
}