lib

package module
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

README

go-lib

Shared Code for FediTools projects

Go Report Card codecov Crowdin License Release PkgGoDev

Documentation

Index

Constants

View Source
const HostMetaWebFingerTemplateRel = "lrdd"

HostMetaWebFingerTemplateRel matches a webfinger link relationship.

View Source
const NodeInfo20Schema = "http://nodeinfo.diaspora.software/ns/schema/2.0"

NodeInfo20Schema the schema url for nodeinfo 2.0.

Variables

View Source
var (
	// ErrInvalidAccountFormat is returned when a federated account is in an invalid format.
	ErrInvalidAccountFormat = NewError("invalid account format")
	// ErrMissingNodeInfoURI is returned a well known node info document is missing a node info url.
	ErrMissingNodeInfoURI = NewError("missing node info url")
)

Functions

func BytesToInt64

func BytesToInt64(b []byte) int64

func BytesToTime

func BytesToTime(b []byte) time.Time

func ContainsOneOfStrings

func ContainsOneOfStrings(stack []string, needles []string) bool

ContainsOneOfStrings will return true if any of a group of strings is found in a given group of strings.

func ContainsString

func ContainsString(stack []string, needle string) bool

ContainsString will return true if a string is found in a given group of strings.

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func SplitAccount

func SplitAccount(act string) (username string, domain string, err error)

SplitAccount splits a federated account into a username and domain.

func TimeToBytes

func TimeToBytes(t time.Time) []byte

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a fedihelper specific error.

func NewError

func NewError(m string) *Error

NewError wraps a message in a Error object.

func NewErrorf

func NewErrorf(m string, args ...interface{}) *Error

NewErrorf wraps a message in a Error object.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string.

type HostMeta

type HostMeta struct {
	XMLNS string `xml:"xmlns,attr"`
	Links []Link `xml:"Link"`
}

func FetchHostMeta

func FetchHostMeta(ctx context.Context, t *http.Client, domain string, config ...bool) (*HostMeta, error)

func (*HostMeta) WebFingerURI

func (h *HostMeta) WebFingerURI() WebFingerURI
type Link struct {
	Href     string `json:"href,omitempty"`
	Rel      string `json:"rel,omitempty" xml:"rel,attr"`
	Template string `json:"template,omitempty" xml:"template,attr"`
	Type     string `json:"type,omitempty"`
}

Link represents a link.

type NodeInfo

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

NodeInfo is a federated node info 2.0 object.

func FetchNodeInfoForDomain

func FetchNodeInfoForDomain(ctx context.Context, t *http.Client, domain string, config ...bool) (*NodeInfo, error)

FetchNodeInfoForDomain retrieves well-known nodeinfo from a federated instance.

type NodeInfoServices

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

NodeInfoServices contains the supported services of the node.

type NodeInfoSoftware

type NodeInfoSoftware struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

NodeInfoSoftware contains the software and version of the node.

type NodeInfoUsage

type NodeInfoUsage struct {
	LocalPosts int64              `json:"localPosts"`
	Users      NodeInfoUsageUsers `json:"users"`
}

NodeInfoUsage contains usage statistics.

type NodeInfoUsageUsers

type NodeInfoUsageUsers struct {
	Total int64 `json:"total"`
}

NodeInfoUsageUsers contains usage statistics about users.

type Software

type Software string
const (
	// SoftwareMastodon is the software keyword for Mastodon.
	SoftwareMastodon Software = "mastodon"
	// SoftwarePleroma is the software keyword for Pleroma.
	SoftwarePleroma Software = "pleroma"
)

func (Software) String

func (s Software) String() string

type WebFingerURI

type WebFingerURI string

func (WebFingerURI) FTemplate

func (w WebFingerURI) FTemplate() string

func (WebFingerURI) String

func (w WebFingerURI) String() string

type WellKnownNodeInfo

type WellKnownNodeInfo struct {
	Links []Link `json:"links"`
}

WellKnownNodeInfo is a federated well known node info object.

func FetchWellKnownNodeInfo

func FetchWellKnownNodeInfo(ctx context.Context, t *http.Client, domain string, config ...bool) (*WellKnownNodeInfo, error)

FetchWellKnownNodeInfo retrieves wellknown nodeinfo from a federated instance.

func (*WellKnownNodeInfo) NodeInfoURI

func (w *WellKnownNodeInfo) NodeInfoURI() (*url.URL, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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