mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 04:37:57 +00:00
Remove dialing without a PeerId
This commit is contained in:
committed by
Bastian Köcher
parent
90cd8a8479
commit
ead437d0f4
@@ -22,14 +22,13 @@ use crate::custom_proto::{CustomMessage, RegisteredProtocol, RegisteredProtocols
|
||||
use crate::{NetworkConfiguration, NodeIndex, ProtocolId, parse_str_addr};
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{prelude::*, Stream};
|
||||
use libp2p::{multiaddr::Protocol, Multiaddr, PeerId, build_multiaddr};
|
||||
use libp2p::{multiaddr::Protocol, Multiaddr, PeerId};
|
||||
use libp2p::core::{Swarm, nodes::Substream, transport::boxed::Boxed, muxing::StreamMuxerBox};
|
||||
use libp2p::core::nodes::ConnectedPoint;
|
||||
use log::{debug, error, info, warn};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fs;
|
||||
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
||||
use std::net::SocketAddr;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -81,27 +80,8 @@ where TProtos: IntoIterator<Item = RegisteredProtocol<TMessage>>,
|
||||
// Connect to the bootnodes.
|
||||
for bootnode in config.boot_nodes.iter() {
|
||||
match parse_str_addr(bootnode) {
|
||||
Ok((peer_id, _)) => {
|
||||
Swarm::dial(&mut swarm, peer_id);
|
||||
},
|
||||
Err(_) => {
|
||||
// If the format of the bootstrap node is not a multiaddr, try to parse it as
|
||||
// a `SocketAddr`. This corresponds to the format `IP:PORT`.
|
||||
let addr = match bootnode.parse::<SocketAddr>() {
|
||||
Ok(SocketAddr::V4(socket)) => build_multiaddr![Ip4(*socket.ip()), Tcp(socket.port())],
|
||||
Ok(SocketAddr::V6(socket)) => build_multiaddr![Ip6(*socket.ip()), Tcp(socket.port())],
|
||||
_ => {
|
||||
warn!(target: "sub-libp2p", "Not a valid bootnode address: {}", bootnode);
|
||||
continue
|
||||
}
|
||||
};
|
||||
|
||||
info!(target: "sub-libp2p", "Dialing {} with no peer id. Keep in mind that doing \
|
||||
so is vulnerable to man-in-the-middle attacks.", addr);
|
||||
if let Err(addr) = Swarm::dial_addr(&mut swarm, addr) {
|
||||
warn!(target: "sub-libp2p", "Bootstrap address not supported: {}", addr)
|
||||
}
|
||||
},
|
||||
Ok((peer_id, _)) => Swarm::dial(&mut swarm, peer_id),
|
||||
Err(_) => warn!(target: "sub-libp2p", "Not a valid bootnode address: {}", bootnode),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user