models

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMachineryServer

func NewMachineryServer(globalConfig *RelayConfig) (*machinery.Server, error)

NewMachineryServer create Redis backed Machinery Server from RelayConfig.

func ReadPublicKeyRSAFromString

func ReadPublicKeyRSAFromString(pemString string) (*rsa.PublicKey, error)

Types

type Activity

type Activity struct {
	Context interface{} `json:"@context,omitempty"`
	ID      string      `json:"id,omitempty"`
	Actor   string      `json:"actor,omitempty"`
	Type    string      `json:"type,omitempty"`
	Object  interface{} `json:"object,omitempty"`
	To      []string    `json:"to,omitempty"`
	Cc      []string    `json:"cc,omitempty"`
}

Activity : ActivityPub Activity.

func (*Activity) GenerateAnnounce

func (activity *Activity) GenerateAnnounce(host *url.URL) Activity

GenerateAnnounce : Generate Announce of activity.

func (*Activity) GenerateResponse

func (activity *Activity) GenerateResponse(host *url.URL, responseType string) Activity

GenerateResponse : Generate activity response.

func (*Activity) InnerActivity added in v1.2.0

func (activity *Activity) InnerActivity() (*Activity, error)

InnerActivity : Unwrap inner activity.

type ActivityObject

type ActivityObject struct {
	ID      string   `json:"id,omitempty"`
	Type    string   `json:"type,omitempty"`
	Name    string   `json:"name,omitempty"`
	Content string   `json:"content,omitempty"`
	To      []string `json:"to,omitempty"`
	Cc      []string `json:"cc,omitempty"`
}

ActivityObject : ActivityPub Activity.

type Actor

type Actor struct {
	Context           interface{} `json:"@context,omitempty"`
	ID                string      `json:"id,omitempty"`
	Type              string      `json:"type,omitempty"`
	Name              string      `json:"name,omitempty"`
	PreferredUsername string      `json:"preferredUsername,omitempty"`
	Summary           string      `json:"summary,omitempty"`
	Inbox             string      `json:"inbox,omitempty"`
	Endpoints         *Endpoints  `json:"endpoints,omitempty"`
	PublicKey         PublicKey   `json:"publicKey,omitempty"`
	Icon              *Image      `json:"icon,omitempty"`
	Image             *Image      `json:"image,omitempty"`
}

Actor : ActivityPub Actor.

func NewActivityPubActorFromSelfKey

func NewActivityPubActorFromSelfKey(globalConfig *RelayConfig) Actor

func (*Actor) GenerateSelfKey

func (actor *Actor) GenerateSelfKey(hostname *url.URL, publicKey *rsa.PublicKey)

GenerateSelfKey : Generate relay Actor from PublicKey.

func (*Actor) RetrieveRemoteActor

func (actor *Actor) RetrieveRemoteActor(url string, uaString string, cache *cache.Cache) error

RetrieveRemoteActor : Retrieve Actor from remote instance.

type Config

type Config int

Config : Enum for RelayConfig

const (
	// BlockService : Blocking for service-type actor
	BlockService Config = iota
	// ManuallyAccept : Manually accept follow-request
	ManuallyAccept
	// CreateAsAnnounce : Announce activity instead of relay create activity
	CreateAsAnnounce
)

type Endpoints

type Endpoints struct {
	SharedInbox string `json:"sharedInbox,omitempty"`
}

Endpoints : Contains SharedInbox address.

type Image

type Image struct {
	URL string `json:"url,omitempty"`
}

Image : Image Object.

type Nodeinfo

type Nodeinfo struct {
	Version           string           `json:"version"`
	Software          NodeinfoSoftware `json:"software"`
	Protocols         []string         `json:"protocols"`
	Services          NodeinfoServices `json:"services"`
	OpenRegistrations bool             `json:"openRegistrations"`
	Usage             NodeinfoUsage    `json:"usage"`
	Metadata          NodeinfoMetadata `json:"metadata"`
}

Nodeinfo : Nodeinfo Resource.

type NodeinfoLink struct {
	Rel  string `json:"rel"`
	Href string `json:"href"`
}

NodeinfoLink : Nodeinfo Link Resource.

type NodeinfoLinks struct {
	Links []NodeinfoLink `json:"links"`
}

NodeinfoLinks : Nodeinfo Link Resource.

type NodeinfoMetadata

type NodeinfoMetadata struct {
}

NodeinfoMetadata : NodeinfoMetadata Resource.

type NodeinfoResources

type NodeinfoResources struct {
	NodeinfoLinks NodeinfoLinks
	Nodeinfo      Nodeinfo
}

NodeinfoResources : Nodeinfo Resources.

func (*NodeinfoResources) GenerateFromActor

func (resource *NodeinfoResources) GenerateFromActor(hostname *url.URL, _ *Actor, serverVersion string)

GenerateFromActor : Generate Webfinger resource from Actor.

type NodeinfoServices

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

NodeinfoServices : NodeinfoSoftware Resource.

type NodeinfoSoftware

type NodeinfoSoftware struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	Repository string `json:"repository,omitempty"`
}

