Skip to content

Commit

Permalink
Merge pull request #2003 from mickvandijke/1999-node-should-panic-on-…
Browse files Browse the repository at this point in the history
…upnp-failure

chore(node): [#1999] panic on upnp event `GatewayNotFound`
  • Loading branch information
mickvandijke authored Aug 5, 2024
2 parents 898446f + 816ef88 commit 5e61746
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions sn_networking/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub enum NetworkEvent {
#[derive(Debug, Clone)]
pub enum TerminateNodeReason {
HardDiskWriteError,
UpnpGatewayNotFound,
}

// Manually implement Debug as `#[debug(with = "unverified_record_fmt")]` not working as expected.
Expand Down
7 changes: 7 additions & 0 deletions sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use crate::event::TerminateNodeReason;
use crate::{
cmd::LocalSwarmCmd,
event::NodeEvent,
Expand Down Expand Up @@ -80,6 +81,12 @@ impl SwarmDriver {
}
event_string = "upnp_event";
info!(?upnp_event, "UPnP event");
if let libp2p::upnp::Event::GatewayNotFound = upnp_event {
warn!("UPnP is not enabled/supported on the gateway. Please rerun without the `--upnp` flag");
self.send_event(NetworkEvent::TerminateNode {
reason: TerminateNodeReason::UpnpGatewayNotFound,
});
}
}

SwarmEvent::Behaviour(NodeEvent::RelayServer(event)) => {
Expand Down

0 comments on commit 5e61746

Please sign in to comment.