mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-05 23:24:21 +01:00
wireaddr: rework port parsing for weird addresses.
We save wireaddr to databases as a string (which is pretty dumb) but it turned out that my local node saved '[::ffff:127.0.0.1]:49150' which our parser can't parse. Thus I've reworked the parser to make fewer assumptions: parse_ip_port() is renamed to separate_address_and_port() and is now far more accepting of different forms, and returns failure only on grossly malformed strings. Otherwise it overwrites its *port arg only if there's a port specified. I also made it static. Then fromwire_wireaddr() hands the resulting address to inet_pton to figure out if it's actually valid. Cc: William Casarin <jb55@jb55.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
cc9ca82821
commit
eb0603bd13
@@ -41,7 +41,6 @@ struct wireaddr {
|
||||
void towire_wireaddr(u8 **pptr, const struct wireaddr *addr);
|
||||
bool fromwire_wireaddr(const u8 **cursor, size_t *max, struct wireaddr *addr);
|
||||
|
||||
bool parse_ip_port(tal_t *ctx, const char *arg, char **ip, u16 *port);
|
||||
bool parse_wireaddr(const char *arg, struct wireaddr *addr, u16 port);
|
||||
|
||||
char *fmt_wireaddr(const tal_t *ctx, const struct wireaddr *a);
|
||||
|
||||
Reference in New Issue
Block a user