mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightningd: escape our own alias when we print it in logs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -390,7 +390,8 @@ int main(int argc, char *argv[])
|
|||||||
/* Mark ourselves live. */
|
/* Mark ourselves live. */
|
||||||
log_info(ld->log, "Server started with public key %s, alias %s (color #%s) and lightningd %s",
|
log_info(ld->log, "Server started with public key %s, alias %s (color #%s) and lightningd %s",
|
||||||
type_to_string(tmpctx, struct pubkey, &ld->id),
|
type_to_string(tmpctx, struct pubkey, &ld->id),
|
||||||
ld->alias, tal_hex(tmpctx, ld->rgb), version());
|
json_escape(tmpctx, (const char *)ld->alias)->s,
|
||||||
|
tal_hex(tmpctx, ld->rgb), version());
|
||||||
|
|
||||||
/* Start the peers. */
|
/* Start the peers. */
|
||||||
activate_peers(ld);
|
activate_peers(ld);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <ccan/container_of/container_of.h>
|
#include <ccan/container_of/container_of.h>
|
||||||
#include <ccan/time/time.h>
|
#include <ccan/time/time.h>
|
||||||
#include <ccan/timer/timer.h>
|
#include <ccan/timer/timer.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wallet/txfilter.h>
|
#include <wallet/txfilter.h>
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ size_t hash_htlc_key(const struct htlc_key *htlc_key UNNEEDED)
|
|||||||
/* Generated stub for hsm_init */
|
/* Generated stub for hsm_init */
|
||||||
void hsm_init(struct lightningd *ld UNNEEDED, bool newdir UNNEEDED)
|
void hsm_init(struct lightningd *ld UNNEEDED, bool newdir UNNEEDED)
|
||||||
{ fprintf(stderr, "hsm_init called!\n"); abort(); }
|
{ fprintf(stderr, "hsm_init called!\n"); abort(); }
|
||||||
|
/* Generated stub for json_escape */
|
||||||
|
struct json_escaped *json_escape(const tal_t *ctx UNNEEDED, const char *str TAKES UNNEEDED)
|
||||||
|
{ fprintf(stderr, "json_escape called!\n"); abort(); }
|
||||||
/* Generated stub for log_ */
|
/* Generated stub for log_ */
|
||||||
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, const char *fmt UNNEEDED, ...)
|
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, const char *fmt UNNEEDED, ...)
|
||||||
|
|
||||||
|
|||||||
@@ -2108,8 +2108,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
.format(weird_name)])
|
.format(weird_name)])
|
||||||
weird_name_json = json.encoder.JSONEncoder().encode(weird_name)[1:-1].replace('\\', '\\\\')
|
weird_name_json = json.encoder.JSONEncoder().encode(weird_name)[1:-1].replace('\\', '\\\\')
|
||||||
aliasline = l1.daemon.is_in_log('Server started with public key .* alias')
|
aliasline = l1.daemon.is_in_log('Server started with public key .* alias')
|
||||||
# FIXME: alias needs json escaping.
|
assert weird_name_json in str(aliasline)
|
||||||
assert weird_name_json not in str(aliasline)
|
|
||||||
normal_name = 'Normal name'
|
normal_name = 'Normal name'
|
||||||
l2 = self.node_factory.get_node(options=['--alias={}'
|
l2 = self.node_factory.get_node(options=['--alias={}'
|
||||||
.format(normal_name)])
|
.format(normal_name)])
|
||||||
|
|||||||
Reference in New Issue
Block a user