nodeinfo

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 5 Imported by: 1

README

nodeinfo-go

golang lib to query federation node information.

Based on Well-known URI for nodeinfo and matrix discovery it obtains node information about it's service and user stats.

This repo also contains a small CLI tool to use this lib.

CLI Tool

how to build:

  1. have go compiler installed
  2. clone this repo
  3. cd into cli folder
  4. go build .

exec: ./nodeinfo <node domain>

Documentation

Index

Constants

View Source
const (
	ProtocolMatrix = "matrix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Software          Software               `json:"software"`
	Version           string                 `json:"version"`
	OpenRegistrations bool                   `json:"openRegistrations"`
	Protocols         []string               `json:"protocols"`
	Services          Services               `json:"services"`
	Usage             Usage                  `json:"usage"`
	Metadata          map[string]interface{} `json:"metadata"`
}

Node metadata about a server running in the federation

func QueryNode

func QueryNode(domain string, opts ...QueryNodeOption) (*Node, error)

QueryNode fetch node info based on domain

type QueryNodeOption

type QueryNodeOption func(f *fetcher) error

QueryNodeOption are functions to be used as options for QueryNode

func QueryOptionClient

func QueryOptionClient(c *http.Client) QueryNodeOption

QueryOptionClient return an option for QueryNode that can set an specific http client

type Services

type Services struct {
	Inbound  []string `json:"inbound"`
	Outbound []string `json:"outbound"`
}

Services tell about third party sites the node can connect to or interact with

type Software

type Software struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	Repository string `json:"repository"`
	Homepage   string `json:"homepage"`
}

Software is about node software

type Usage

type Usage struct {
	Users         UsersUsage `json:"users"`
	LocalPosts    int        `json:"localPosts,omitempty"`
	LocalComments int        `json:"localComments,omitempty"`
}

Usage are usage statistics for the node

type UsersUsage

type UsersUsage struct {
	Total          int `json:"total,omitempty"`
	ActiveHalfyear int `json:"activeHalfyear,omitempty"`
	ActiveMonth    int `json:"activeMonth,omitempty"`
}

UsersUsage are statistics about the users of the node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL