Commit 192a4cc4 authored by Éloïs's avatar Éloïs

[ref] #82 ws2p : migrate from crate "websocket" to crate "ws"

parent 8233cb9d
Pipeline #2311 passed with stages
in 17 minutes and 52 seconds
This diff is collapsed.
......@@ -7,16 +7,16 @@ license = "AGPL-3.0"
[dependencies]
duniter-core = { path = "./core" }
duniter-tui = { path = "./tui" }
duniter-ws2p = { path = "./ws2p", optional = true }
duniter-tui = { path = "./tui", optional = true }
duniter-ws2p = { path = "./ws2p" }
[features]
default = ["ws2p"]
ws2p = ["duniter-ws2p"]
default = ["tui","ssl"]
ssl = ["duniter-ws2p/ssl"]
tui = ["duniter-tui"]
# Treat warnings as a build error.
strict = []
[workspace]
members = [
"blockchain",
......
......@@ -23,13 +23,13 @@
)]
extern crate duniter_core;
#[cfg(feature = "tui")]
extern crate duniter_tui;
#[cfg(feature = "ws2p")]
extern crate duniter_ws2p;
pub use duniter_core::DuniterCore;
#[cfg(feature = "tui")]
pub use duniter_tui::TuiModule;
#[cfg(feature = "ws2p")]
pub use duniter_ws2p::WS2PModule;
/// Main function
......@@ -45,16 +45,16 @@ fn main() {
//duniter_core.plug::<GvaModule>();
//duniter_core.plug::<PoolModule>();
//duniter_core.plug::<PowModule>();
duniter_core.plug::<TuiModule>();
plug_ws2p_module(&mut duniter_core);
plug_tui_module(&mut duniter_core);
duniter_core.plug::<WS2PModule>();
duniter_core.start_blockchain();
};
}
/// Plug WS2P Module
#[cfg(feature = "ws2p")]
fn plug_ws2p_module(duniter_core: &mut DuniterCore) {
duniter_core.plug::<WS2PModule>();
/// Plug TUI Module
#[cfg(feature = "tui")]
fn plug_tui_module(duniter_core: &mut DuniterCore) {
duniter_core.plug::<TuiModule>();
}
#[cfg(not(feature = "ws2p"))]
fn plug_ws2p_module(_duniter_core: &mut DuniterCore) {}
#[cfg(not(feature = "tui"))]
fn plug_tui_module(_duniter_core: &mut DuniterCore) {}
......@@ -26,8 +26,9 @@ sqlite = "0.23.9"
serde = "1.0.24"
serde_derive = "1.0.24"
serde_json = "1.0.9"
websocket = "0.20.2"
ws = "0.7.6"
[features]
ssl = ["ws/ssl"]
# Treat warnings as a build error.
strict = []
\ No newline at end of file
......@@ -13,9 +13,9 @@ pub static WS2P_OUTCOMING_INTERVAL: &'static u64 = &300;
pub static WS2P_DEFAULT_OUTCOMING_QUOTA: &'static usize = &10;
pub static WS2P_NEGOTIATION_TIMEOUT: &'static u64 = &15;
//pub static WS2P_REQUEST_TIMEOUT : &'static u64 = &30;
pub static WS2P_CONNECTION_TIMEOUT: &'static u64 = &120;
pub static WS2P_EXPIRE_TIMEOUT: &'static u64 = &120;
pub static WS2P_SPAM_INTERVAL_IN_MILLI_SECS: &'static u64 = &80;
pub static WS2P_SPAM_LIMIT: &'static u64 = &6;
pub static WS2P_SPAM_LIMIT: &'static usize = &6;
pub static WS2P_SPAM_SLEEP_TIME_IN_SEC: &'static u64 = &100;
pub static DURATION_BEFORE_RECORDING_ENDPOINT: &'static u64 = &180;
pub static BLOCKS_REQUEST_INTERVAL: &'static u64 = &60;
......
This diff is collapsed.
// Copyright (C) 2018 The Duniter Project Developers.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use duniter_documents::Blockstamp;
use duniter_network::network_head::*;
use *;
pub fn generate_my_head(
network_keypair: &KeyPairEnum,
conf: &WS2PConf,
soft_name: &str,
soft_version: &str,
my_current_blockstamp: &Blockstamp,
my_uid: Option<String>,
) -> NetworkHead {
let message = NetworkHeadMessage::V2(NetworkHeadMessageV2 {
api: String::from("WS2POCA"),
version: 1,
pubkey: network_keypair.public_key(),
blockstamp: *my_current_blockstamp,
node_uuid: conf.node_id,
software: String::from(soft_name),
soft_version: String::from(soft_version),
prefix: 1,
free_member_room: None,
free_mirror_room: None,
});
let message_v2 = NetworkHeadMessage::V2(NetworkHeadMessageV2 {
api: String::from("WS2POCA"),
version: 2,
pubkey: network_keypair.public_key(),
blockstamp: *my_current_blockstamp,
node_uuid: conf.node_id,
software: String::from(soft_name),
soft_version: String::from(soft_version),
prefix: 1,
free_member_room: Some(0),
free_mirror_room: Some(0),
});
NetworkHead::V2(Box::new(NetworkHeadV2 {
message: message.clone(),
sig: network_keypair
.private_key()
.sign(message.to_string().as_bytes()),
message_v2: message_v2.clone(),
sig_v2: network_keypair
.private_key()
.sign(message_v2.to_string().as_bytes()),
step: 0,
uid: my_uid,
}))
}
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,6 @@ extern crate duniter_module;
extern crate duniter_network;
extern crate serde_json;
extern crate sqlite;
extern crate websocket;
use duniter_crypto::keys::*;
use duniter_network::network_endpoint::{NetworkEndpoint, NetworkEndpointApi};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment