diff --git a/.gitmodules b/.gitmodules index 9ebfed1..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "acrate-nodeinfo/nodeinfo"] - path = acrate-nodeinfo/src/spec - url = https://github.com/jhass/nodeinfo.git diff --git a/acrate-nodeinfo/Cargo.toml b/acrate-nodeinfo/Cargo.toml index 90f87fd..4345304 100644 --- a/acrate-nodeinfo/Cargo.toml +++ b/acrate-nodeinfo/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] acrate-hostmeta = { version = "0.1.0", path = "../acrate-hostmeta" } -jsonschema = { version = "0.26.1", default-features = false } log = "0.4.22" reqwest = { version = "0.12.9", features = ["json", "stream"] } serde = { version = "1.0.214", features = ["derive"] } diff --git a/acrate-nodeinfo/src/lib.rs b/acrate-nodeinfo/src/lib.rs index 90cfed6..eb34904 100644 --- a/acrate-nodeinfo/src/lib.rs +++ b/acrate-nodeinfo/src/lib.rs @@ -1,3 +1,76 @@ -//! Serde-based [NodeInfo] parser. +//! Serde-based loose [NodeInfo] fetcher and parser. //! //! [NodeInfo]: https://github.com/jhass/nodeinfo/blob/main/PROTOCOL.md + +use serde::Deserialize; + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1 { + pub version: String, + pub software: NodeInfo1Software, + pub protocols: NodeInfo1Protocols, + pub services: NodeInfo1Services, + pub open_registrations: bool, + pub usage: NodeInfo1Usage, + pub metadata: serde_json::Value, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo2 { + pub version: String, + pub instance: Option, + pub software: NodeInfo1Software, + pub protocols: NodeInfo1Protocols, + pub services: NodeInfo1Services, + pub open_registrations: bool, + pub usage: NodeInfo1Usage, + pub metadata: serde_json::Value, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1Software { + pub name: String, + pub version: String, + pub repository: Option, + pub homepage: Option, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1Protocols { + pub inbound: Vec, + pub outbound: Vec, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1Services { + pub inbound: Vec, + pub outbound: Vec, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1Usage { + pub users: NodeInfo1UsageUsers, + pub local_posts: i32, + pub local_comments: i32, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo1UsageUsers { + pub total: i32, + pub active_halfyear: i32, + pub active_month: i32, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NodeInfo2Instance { + pub name: String, + pub description: String, +} diff --git a/acrate-nodeinfo/src/spec b/acrate-nodeinfo/src/spec deleted file mode 160000 index 1ad645d..0000000 --- a/acrate-nodeinfo/src/spec +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1ad645d23cce892dbb6fbaf349760dfb0f1aeaa1