From 950ad3176069a5a94595c7ebf8a1109a6c4e34b2 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 3 Apr 2017 22:02:44 -0500 Subject: [PATCH] For now, puting bogus, non-zero IP address in due to MultiAddress bug. The client pays no attention to the IP address anyway. But the MultiAddress bug needs to be fixed. --- core/daemon.c | 1 + routing/online.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/daemon.c b/core/daemon.c index a68d2f5..fe91fd0 100644 --- a/core/daemon.c +++ b/core/daemon.c @@ -75,5 +75,6 @@ int ipfs_daemon (int argc, char **argv) libp2p_logger_add_class("peerstore"); libp2p_logger_add_class("providerstore"); libp2p_logger_add_class("daemon"); + libp2p_logger_add_class("online"); return ipfs_daemon_start(NULL); } diff --git a/routing/online.c b/routing/online.c index 7ae1282..8477817 100644 --- a/routing/online.c +++ b/routing/online.c @@ -5,6 +5,7 @@ #include "libp2p/net/stream.h" #include "libp2p/conn/session.h" #include "libp2p/routing/dht_protocol.h" +#include "libp2p/utils/logger.h" /** * Implements the routing interface for communicating with network clients @@ -82,9 +83,13 @@ int ipfs_routing_online_provide(struct IpfsRouting* routing, char* key, size_t k local_peer->id = routing->local_node->identity->peer_id; local_peer->connection_type = CONNECTION_TYPE_CONNECTED; local_peer->addr_head = libp2p_utils_linked_list_new(); + struct MultiAddress* temp_ma = multiaddress_new_from_string((char*)routing->local_node->repo->config->addresses->swarm_head->item); + int port = multiaddress_get_ip_port(temp_ma); + multiaddress_free(temp_ma); char str[255]; - sprintf(str, "%s/ipfs/%s", (char*)routing->local_node->repo->config->addresses->swarm_head->item, routing->local_node->repo->config->identity->peer_id); + sprintf(str, "/ip4/127.1.2.3/tcp/%d", port); struct MultiAddress* ma = multiaddress_new_from_string(str); + libp2p_logger_debug("online", "Adding local MultiAddress %s to peer.\n", ma->string); local_peer->addr_head->item = ma; struct Libp2pMessage* msg = libp2p_message_new();