feat: websockets support (#63)
This commit is contained in:
parent
263c6ef005
commit
a487f79179
|
@ -1674,7 +1674,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|||
|
||||
[[package]]
|
||||
name = "waku-bindings"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"base64 0.21.0",
|
||||
|
@ -1697,7 +1697,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "waku-sys"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "waku-bindings"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
authors = [
|
||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||
|
@ -26,7 +26,7 @@ serde_json = "1.0"
|
|||
sscanf = "0.4"
|
||||
smart-default = "0.6"
|
||||
url = "2.3"
|
||||
waku-sys = { version = "0.1.0", path = "../waku-sys" }
|
||||
waku-sys = { version = "0.2.0", path = "../waku-sys" }
|
||||
|
||||
[dev-dependencies]
|
||||
futures = "0.3.25"
|
||||
|
|
|
@ -9,9 +9,9 @@ mod utils;
|
|||
|
||||
pub use node::{
|
||||
waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic,
|
||||
waku_dns_discovery, waku_discv5_update_bootnodes, waku_new, Aes256Gcm, DnsInfo, GossipSubParams, Initialized, Key, Multiaddr,
|
||||
Protocol, PublicKey, Running, SecretKey, WakuLogLevel, WakuNodeConfig, WakuNodeHandle,
|
||||
WakuPeerData, WakuPeers,
|
||||
waku_discv5_update_bootnodes, waku_dns_discovery, waku_new, Aes256Gcm, DnsInfo,
|
||||
GossipSubParams, Initialized, Key, Multiaddr, Protocol, PublicKey, Running, SecretKey,
|
||||
WakuLogLevel, WakuNodeConfig, WakuNodeHandle, WakuPeerData, WakuPeers, WebsocketParams,
|
||||
};
|
||||
|
||||
pub use general::{
|
||||
|
|
|
@ -69,6 +69,12 @@ pub struct WakuNodeConfig {
|
|||
pub discv5_udp_port: Option<u16>,
|
||||
/// Gossipsub custom configuration.
|
||||
pub gossipsub_params: Option<GossipSubParams>,
|
||||
/// The domain name resolving to the node's public IPv4 address.
|
||||
#[serde(rename = "dns4DomainName")]
|
||||
pub dns4_domain_name: Option<String>,
|
||||
/// Custom websocket support parameters
|
||||
#[serde(rename = "websockets")]
|
||||
pub websocket_params: Option<WebsocketParams>,
|
||||
}
|
||||
|
||||
#[derive(Clone, SmartDefault, Serialize, Deserialize, Debug)]
|
||||
|
@ -195,6 +201,26 @@ pub struct GossipSubParams {
|
|||
pub seen_messages_ttl_seconds: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, SmartDefault, Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WebsocketParams {
|
||||
/// Indicates if websockets support will be enabled
|
||||
#[default(Some(false))]
|
||||
pub enabled: Option<bool>,
|
||||
/// Listening address for websocket connections. Default `0.0.0.0`
|
||||
#[default(Some(std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0))))]
|
||||
pub host: Option<std::net::IpAddr>,
|
||||
/// TCP listening port for websocket connection. Use `0` for **random**. Default `60001`, if secure websockets support is enabled, the default is `6443“`
|
||||
pub port: Option<usize>,
|
||||
/// Enable secure websockets support
|
||||
#[default(Some(false))]
|
||||
pub secure: Option<bool>,
|
||||
/// Secure websocket certificate path. Mandatory if secure websockets support is enabled.
|
||||
pub cert_path: Option<String>,
|
||||
/// Secure websocket key path. Mandatory if secure websockets support is enabled.
|
||||
pub key_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, Debug)]
|
||||
pub enum WakuLogLevel {
|
||||
#[default]
|
||||
|
|
|
@ -60,9 +60,7 @@ pub fn waku_dns_discovery(
|
|||
}
|
||||
|
||||
/// Update the bootnodes used by DiscoveryV5 by passing a list of ENRs
|
||||
pub fn waku_discv5_update_bootnodes(
|
||||
bootnodes: Vec<String>
|
||||
) -> Result<()> {
|
||||
pub fn waku_discv5_update_bootnodes(bootnodes: Vec<String>) -> Result<()> {
|
||||
let bootnodes_ptr = CString::new(
|
||||
serde_json::to_string(&bootnodes)
|
||||
.expect("Serialization from properly built bootnode array should never fail"),
|
||||
|
|
|
@ -28,7 +28,7 @@ pub fn waku_filter_subscribe(
|
|||
.into_raw();
|
||||
|
||||
let result_ptr = unsafe {
|
||||
let result_ptr = waku_sys::waku_filter_subscribe(
|
||||
let result_ptr = waku_sys::waku_legacy_filter_subscribe(
|
||||
filter_subscription_ptr,
|
||||
peer_id_ptr,
|
||||
timeout
|
||||
|
@ -56,7 +56,7 @@ pub fn waku_filter_unsubscribe(
|
|||
.expect("CString should build properly from the serialized filter subscription")
|
||||
.into_raw();
|
||||
let result_ptr = unsafe {
|
||||
let res = waku_sys::waku_filter_unsubscribe(
|
||||
let res = waku_sys::waku_legacy_filter_unsubscribe(
|
||||
filter_subscription_ptr,
|
||||
timeout
|
||||
.as_millis()
|
||||
|
|
|
@ -24,8 +24,8 @@ use crate::general::{
|
|||
WakuMessage, WakuPubSubTopic,
|
||||
};
|
||||
|
||||
pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig};
|
||||
pub use discovery::{waku_dns_discovery, waku_discv5_update_bootnodes, DnsInfo};
|
||||
pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig, WebsocketParams};
|
||||
pub use discovery::{waku_discv5_update_bootnodes, waku_dns_discovery, DnsInfo};
|
||||
pub use peers::{Protocol, WakuPeerData, WakuPeers};
|
||||
pub use relay::{waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic};
|
||||
pub use store::{waku_local_store_query, waku_store_query};
|
||||
|
@ -313,14 +313,10 @@ impl WakuNodeHandle<Running> {
|
|||
filter::waku_filter_unsubscribe(filter_subscription, timeout)
|
||||
}
|
||||
|
||||
|
||||
/// Update the bootnodes used by DiscoveryV5 by passing a list of ENRs
|
||||
pub fn discv5_update_bootnodes(
|
||||
bootnodes: Vec<String>
|
||||
) -> Result<()> {
|
||||
pub fn discv5_update_bootnodes(bootnodes: Vec<String>) -> Result<()> {
|
||||
discovery::waku_discv5_update_bootnodes(bootnodes)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Spawn a new Waku node with the given configuration (default configuration if `None` provided)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "waku-sys"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
authors = [
|
||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f6fe353e2ee31bd5514811327cb1ca2478e2e4a9
|
||||
Subproject commit bc6a305759f2f09ffd1426697730562ffdd4a3dd
|
Loading…
Reference in New Issue