lib

package module
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: GPL-3.0 Imports: 10 Imported by: 7

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 added in v0.12.0

func BytesToInt64(b []byte) int64

func BytesToTime added in v0.12.0

func BytesToTime(b []byte) time.Time

func ContainsOneOfStrings added in v0.12.0

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 added in v0.12.0

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

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

func Int64ToBytes added in v0.12.0

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 added in v0.12.0

func TimeToBytes(t time.Time) []byte

Types

type Error added in v0.18.0

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

Error represents a fedihelper specific error.

func NewError added in v0.18.0

func NewError(m string) *Error

NewError wraps a message in a Error object.

func NewErrorf added in v0.18.0

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

NewErrorf wraps a message in a Error object.

func (*Error) Error added in v0.18.0

func (e *Error) Error() string

Error returns the error message as a string.

type HostMeta added in v0.18.0

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

func FetchHostMeta added in v0.18.0

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

func (*HostMeta) WebFingerURI added in v0.18.0

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 added in v0.18.0

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 added in v0.18.0

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 added in v0.18.0

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

NodeInfoServices contains the supported services of the node.

type NodeInfoSoftware added in v0.18.0

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

NodeInfoSoftware contains the software and version of the node.

type NodeInfoUsage added in v0.18.0

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

NodeInfoUsage contains usage statistics.

type NodeInfoUsageUsers added in v0.18.0

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

NodeInfoUsageUsers contains usage statistics about users.

type Software added in v0.18.0

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 added in v0.18.0

func (s Software) String() string

type WebFingerURI added in v0.18.0

type WebFingerURI string

func (WebFingerURI) FTemplate added in v0.18.0

func (w WebFingerURI) FTemplate() string

func (WebFingerURI) String added in v0.18.0

func (w WebFingerURI) String() string

type WellKnownNodeInfo added in v0.18.0

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

WellKnownNodeInfo is a federated well known node info object.

func FetchWellKnownNodeInfo added in v0.18.0

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 added in v0.18.0

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