void conf_print( void ) { char hex[HEX_LEN]; hex_hash_encode( hex, _main->conf->node_id ); info( NULL, "Node ID: %s", hex ); hostname_print(); if( _main->conf->bool_realm == 1 ) { info( NULL, "Realm: %s (-r)", _main->conf->realm ); } else { info( NULL, "Realm: None (-r)" ); } #ifdef POLARSSL if( _main->conf->bool_encryption == 1 ) { info( NULL, "Encryption key: %s (-k)", _main->conf->key ); } else { info( NULL, "Encryption key: None (-k)" ); } #endif info( NULL, "P2P daemon is listening to UDP/%i (-p)", _main->conf->p2p_port ); info( NULL, "DNS daemon is listening to UDP/%i (-P)", _main->conf->dns_port ); info( NULL, "Bootstrap node: %s (-x/-l)", _main->conf->bootstrap_node ); info( NULL, "Bootstrap port: UDP/%i (-y)", _main->conf->bootstrap_port ); info( NULL, "Announced port: %i (-y)", _main->conf->announce_port ); if( _main->conf->mode == CONF_CONSOLE ) { info( NULL, "Mode: Console (-d)" ); } else { info( NULL, "Mode: Daemon (-d)" ); } if( _main->conf->verbosity == CONF_BEQUIET ) { info( NULL, "Verbosity: Quiet (-q)" ); } else { info( NULL, "Verbosity: Verbose (-q)" ); } info( NULL, "Cores: %i", _main->conf->cores ); }
void p2p_get_peers_get_values(BEN * values, UCHAR * node_id, ITEM * ti, BEN * token, IP * from) { UCHAR nodes_compact_list[IP_SIZE_META_PAIR8]; UCHAR *p = nodes_compact_list; LOOKUP *l = tdb_ldb(ti); int nodes_compact_size = 0; BEN *val = NULL; ITEM *item = NULL; long int j = 0; char hex[HEX_LEN]; if (l == NULL) { return; } ldb_update(l, node_id, token, from); /* Extract values and create a nodes_compact_list */ item = list_start(values->v.l); while (item != NULL && j < 8) { val = list_value(item); if (!ben_is_str(val) || ben_str_i(val) != IP_SIZE_META_PAIR) { info(_log, from, "Values list broken from "); return; } memcpy(p, ben_str_s(val), ben_str_i(val)); nodes_compact_size += IP_SIZE_META_PAIR; p += IP_SIZE_META_PAIR; item = list_next(item); j++; } if (nodes_compact_size <= 0) { return; } hex_hash_encode(hex, l->target); info(_log, from, "Found %s at", hex); /* * Random lookups are not initiated by a client. * Periodic announces are not initiated by a client either. * And I do not want to cache random lookups. */ if (!l->send_response_to_initiator) { return; } /* Merge responses to the cache */ cache_put(l->target, nodes_compact_list, nodes_compact_size); /* Do not send more than one DNS response to a client. * The client is happy after getting the first response anyway. */ if (ldb_number_of_dns_responses(l) >= 1) { return; } /* Get the merged compact list from the cache. */ nodes_compact_size = cache_compact_list(nodes_compact_list, l->target); if (nodes_compact_size <= 0) { return; } /* Send the result back via DNS */ r_success(&l->c_addr, &l->msg, nodes_compact_list, nodes_compact_size); }