/// The peer did something incorrect. Tell them.
SendErrorMessage {
/// The message to send.
- msg: ErrorMessage
+ msg: ErrorMessage,
+ },
+ /// The peer did something incorrect. Tell them without closing any channels.
+ SendWarningMessage {
+ /// The message to send.
+ msg: WarningMessage,
+ /// The peer may have done something harmless that we weren't able to meaningfully process,
+ /// though we should still tell them about it.
+ /// If this event is logged, log it at the given level.
+ log_level: logger::Level,
},
}
self.enqueue_message(peer, &msg);
continue;
},
+ msgs::ErrorAction::SendWarningMessage { msg, log_level } => {
+ log_given_level!(self.logger, log_level, "Error handling message{}; sending warning message with: {}", OptionalFromDebugger(&peer.their_node_id), e.err);
+ self.enqueue_message(peer, &msg);
+ continue;
+ },
}
}
}
return Err(PeerHandleError{ no_connection_possible: true }.into());
}
},
+ wire::Message::Warning(msg) => {
+ let mut data_is_printable = true;
+ for b in msg.data.bytes() {
+ if b < 32 || b > 126 {
+ data_is_printable = false;
+ break;
+ }
+ }
+
+ if data_is_printable {
+ log_debug!(self.logger, "Got warning message from {}: {}", log_pubkey!(peer.their_node_id.unwrap()), msg.data);
+ } else {
+ log_debug!(self.logger, "Got warning message from {} with non-ASCII error message", log_pubkey!(peer.their_node_id.unwrap()));
+ }
+ },
wire::Message::Ping(msg) => {
if msg.ponglen < 65532 {
msg.data);
self.enqueue_message(get_peer_for_forwarding!(node_id), msg);
},
+ msgs::ErrorAction::SendWarningMessage { ref msg, ref log_level } => {
+ log_given_level!(self.logger, *log_level, "Handling SendWarningMessage HandleError event in peer_handler for node {} with message {}",
+ log_pubkey!(node_id),
+ msg.data);
+ self.enqueue_message(get_peer_for_forwarding!(node_id), msg);
+ },
}
},
MessageSendEvent::SendChannelRangeQuery { ref node_id, ref msg } => {
pub(crate) enum Message<T> where T: core::fmt::Debug + Type {
Init(msgs::Init),
Error(msgs::ErrorMessage),
+ Warning(msgs::WarningMessage),
Ping(msgs::Ping),
Pong(msgs::Pong),
OpenChannel(msgs::OpenChannel),
match self {
&Message::Init(ref msg) => msg.type_id(),
&Message::Error(ref msg) => msg.type_id(),
+ &Message::Warning(ref msg) => msg.type_id(),
&Message::Ping(ref msg) => msg.type_id(),
&Message::Pong(ref msg) => msg.type_id(),
&Message::OpenChannel(ref msg) => msg.type_id(),
msgs::ErrorMessage::TYPE => {
Ok(Message::Error(Readable::read(buffer)?))
},
+ msgs::WarningMessage::TYPE => {
+ Ok(Message::Warning(Readable::read(buffer)?))
+ },
msgs::Ping::TYPE => {
Ok(Message::Ping(Readable::read(buffer)?))
},
const TYPE: u16 = 17;
}
+impl Encode for msgs::WarningMessage {
+ const TYPE: u16 = 1;
+}
+
impl Encode for msgs::Ping {
const TYPE: u16 = 18;
}