mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
irc: Added alias handling for node announcements
Aliases seem to be popular among users wanting to show off their node, so let's add them :-)
This commit is contained in:
parent
94fd82dc81
commit
f9a4af62e3
3 changed files with 13 additions and 3 deletions
|
@ -177,7 +177,6 @@ static void handle_node_announcement(
|
||||||
struct pubkey *pk = talz(msg, struct pubkey);
|
struct pubkey *pk = talz(msg, struct pubkey);
|
||||||
char *hostname = tal_strdup(msg, splits[2]);
|
char *hostname = tal_strdup(msg, splits[2]);
|
||||||
int port = atoi(splits[3]);
|
int port = atoi(splits[3]);
|
||||||
|
|
||||||
if (!pubkey_from_hexstr(istate->dstate->secpctx, splits[1], strlen(splits[1]), pk) || port < 1)
|
if (!pubkey_from_hexstr(istate->dstate->secpctx, splits[1], strlen(splits[1]), pk) || port < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -185,9 +184,16 @@ static void handle_node_announcement(
|
||||||
log_debug(istate->log, "Ignoring node announcement from %s, signature check failed.",
|
log_debug(istate->log, "Ignoring node announcement from %s, signature check failed.",
|
||||||
splits[1]);
|
splits[1]);
|
||||||
return;
|
return;
|
||||||
|
} else if(splits[4] != NULL && strlen(splits[4]) > 64) {
|
||||||
|
log_debug(istate->log, "Ignoring node announcement from %s, alias too long",
|
||||||
|
splits[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_node(istate->dstate, pk, hostname, port);
|
struct node *node = add_node(istate->dstate, pk, hostname, port);
|
||||||
|
if (splits[4] != NULL){
|
||||||
|
tal_free(node->alias);
|
||||||
|
node->alias = tal_hexdata(node, splits[5], strlen(splits[4]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -210,7 +216,7 @@ static void handle_irc_privmsg(struct ircstate *istate, const struct privmsg *ms
|
||||||
|
|
||||||
if (splitcount == 10 && streq(type, "CHAN"))
|
if (splitcount == 10 && streq(type, "CHAN"))
|
||||||
handle_channel_announcement(istate, msg, splits + 1);
|
handle_channel_announcement(istate, msg, splits + 1);
|
||||||
else if (splitcount == 5 && streq(type, "NODE"))
|
else if (splitcount >= 5 && streq(type, "NODE"))
|
||||||
handle_node_announcement(istate, msg, splits + 1);
|
handle_node_announcement(istate, msg, splits + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct node *new_node(struct lightningd_state *dstate,
|
||||||
n->in = tal_arr(n, struct node_connection *, 0);
|
n->in = tal_arr(n, struct node_connection *, 0);
|
||||||
n->out = tal_arr(n, struct node_connection *, 0);
|
n->out = tal_arr(n, struct node_connection *, 0);
|
||||||
n->port = 0;
|
n->port = 0;
|
||||||
|
n->alias = NULL;
|
||||||
node_map_add(dstate->nodes, n);
|
node_map_add(dstate->nodes, n);
|
||||||
tal_add_destructor(n, destroy_node);
|
tal_add_destructor(n, destroy_node);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@ struct node {
|
||||||
/* Where that came from. */
|
/* Where that came from. */
|
||||||
struct node_connection *prev;
|
struct node_connection *prev;
|
||||||
} bfg[ROUTING_MAX_HOPS+1];
|
} bfg[ROUTING_MAX_HOPS+1];
|
||||||
|
|
||||||
|
/* UTF-8 encoded alias as tal_arr, not zero terminated */
|
||||||
|
u8 *alias;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lightningd_state;
|
struct lightningd_state;
|
||||||
|
|
Loading…
Add table
Reference in a new issue