NodeinfoSoftware : NodeinfoSoftware Resource.

type NodeinfoUsage

type NodeinfoUsage struct {
	Users NodeinfoUsageUsers `json:"users"`
}

NodeinfoUsage : NodeinfoUsage Resource.

type NodeinfoUsageUsers

type NodeinfoUsageUsers struct {
	Total          int `json:"total"`
	ActiveMonth    int `json:"activeMonth"`
	ActiveHalfyear int `json:"activeHalfyear"`
}

NodeinfoUsageUsers : NodeinfoUsageUsers Resource.

type PublicKey

type PublicKey struct {
	ID           string `json:"id,omitempty"`
	Owner        string `json:"owner,omitempty"`
	PublicKeyPem string `json:"publicKeyPem,omitempty"`
}

PublicKey : Activity Certificate.

type RelayConfig

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

RelayConfig contains valid configuration.

func NewRelayConfig

func NewRelayConfig() (*RelayConfig, error)

NewRelayConfig create valid RelayConfig from viper configuration.

func (*RelayConfig) ActorKey

func (relayConfig *RelayConfig) ActorKey() *rsa.PrivateKey

ActorKey is API Worker's HTTPSignature private key.

func (*RelayConfig) DumpWelcomeMessage

func (relayConfig *RelayConfig) DumpWelcomeMessage(moduleName string, version string) string

DumpWelcomeMessage provide build and config information string.

func (*RelayConfig) JobConcurrency

func (relayConfig *RelayConfig) JobConcurrency() int

JobConcurrency is API Worker's jobConcurrency definition.

func (*RelayConfig) RedisClient

func (relayConfig *RelayConfig) RedisClient() *redis.Client

RedisClient is return redis client from RelayConfig.

func (*RelayConfig) ServerBind

func (relayConfig *RelayConfig) ServerBind() string

ServerBind is API Server's bind interface definition.

func (*RelayConfig) ServerHostname

func (relayConfig *RelayConfig) ServerHostname() *url.URL

ServerHostname is API Server's hostname definition.

func (*RelayConfig) ServerServiceName

func (relayConfig *RelayConfig) ServerServiceName() string

ServerServiceName is API Server's servername definition.

type RelayState

type RelayState struct {
	RedisClient *redis.Client

	RelayConfig    relayConfig    `json:"relayConfig,omitempty"`
	LimitedDomains []string       `json:"limitedDomains,omitempty"`
	BlockedDomains []string       `json:"blockedDomains,omitempty"`
	Subscriptions  []Subscription `json:"subscriptions,omitempty"`
	// contains filtered or unexported fields
}

RelayState : Store subscriptions and relay configurations

func NewState

func NewState(redisClient *redis.Client, notifiable bool) RelayState

NewState : Create new RelayState instance with redis client

func (*RelayState) AddSubscription

func (config *RelayState) AddSubscription(domain Subscription)

AddSubscription : Add new instance for subscription list

func (*RelayState) DelSubscription

func (config *RelayState) DelSubscription(domain string)

DelSubscription : Delete instance from subscription list

func (*RelayState) ListenNotify

func (config *RelayState) ListenNotify(c chan<- bool)

func (*RelayState) Load

func (config *RelayState) Load()

Load : Refrash content from redis

func (*RelayState) SelectSubscription

func (config *RelayState) SelectSubscription(domain string) *Subscription

SelectSubscription : Select instance from string

func (*RelayState) SetBlockedDomain

func (config *RelayState) SetBlockedDomain(domain string, value bool)

SetBlockedDomain : Set/Unset instance for blocked domain

func (*RelayState) SetConfig

func (config *RelayState) SetConfig(key Config, value bool)

SetConfig : Set relay configuration

func (*RelayState) SetLimitedDomain

func (config *RelayState) SetLimitedDomain(domain string, value bool)

SetLimitedDomain : Set/Unset instance for limited domain

type Signature

type Signature struct {
	Type           string `json:"type,omitempty"`
	Creator        string `json:"creator,omitempty"`
	Created        string `json:"created,omitempty"`
	SignatureValue string `json:"signatureValue,omitempty"`
}

Signature : ActivityPub Header Signature.

type Subscription

type Subscription struct {
	Domain     string `json:"domain,omitempty"`
	InboxURL   string `json:"inbox_url,omitempty"`
	ActivityID string `json:"activity_id,omitempty"`
	ActorID    string `json:"actor_id,omitempty"`
}

Subscription : Instance subscription information

type WebfingerLink struct {
	Rel  string `json:"rel,omitempty"`
	Type string `json:"type,omitempty"`
	Href string `json:"href,omitempty"`
}

WebfingerLink : Webfinger Link Resource.

type WebfingerResource

type WebfingerResource struct {
	Subject string          `json:"subject,omitempty"`
	Links   []WebfingerLink `json:"links,omitempty"`
}

WebfingerResource : Webfinger Resource.

func (*WebfingerResource) GenerateFromActor

func (resource *WebfingerResource) GenerateFromActor(hostname *url.URL, actor *Actor)

GenerateFromActor : Generate Webfinger resource from Actor.

Jump to

Keyboard shortcuts

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