Commit 8465a34c authored by Éloïs's avatar Éloïs
Browse files

|enh] create endpoint v11 (ws2pv2)

parent 2d56ee1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -319,6 +319,7 @@ dependencies = [
name = "duniter-network"
version = "0.1.0-a0.1"
dependencies = [
 "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 "duniter-crypto 0.2.0-a0.1",
 "duniter-documents 0.8.0-a0.1",
 "duniter-module 0.1.0-a0.1",
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ license = "AGPL-3.0"
path = "lib.rs"

[dependencies]
byteorder = "1.2.3"
duniter-crypto = { path = "../crypto" }
duniter-documents = { path = "../documents" }
duniter-module = { path = "../module" }
+5 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ extern crate lazy_static;
#[macro_use]
extern crate serde_derive;

extern crate byteorder;
extern crate crypto;
extern crate duniter_crypto;
extern crate duniter_documents;
@@ -337,8 +338,8 @@ mod tests {
        let node_id = NodeUUID(u32::from_str_radix("c1c39a0a", 16).unwrap());
        let full_id = NodeFullId(node_id, issuer);
        assert_eq!(
            NetworkEndpoint::parse_from_raw("WS2P c1c39a0a i3.ifee.fr 80 /ws2p", issuer, 0, 0),
            Some(NetworkEndpoint::V1(NetworkEndpointV1 {
            NetworkEndpoint::parse_from_raw("WS2P c1c39a0a i3.ifee.fr 80 /ws2p", issuer, 0, 0, 1),
            Ok(NetworkEndpoint::V10(NetworkEndpointV10 {
                version: 1,
                issuer,
                api: NetworkEndpointApi(String::from("WS2P")),
@@ -363,8 +364,8 @@ mod tests {
        let node_id = NodeUUID(u32::from_str_radix("cb06a19b", 16).unwrap());
        let full_id = NodeFullId(node_id, issuer);
        assert_eq!(
            NetworkEndpoint::parse_from_raw("WS2P cb06a19b g1.imirhil.fr 53012 /", issuer, 0, 0),
            Some(NetworkEndpoint::V1(NetworkEndpointV1 {
            NetworkEndpoint::parse_from_raw("WS2P cb06a19b g1.imirhil.fr 53012 /", issuer, 0, 0, 1),
            Ok(NetworkEndpoint::V10(NetworkEndpointV10 {
                version: 1,
                issuer,
                api: NetworkEndpointApi(String::from("WS2P")),
+866 −49

File changed.

Preview size limit exceeded, changes collapsed.

+21 −5
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ impl Default for WS2PConf {
                    ),
                    0,
                    0,
                    1u16,
                ).unwrap(),
                NetworkEndpoint::parse_from_raw(
                    "WS2P b48824f0 g1.monnaielibreoccitanie.org 443 /ws2p",
@@ -114,6 +115,7 @@ impl Default for WS2PConf {
                    ),
                    0,
                    0,
                    1u16,
                ).unwrap(),
            ],
        }
@@ -536,7 +538,8 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
                                                            *node_full_id,
                                                            *conn_state as u32,
                                                            uid_option.clone(),
                                                            ep.get_url(false),
                                                            ep.get_url(false, false)
                                                                .expect("Endpoint unreachable !"),
                                                        ),
                                                    );
                                                }
@@ -577,7 +580,10 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
                                ws2p_full_id,
                                WS2PConnectionState::Established as u32,
                                ws2p_module.uids_cache.get(&ws2p_full_id.1).cloned(),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id].0.get_url(false),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id]
                                    .0
                                    .get_url(false, false)
                                    .expect("Endpoint unreachable !"),
                            ));
                        }
                        WS2PSignal::WSError(ws2p_full_id) => {
@@ -586,7 +592,10 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
                                ws2p_full_id,
                                WS2PConnectionState::WSError as u32,
                                ws2p_module.uids_cache.get(&ws2p_full_id.1).cloned(),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id].0.get_url(false),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id]
                                    .0
                                    .get_url(false, false)
                                    .expect("Endpoint unreachable !"),
                            ));
                        }
                        WS2PSignal::NegociationTimeout(ws2p_full_id) => {
@@ -595,7 +604,10 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
                                ws2p_full_id,
                                WS2PConnectionState::Denial as u32,
                                ws2p_module.uids_cache.get(&ws2p_full_id.1).cloned(),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id].0.get_url(false),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id]
                                    .0
                                    .get_url(false, false)
                                    .expect("Endpoint unreachable !"),
                            ));
                        }
                        WS2PSignal::Timeout(ws2p_full_id) => {
@@ -604,7 +616,10 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
                                ws2p_full_id,
                                WS2PConnectionState::Close as u32,
                                ws2p_module.uids_cache.get(&ws2p_full_id.1).cloned(),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id].0.get_url(false),
                                ws2p_module.ws2p_endpoints[&ws2p_full_id]
                                    .0
                                    .get_url(false, false)
                                    .expect("Endpoint unreachable !"),
                            ));
                        }
                        WS2PSignal::PeerCard(_ws2p_full_id, _peer_card, ws2p_endpoints) => {
@@ -1062,6 +1077,7 @@ mod tests {
            ),
            1,
            current_time.as_secs(),
            1,
        ).expect("Failt to parse test endpoint !");

        ws2p_db::write_endpoint(&db, &endpoint, 1, current_time.as_secs());
Loading