nodeinfo
: Give up on following the spec and implement things loosely
This commit is contained in:
parent
61d8bbea95
commit
5ecb0bb615
4 changed files with 74 additions and 6 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "acrate-nodeinfo/nodeinfo"]
|
||||
path = acrate-nodeinfo/src/spec
|
||||
url = https://github.com/jhass/nodeinfo.git
|
|
@ -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"] }
|
||||
|
|
|
@ -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<NodeInfo2Instance>,
|
||||
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<String>,
|
||||
pub homepage: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NodeInfo1Protocols {
|
||||
pub inbound: Vec<String>,
|
||||
pub outbound: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NodeInfo1Services {
|
||||
pub inbound: Vec<String>,
|
||||
pub outbound: Vec<String>,
|
||||
}
|
||||
|
||||
#[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,
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 1ad645d23cce892dbb6fbaf349760dfb0f1aeaa1
|
Loading…
Reference in a new issue