yagoproto

package module
v0.0.0-...-9b85f49 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package yagoproto holds the YaCy peer-to-peer message types: the per-endpoint request and response data transfer objects exchanged over the /yacy/* protocol, built on the value-level types in yagomodel.

Index

Constants

View Source
const (
	CrawlReceiptResultUnavailable = "unavailable"
	CrawlReceiptResultException   = "exception"
	CrawlReceiptResultRobot       = "robot"
	CrawlReceiptResultRejected    = "rejected"
	CrawlReceiptResultDequeue     = "dequeue"
	CrawlReceiptResultFill        = "fill"
	CrawlReceiptResultUpdate      = "update"
	CrawlReceiptResultKnown       = "known"
	CrawlReceiptResultStale       = "stale"

	MaximumCrawlReceiptResultBytes   = 32
	MaximumCrawlReceiptReasonBytes   = 1024
	MaximumCrawlReceiptMetadataBytes = 256 << 10
)
View Source
const (
	CrawlURLResponseRejected = "rejected - insufficient call parameters"
	CrawlURLResponseOK       = "ok"
)
View Source
const (
	PathHello        = "/yacy/hello.html"
	PathTransferRWI  = "/yacy/transferRWI.html"
	PathTransferURL  = "/yacy/transferURL.html"
	PathSearch       = "/yacy/search.html"
	PathQuery        = "/yacy/query.html"
	PathIndex        = "/yacy/idx.json"
	PathList         = "/yacy/list.html"
	PathMessage      = "/yacy/message.html"
	PathProfile      = "/yacy/profile.html"
	PathCrawlURLs    = "/yacy/urls.xml"
	PathSeedlist     = "/yacy/seedlist.html"
	PathSeedlistJSON = "/yacy/seedlist.json"
	PathSeedlistXML  = "/yacy/seedlist.xml"
	// PathP2PSeeds and PathP2PSeedsJSON mirror upstream's unauthenticated
	// /p2p/seeds bootstrap endpoint: the same list principal peers upload to a
	// bootstrap position, in the plain genSeedStr form and the peers-array
	// JSON form the seedlist endpoints already serve.
	PathP2PSeeds       = "/p2p/seeds"
	PathP2PSeedsJSON   = "/p2p/seeds.json"
	PathCrawlReceipt   = "/yacy/crawlReceipt.html"
	PathYaCySearchHTML = "/yacysearch.html"
	PathYaCySearchJSON = "/yacysearch.json"
	PathYaCySearchRSS  = "/yacysearch.rss"
	PathOpenSearch     = "/opensearchdescription.xml"
	PathSuggestJSON    = "/suggest.json"
	PathSuggestXML     = "/suggest.xml"
)
View Source
const (
	EndpointMethodsGetPost = EndpointMethodGet | EndpointMethodPost
	EndpointMethodsPost    = EndpointMethodPost
)
View Source
const (
	HelloEndpointMethods        = EndpointMethodsGetPost
	TransferRWIEndpointMethods  = EndpointMethodsPost
	TransferURLEndpointMethods  = EndpointMethodsPost
	SearchEndpointMethods       = EndpointMethodsGetPost
	QueryEndpointMethods        = EndpointMethodsGetPost
	IndexEndpointMethods        = EndpointMethodsGetPost
	ListEndpointMethods         = EndpointMethodsGetPost
	MessageEndpointMethods      = EndpointMethodsGetPost
	ProfileEndpointMethods      = EndpointMethodsGetPost
	CrawlURLEndpointMethods     = EndpointMethodsGetPost
	SeedlistEndpointMethods     = EndpointMethodsGetPost
	CrawlReceiptEndpointMethods = EndpointMethodsPost
)
View Source
const (
	FieldNetworkName = "network.unit.name"
	FieldIam         = "iam"
	FieldYouAre      = "youare"
	FieldKey         = "key"
	FieldMyTime      = "mytime"
	FieldVersion     = "version"
	FieldUptime      = "uptime"
)
View Source
const (
	FieldSeed     = "seed"
	FieldCount    = "count"
	FieldMagicMD5 = "magicmd5"
	FieldYourIP   = "yourip"
	FieldYourType = "yourtype"
	FieldMessage  = "message"
)
View Source
const (
	FieldWordCount  = "wordc"
	FieldEntryCount = "entryc"
	FieldIndexes    = "indexes"
	FieldResult     = "result"
	FieldPause      = "pause"
	FieldUnknownURL = "unknownURL"
	FieldErrorURL   = "errorURL"
)
View Source
const (
	FieldURLCount = "urlc"
	FieldDouble   = "double"
)
View Source
const (
	FieldMySeed               = "myseed"
	FieldQuery                = "query"
	FieldExclude              = "exclude"
	FieldURLs                 = "urls"
	FieldTime                 = "time"
	FieldMaxDist              = "maxdist"
	FieldPartitions           = "partitions"
	FieldAbstracts            = "abstracts"
	FieldContentDom           = "contentdom"
	FieldStrictContentDom     = "strictContentDom"
	FieldTimezoneOffset       = "timezoneOffset"
	FieldLanguage             = "language"
	FieldModifier             = "modifier"
	FieldPrefer               = "prefer"
	FieldFilter               = "filter"
	FieldConstraint           = "constraint"
	FieldProfile              = "profile"
	FieldSiteHost             = "sitehost"
	FieldSiteHash             = "sitehash"
	FieldAuthor               = "author"
	FieldCollection           = "collection"
	FieldFileType             = "filetype"
	FieldProtocol             = "protocol"
	FieldResource             = "resource"
	FieldMaximumRecords       = "maximumRecords"
	FieldStartRecord          = "startRecord"
	FieldURLMaskFilter        = "urlmaskfilter"
	FieldPreferMaskFilter     = "prefermaskfilter"
	FieldVerify               = "verify"
	FieldNavigation           = "nav"
	FieldSearchTime           = "searchtime"
	FieldReferences           = "references"
	FieldJoinCount            = "joincount"
	FieldLinkCount            = "linkcount"
	FieldQueryEvidenceVersion = "yago.query.evidence.version"
	FieldQueryEvidenceTerm    = "yago.query.evidence.term"
)
View Source
const (
	FieldObject   = "object"
	FieldEnv      = "env"
	FieldResponse = "response"
	FieldMagic    = "magic"
)
View Source
const (
	FieldMessageProcess        = "process"
	FieldMessageSize           = "messagesize"
	FieldMessageAttachmentSize = "attachmentsize"
	FieldMessageSubject        = "subject"
)
View Source
const (
	FieldReason    = "reason"
	FieldLURLEntry = "lurlEntry"
	FieldDelay     = "delay"
)
View Source
const (
	FieldCall   = "call"
	FieldHashes = "hashes"
)
View Source
const (
	FieldSeedlistMaxCount   = "maxcount"
	FieldSeedlistMinVersion = "minversion"
	FieldSeedlistNode       = "node"
	FieldSeedlistMe         = "me"
	FieldSeedlistMy         = "my"
	FieldSeedlistID         = "id"
	FieldSeedlistName       = "name"
	FieldSeedlistAddress    = "address"
	FieldSeedlistCallback   = "callback"
	FieldSeedlistPeerName   = "peername"
)
View Source
const (
	FieldListColumn = "col"
	FieldListName   = "listname"
)
View Source
const (
	MessageResponseRejected   = "-1"
	MessageResponsePermission = "Welcome to my peer!"
	MessageResponseAccepted   = "Thank you!"
)
View Source
const (
	MessageSubjectMaximumBytes    = 100
	MessageBodyMaximumBytes       = 10240
	MessageAttachmentMaximumBytes = 0
)
View Source
const (
	QueryResponseRejected   = -1
	QueryResponseUnresolved = "-UNRESOLVED_PATTERN-"
)
View Source
const (
	MaximumTransferEntries  = 1000
	MaximumSearchTermHashes = 32
	MaximumSearchURLHashes  = 128
	MaximumCrawlURLHashes   = MaximumTransferEntries
)
View Source
const (
	ResultOK          = "ok"
	ResultWrongTarget = "wrong_target"
)
View Source
const DefaultNetwork = "freeworld"
View Source
const HelloSeedMaximumUTF16Units = 16000
View Source
const (
	IndexObjectHost = "host"
)
View Source
const ListColumnBlack = "black"
View Source
const (
	QueryMatchEvidenceVersion = 1
)
View Source
const SeedlistMaximumEntries = 1000

Variables

View Source
var ErrBadField = errors.New("bad field")

Functions

func InjectResponseHeader

func InjectResponseHeader(dst yagomodel.Message, version string, uptime int)

func MagicMD5

func MagicMD5(key, iam, essentials string) string

func NetworkUnit

func NetworkUnit(name string) string

func ValidCrawlReceiptResult

func ValidCrawlReceiptResult(result string) bool

Types

type CrawlReceiptRequest

type CrawlReceiptRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                yagomodel.Hash
	YouAre             yagomodel.Hash
	Key                string
	MagicMD5           string
	Result             string
	Reason             string
	LURLEntry          string
}

func ParseCrawlReceiptRequest

func ParseCrawlReceiptRequest(_ context.Context, form url.Values) (CrawlReceiptRequest, error)

func (CrawlReceiptRequest) Form

func (r CrawlReceiptRequest) Form() url.Values

type CrawlReceiptResponse

type CrawlReceiptResponse struct {
	ResponseHeader
	Delay int
}

func ParseCrawlReceiptResponse

func ParseCrawlReceiptResponse(m yagomodel.Message) (CrawlReceiptResponse, error)

func (CrawlReceiptResponse) Encode

type CrawlURLCall

type CrawlURLCall string
const (
	CrawlURLCallRemoteCrawl CrawlURLCall = "remotecrawl"
	CrawlURLCallURLHashList CrawlURLCall = "urlhashlist"
)

type CrawlURLRequest

type CrawlURLRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                string
	YouAre             string
	Key                string
	MagicMD5           string
	MyTime             string
	Call               CrawlURLCall
	Count              yagomodel.Optional[int]
	Time               yagomodel.Optional[int]
	Hashes             string
}

func ParseCrawlURLRequest

func ParseCrawlURLRequest(_ context.Context, form url.Values) (CrawlURLRequest, error)

func (CrawlURLRequest) Form

func (r CrawlURLRequest) Form() url.Values

func (CrawlURLRequest) HashList

func (r CrawlURLRequest) HashList() ([]yagomodel.Hash, bool)

type EndpointMethodSet

type EndpointMethodSet uint8
const (
	EndpointMethodGet EndpointMethodSet = 1 << iota
	EndpointMethodPost
)

type HelloRequest

type HelloRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Key                string
	Seed               yagomodel.Seed
	Count              int
	Iam                string
	MagicMD5           string
	MyTime             string
}

func ParseHelloRequest

func ParseHelloRequest(ctx context.Context, form url.Values) (HelloRequest, error)

func (HelloRequest) Form

func (r HelloRequest) Form() url.Values

type HelloResponse

type HelloResponse struct {
	ResponseHeader
	YourIP   string
	YourType yagomodel.PeerType
	MyTime   string
	Message  string
	Seeds    []yagomodel.Seed
}

func ParseHelloResponse

func ParseHelloResponse(ctx context.Context, m yagomodel.Message) (HelloResponse, error)

func (HelloResponse) Encode

func (r HelloResponse) Encode() yagomodel.Message

func (HelloResponse) KnownSeeds

func (r HelloResponse) KnownSeeds() []yagomodel.Seed

func (HelloResponse) OwnSeed

type IndexRequest

type IndexRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                string
	Key                string
	MagicMD5           string
	Object             string
}

func ParseIndexRequest

func ParseIndexRequest(_ context.Context, form url.Values) (IndexRequest, error)

func (IndexRequest) Form

func (r IndexRequest) Form() url.Values

type ListRequest

type ListRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                string
	Key                string
	MagicMD5           string
	Column             string
	Name               string
}

func ParseListRequest

func ParseListRequest(_ context.Context, form url.Values) (ListRequest, error)

func (ListRequest) Form

func (r ListRequest) Form() url.Values

type MessageProcess

type MessageProcess string
const (
	MessageProcessPermission MessageProcess = "permission"
	MessageProcessPost       MessageProcess = "post"
)

type MessageRequest

type MessageRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	YouAre             yagomodel.Hash
	Iam                yagomodel.Hash
	Key                string
	MagicMD5           string
	MyTime             string
	Process            MessageProcess
	MySeed             yagomodel.Optional[yagomodel.Seed]
	Subject            string
	Body               string
}

func ParseMessageRequest

func ParseMessageRequest(ctx context.Context, form url.Values) (MessageRequest, error)

func (MessageRequest) Form

func (r MessageRequest) Form() url.Values

type MessageResponse

type MessageResponse struct {
	ResponseHeader
	MessageSize    int
	AttachmentSize int
	Response       string
}

func ParseMessageResponse

func ParseMessageResponse(m yagomodel.Message) (MessageResponse, error)

func (MessageResponse) Encode

func (r MessageResponse) Encode() yagomodel.Message

type NetworkAccess

type NetworkAccess struct {
	NetworkName string
	Mode        NetworkAuthenticationMode
	Essentials  string
	Self        yagomodel.Hash
}

func (NetworkAccess) Authorizes

func (a NetworkAccess) Authorizes(form url.Values) bool

func (NetworkAccess) Sign

func (a NetworkAccess) Sign(form url.Values) error

func (NetworkAccess) SignWithSalt

func (a NetworkAccess) SignWithSalt(form url.Values, salt string)

type NetworkAuthenticationMode

type NetworkAuthenticationMode string
const (
	NetworkAuthenticationUncontrolled NetworkAuthenticationMode = "uncontrolled"
	NetworkAuthenticationSaltedMagic  NetworkAuthenticationMode = "salted-magic-sim"
)

type ProfileRequest

type ProfileRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                string
	Key                string
	MagicMD5           string
}

func ParseProfileRequest

func ParseProfileRequest(_ context.Context, form url.Values) (ProfileRequest, error)

func (ProfileRequest) Form

func (r ProfileRequest) Form() url.Values

type QueryFieldPositions

type QueryFieldPositions struct {
	Field        string                      `json:"f"`
	Requirements []QueryRequirementPositions `json:"r"`
}

type QueryMatchEvidence

type QueryMatchEvidence struct {
	Version             int                   `json:"v"`
	Analyzer            string                `json:"a"`
	RequirementOrdinals []int                 `json:"q"`
	AbsentOrdinals      []int                 `json:"x"`
	Snippet             string                `json:"s,omitempty"`
	SnippetMatches      []QueryMatchRange     `json:"m,omitempty"`
	BodyMatches         []QueryMatchRange     `json:"b,omitempty"`
	FieldPositions      []QueryFieldPositions `json:"p,omitempty"`
}

type QueryMatchRange

type QueryMatchRange struct {
	Start int `json:"s"`
	End   int `json:"e"`
}

type QueryObject

type QueryObject string
const (
	ObjectRWICount    QueryObject = "rwicount"
	ObjectRWIURLCount QueryObject = "rwiurlcount"
	ObjectLURLCount   QueryObject = "lurlcount"
	ObjectWantedLURLs QueryObject = "wantedlurls"
	ObjectWantedPURLs QueryObject = "wantedpurls"
	ObjectWantedWord  QueryObject = "wantedword"
	ObjectWantedRWI   QueryObject = "wantedrwi"
	ObjectWantedSeeds QueryObject = "wantedseeds"
)

type QueryRequest

type QueryRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	YouAre             string
	Iam                string
	Object             QueryObject
	Env                string
	Key                string
	MagicMD5           string
	MyTime             string
}

func ParseQueryRequest

func ParseQueryRequest(_ context.Context, form url.Values) (QueryRequest, error)

func (QueryRequest) Form

func (r QueryRequest) Form() url.Values

type QueryRequirementPositions

type QueryRequirementPositions struct {
	Ordinal   int   `json:"o"`
	Positions []int `json:"p"`
}

type QueryResponse

type QueryResponse struct {
	ResponseHeader
	Response           int
	MyTime             string
	Magic              string
	UnresolvedResponse bool
}

func ParseQueryResponse

func ParseQueryResponse(m yagomodel.Message) (QueryResponse, error)

func (QueryResponse) Encode

func (r QueryResponse) Encode() yagomodel.Message

type ResponseHeader

type ResponseHeader struct {
	Version string
	Uptime  int
}

type SearchAbstracts

type SearchAbstracts string
const SearchAbstractsAuto SearchAbstracts = "auto"

func (SearchAbstracts) Hashes

func (a SearchAbstracts) Hashes() []yagomodel.Hash

type SearchContentDomain

type SearchContentDomain string
const (
	ContentDomainAll   SearchContentDomain = "all"
	ContentDomainText  SearchContentDomain = "text"
	ContentDomainImage SearchContentDomain = "image"
	ContentDomainAudio SearchContentDomain = "audio"
	ContentDomainVideo SearchContentDomain = "video"
	ContentDomainApp   SearchContentDomain = "app"
	ContentDomainCtrl  SearchContentDomain = "ctrl"
)

type SearchRequest

type SearchRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                string
	Key                string
	MagicMD5           string
	MySeed             yagomodel.Optional[yagomodel.Seed]
	Query              []yagomodel.Hash
	Exclude            []yagomodel.Hash
	URLs               []yagomodel.Hash
	Count              int
	Time               int
	MaxDist            int
	Partitions         int
	Abstracts          SearchAbstracts
	ContentDom         SearchContentDomain
	StrictContentDom   bool
	TimezoneOffset     int
	Language           string
	Modifier           string
	Prefer             string
	Filter             string
	Constraint         string
	Profile            string
	SiteHost           string
	SiteHash           string
	Author             string
	Collection         string
	FileType           string
	Protocol           string
	EvidenceVersion    int
	EvidenceTerms      []string
}

func ParseSearchRequest

func ParseSearchRequest(ctx context.Context, form url.Values) (SearchRequest, error)

func (SearchRequest) Form

func (r SearchRequest) Form() url.Values

type SearchResponse

type SearchResponse struct {
	ResponseHeader
	SearchTime       int
	References       string
	JoinCount        int
	Count            int
	Resources        []yagomodel.URIMetadataRow
	InvalidResources int
	IndexCount       map[yagomodel.Hash]int
	IndexAbstract    map[yagomodel.Hash]string
	ResourceEvidence map[yagomodel.Hash]QueryMatchEvidence
}

func ParseSearchResponse

func ParseSearchResponse(m yagomodel.Message) (SearchResponse, error)

func (SearchResponse) Encode

func (r SearchResponse) Encode() yagomodel.Message

type SeedlistRequest

type SeedlistRequest struct {
	MaxCount        yagomodel.Optional[int]
	MinVersion      yagomodel.Optional[float64]
	NodeOnly        bool
	IncludeSelf     bool
	OwnSeedOnly     bool
	ID              yagomodel.Optional[yagomodel.Hash]
	IDPresent       bool
	Name            string
	NamePresent     bool
	AddressOnly     bool
	Callback        string
	CallbackPresent bool
	PeerName        string
	PeerNamePresent bool
}

func ParseSeedlistRequest

func ParseSeedlistRequest(_ context.Context, form url.Values) (SeedlistRequest, error)

func (SeedlistRequest) Form

func (r SeedlistRequest) Form() url.Values

type TransferRWIRequest

type TransferRWIRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                yagomodel.Hash
	YouAre             yagomodel.Hash
	WordCount          int
	EntryCount         int
	Indexes            []yagomodel.RWIPosting
	Key                string
	MagicMD5           string
	// contains filtered or unexported fields
}

func ParseTransferRWIRequest

func ParseTransferRWIRequest(ctx context.Context, form url.Values) (TransferRWIRequest, error)

func (TransferRWIRequest) ExceedsEntryLimit

func (r TransferRWIRequest) ExceedsEntryLimit() bool

func (TransferRWIRequest) Form

func (r TransferRWIRequest) Form() url.Values

func (TransferRWIRequest) MissingEntryCountField

func (r TransferRWIRequest) MissingEntryCountField() bool

func (TransferRWIRequest) MissingIndexesField

func (r TransferRWIRequest) MissingIndexesField() bool

func (TransferRWIRequest) MissingWordCountField

func (r TransferRWIRequest) MissingWordCountField() bool

type TransferRWIResponse

type TransferRWIResponse struct {
	ResponseHeader
	Result                 TransferRWIResult
	Pause                  int
	UnknownURL             []yagomodel.Hash
	ErrorURL               []yagomodel.Hash
	UnknownURLFieldPresent bool
}

func ParseTransferRWIResponse

func ParseTransferRWIResponse(m yagomodel.Message) (TransferRWIResponse, error)

func (TransferRWIResponse) Encode

type TransferRWIResult

type TransferRWIResult string
const (
	ResultBusy            TransferRWIResult = "busy"
	ResultNotGranted      TransferRWIResult = "not_granted"
	ResultTooHighLoad     TransferRWIResult = "too high load"
	ResultPostOrEnvIsNull TransferRWIResult = "post or env is null!"
	ResultNotAuthentified TransferRWIResult = "not authentified"
	ResultMissingWordC    TransferRWIResult = "missing wordc"
	ResultMissingEntryC   TransferRWIResult = "missing entryc"
	ResultMissingIndexes  TransferRWIResult = "missing indexes"
)

type TransferURLRequest

type TransferURLRequest struct {
	NetworkName        string
	NetworkNamePresent bool
	Iam                yagomodel.Hash
	YouAre             yagomodel.Hash
	URLCount           int
	URLs               []yagomodel.URIMetadataRow
	Key                string
	MagicMD5           string
}

func ParseTransferURLRequest

func ParseTransferURLRequest(ctx context.Context, form url.Values) (TransferURLRequest, error)

func (TransferURLRequest) Form

func (r TransferURLRequest) Form() url.Values

type TransferURLResponse

type TransferURLResponse struct {
	ResponseHeader
	Result   TransferURLResult
	Double   int
	ErrorURL []yagomodel.Hash
}

func ParseTransferURLResponse

func ParseTransferURLResponse(m yagomodel.Message) (TransferURLResponse, error)

func (TransferURLResponse) Encode

type TransferURLResult

type TransferURLResult string
const ResultErrorNotGranted TransferURLResult = "error_not_granted"

Jump to

Keyboard shortcuts

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