From dedfe2ff0cb6822f71f582ceca0c44b78d810d3d Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Sun, 10 Apr 2022 13:52:00 +0100 Subject: [PATCH] print directory node info --- docs/onion-message-channels.md | 2 +- jmdaemon/jmdaemon/onionmc.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/onion-message-channels.md b/docs/onion-message-channels.md index 6e0c2575b..8e496dc7c 100644 --- a/docs/onion-message-channels.md +++ b/docs/onion-message-channels.md @@ -153,7 +153,7 @@ who would like to help by running a directory node. You can ignore it if that do This requires a long running bot. It should be on a server you can keep running permanently, so perhaps a VPS, but in any case, very high uptime. For reliability it also makes sense to configure to run as a systemd service. -The currently suggested way to run a directory node is to use the script found [here](https://github.com/JoinMarket-Org/custom-scripts/blob/0eda6154265e012b907c43e2ecdacb895aa9e3ab/start-dn.py); you can place it in your `joinmarket-clientserver/scripts` directory and run it *without* arguments, but with one option flag: `--datadir=/your/chosen/datadir` (as you'll see below). +The currently suggested way to run a directory node is to use the script found [here](https://github.com/JoinMarket-Org/custom-scripts/blob/0eda6154265e012b907c43e2ecdacb895aa9e3ab/start-dn.py); you can place it in your `joinmarket-clientserver/scripts` directory and run it with the option flag: `--datadir=/your/chosen/datadir` (as you'll see below). This slightly unobvious approach is based on the following ideas: we run a Joinmarket script, with a Joinmarket python virtualenv, so that we are able to parse messages; this means that the directory node *can* be a bot, e.g. a maker bot, but need not be - and here it is basically a "crippled" maker bot that cannot do anything. This 'crippling' is actually very useful because (a) we use the `no-blockchain` argument (it is forced in-code; you don't need to set it) so we don't need a running Bitcoin node (of whatever flavour), and (b) we don't need a wallet either. diff --git a/jmdaemon/jmdaemon/onionmc.py b/jmdaemon/jmdaemon/onionmc.py index 8e6f63f60..595d4daec 100644 --- a/jmdaemon/jmdaemon/onionmc.py +++ b/jmdaemon/jmdaemon/onionmc.py @@ -1169,11 +1169,13 @@ def process_handshake(self, peerid: str, message: str, accepted = handshake_json["accepted"] nick = handshake_json["nick"] net = handshake_json["network"] + motd = handshake_json["motd"] assert isinstance(proto_max, int) assert isinstance(proto_min, int) assert isinstance(features, dict) assert isinstance(nick, str) assert isinstance(net, str) + assert isinstance(motd, str) except Exception as e: log.warn("Invalid handshake message from: {}," " exception: {}, message: {},ignoring".format( @@ -1200,6 +1202,8 @@ def process_handshake(self, peerid: str, message: str, return # We received a valid, accepting dn-handshake. Update the peer. peer.update_status(PEER_STATUS_HANDSHAKED) + # Show the info for the directory to the user, with emphasis: + self.info_callback("\n\n" + motd + "\n\n") peer.set_nick(nick) else: # it means, we are receiving an initial handshake