diff --git a/tools/shuttle/src/identity.rs b/tools/shuttle/src/identity.rs index ecc9b64f5..93b38f291 100644 --- a/tools/shuttle/src/identity.rs +++ b/tools/shuttle/src/identity.rs @@ -15,8 +15,8 @@ use rust_ipfs::{ core::Endpoint, request_response::{RequestId, ResponseChannel}, swarm::{ - ConnectionDenied, ConnectionId, FromSwarm, PollParameters, THandler, THandlerInEvent, - THandlerOutEvent, ToSwarm, + ConnectionDenied, ConnectionId, ExternalAddresses, FromSwarm, PollParameters, THandler, + THandlerInEvent, THandlerOutEvent, ToSwarm, }, }, Keypair, Multiaddr, NetworkBehaviour, PeerId, @@ -58,6 +58,8 @@ pub struct Behaviour { process_command: Option>, queue_event: HashMap>, Either)>, + + external_addresses: ExternalAddresses, } #[derive(Debug)] @@ -129,6 +131,7 @@ impl Behaviour { waiting_on_request: Default::default(), waiting_on_response: Default::default(), queue_event: Default::default(), + external_addresses: ExternalAddresses::default(), } } @@ -426,6 +429,7 @@ impl NetworkBehaviour for Behaviour { } fn on_swarm_event(&mut self, event: FromSwarm) { + self.external_addresses.on_swarm_event(&event); self.inner.on_swarm_event(event) } diff --git a/tools/shuttle/src/identity/protocol.rs b/tools/shuttle/src/identity/protocol.rs index a05913454..de86b5b0f 100644 --- a/tools/shuttle/src/identity/protocol.rs +++ b/tools/shuttle/src/identity/protocol.rs @@ -6,6 +6,13 @@ use super::document::IdentityDocument; pub const PROTOCOL: StreamProtocol = StreamProtocol::new("/shuttle/identity/0.0.1"); +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum Message { + Request(Request), + Response(Response), +} + #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum Request { diff --git a/tools/shuttle/src/lib.rs b/tools/shuttle/src/lib.rs index 823f05e2e..bf61bc05d 100644 --- a/tools/shuttle/src/lib.rs +++ b/tools/shuttle/src/lib.rs @@ -19,3 +19,11 @@ impl PeerIdExt for PeerId { Ok(public_key) } } + +pub enum ShuttleNodeQuorum { + Primary, + Seconary, + Select(PeerId), + All, +} + diff --git a/tools/shuttle/src/main.rs b/tools/shuttle/src/main.rs index 47b1e1e85..2e97cf50b 100644 --- a/tools/shuttle/src/main.rs +++ b/tools/shuttle/src/main.rs @@ -137,18 +137,20 @@ async fn main() -> Result<(), Box> { let (id_event_tx, mut id_event_rx) = futures::channel::mpsc::channel(1); let mut uninitialized = UninitializedIpfs::empty() - .set_custom_behaviour(Behaviour { - identity: identity::Behaviour::new(&keypair, id_event_tx, None), - dummy: ext_behaviour::Behaviour, - }) - .disable_kad() - .disable_delay() - .set_identify_configuration(IdentifyConfiguration { + .with_identify(Some(IdentifyConfiguration { agent_version: format!("shuttle/{}", env!("CARGO_PKG_VERSION")), ..Default::default() + })) + .with_autonat() + .with_bitswap(None) + .with_ping(None) + .with_pubsub(None) + .with_custom_behaviour(Behaviour { + identity: identity::Behaviour::new(&keypair, id_event_tx, None), + dummy: ext_behaviour::Behaviour, }) - .enable_relay(true) - .enable_relay_server(Some(RelayConfig { + .with_relay(true) + .with_relay_server(Some(RelayConfig { max_circuits: 512, max_circuits_per_peer: 8, max_circuit_duration: Duration::from_secs(2 * 60), @@ -179,7 +181,7 @@ async fn main() -> Result<(), Box> { }, ], })) - .enable_rendezvous_server() + .with_rendezvous_server() .fd_limit(FDLimit::Max) .set_keypair(keypair) .set_idle_connection_timeout(120)