idec

package module
v0.0.0-...-ba6681d Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 10 Imported by: 3

README

go-idec

Build Status codecov

Table of Contents

IDEC protocol in golang

Usage

go get github.com/Difrex/go-idec

cat > test.go <<EOF
package main

import (
	"fmt"
	idec "github.com/Difrex/go-idec"
)

func main() {
    txt := "aWkvb2svcmVwdG8vNFJnUkh4NUtJUHhwOWN1QUNKZ1gKZGV2ZWxvcC4xNgoxNDYzNjU5NDMzCmJ0aW1vZmVldgpzdGF0aW9uMTMsIDEzCkFsbApSZTog0J3QtdGB0LXRgtC10LLRi9C1INC/0YDQvtC10LrRgtGLCgoK0KMg0LzQtdC90Y8g0LjQtyDQv9GA0L7QtdC60YLQvtCyINC90LAg0LPQuNGC0YXQsNCx0LUg0YHQsNC80L7QtSDQuNC90YLQtdGA0LXRgdC90L7QtSBodHRwczovL2dpdGh1Yi5jb20vYnRpbW9mZWV2L2VtdWNoaXAKCtCt0YLQviDQsdGL0LvQsCDQvNC+0Y8g0L/QvtC/0YvRgtC60LAg0L3QsNC/0LjRgdCw0YLRjCDRjdC80YPQu9GP0YLQvtGAINC/0YDQvtGB0YLQtdC50YjQtdCz0L4g0LrQvtC80L/RjNGO0YLQtdGA0LAsINC90LAg0L/RgNC40LzQtdGA0LUgQ2hpcDgg0LggU3VwZXJDaGlwLiDQktGB0LUg0LjQs9GA0Ysg0LTQu9GPINGN0YLQuNGFINGB0LjRgdGC0LXQvCDRgNCw0LHQvtGC0LDRjtGCICjQt9CwINC40YHQutC70Y7Rh9C10L3QuNC10Lwg0L7QtNC90L7QuSwg0LrQsNC20LXRgtGB0Y8pLiDQndC+INCyINGN0LzRg9C70Y/RgtC+0YDQtSDQtdGB0YLRjCDQv9Cw0YDQsCDQvtGI0LjQsdC+0LosINC60L7RgtC+0YDRi9C1INGPINGC0LDQuiDQuCDQvdC1INGA0LXRiNC40LsgKNC+0LTQvdCwINGB0LLRj9C30LDQvdCwINGBINGA0LDQt9C80LXRgNC+0Lwg0L7QutC90LAgUXQsINCy0YLQvtGA0LDRjyDRgSDRg9C60LDQt9Cw0YLQtdC70Y/QvNC4IGMrKykuCgovLyDQsCDQstC+0L7QsdGJ0LUg0Y8g0LLRgdC10LPQtNCwINGF0L7RgtC10Lsg0L3QsNC/0LjRgdCw0YLRjCDRjdC80YPQu9GP0YLQvtGAIFNlZ2EgTWVnYSBEcml2ZSwg0L3QviDQtNGD0LzQsNGOINC90LUg0LTQvtGA0L7RgSDQtdGJ0LUpKQ=="
	
    message, err := idec.ParseMessage(txt)
	if err != nil {
		panic(err.Error())
	}
    
	fmt.Println(message.Subj)
}
EOF

go build test.go
./test
Re: Несетевые проекты

License

GNU GPL v3

Authors

Denis Zheleztsov difrex@lessmore.pw

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeMsgID

func MakeMsgID(msg string) string

MakeMsgID from provided plain bundled message

func ParseReptoField

func ParseReptoField(repto string) string

ParseReptoField @repto:MSGID, drops @repto prefix and return raw MSGID

Types

type Echo

type Echo struct {
	Name        string `json:"name"`
	Size        int    `json:"size"`
	Description string `json:"description"`
}

Echo echo description

func ParseEchoList

func ParseEchoList(list string) ([]Echo, error)

ParseEchoList parse /list.txt

type Extensions

type Extensions struct {
	ListTXT      string `json:"list_txt"`
	BlacklistTXT string `json:"backlist_txt"`
	Features     string `json:"features"`
	XCount       string `json:"xcount"`
}

Extensions IDEC extensions

func NewExtensions

func NewExtensions() Extensions

NewExtensions ...

type FetchConfig

type FetchConfig struct {
	Node   string   `json:"node"`
	Echoes []string `json:"echo"`
	Num    int      `json:"count"`
	Offset int      `json:"offset"`
	Limit  int      `json:"limit"`
}

FetchConfig node, echo, and other connection settings

func (FetchConfig) GetAllMessagesIDS

func (f FetchConfig) GetAllMessagesIDS() ([]ID, error)

GetAllMessagesIDS get all message ids from node

func (FetchConfig) GetEchoList

func (f FetchConfig) GetEchoList() ([]Echo, error)

GetEchoList ...

func (FetchConfig) GetMessagesIDS

func (f FetchConfig) GetMessagesIDS() ([]ID, error)

GetMessagesIDS get message ids from node

func (FetchConfig) GetRawMessages

func (f FetchConfig) GetRawMessages(ids []ID) ([]MSG, error)

GetRawMessages get messages from node

func (FetchConfig) PostMessage

func (f FetchConfig) PostMessage(authstring, message string) error

PostMessage sends prepared base64 point message to the node

type ID

type ID struct {
	Echo  string `json:"echo"`
	MsgID string `json:"msgids"`
}

ID ...

type MSG

type MSG struct {
	Message string `json:"message"`
	ID      string `json:"id"`
}

MSG ...

type Message

type Message struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Address   string `json:"address"`
	Echo      string `json:"echo"`
	Subg      string `json:"subg"`
	ID        string `json:"id"`
	Timestamp int    `json:"timestamp"`
	Body      string `json:"body"`
	Tags      Tags   `json:"tags"`
	Repto     string `json:"repto"`
}

Message IDEC message structure

func MakeBundledMessage

func MakeBundledMessage(pointMessage *PointMessage) (Message, error)

MakeBundledMessage from point message. Returns Message with empty From and Address fields you must set this somewhere outside

func ParseMessage

func ParseMessage(message string) (Message, error)

ParseMessage ...

type PointMessage

type PointMessage struct {
	Echo      string `json:"echo"`
	To        string `json:"to"`
	Subg      string `json:"subg"`
	EmptyLine string `json:"empty_line"`
	Repto     string `json:"repto"`
	Body      string `json:"body"`
}

PointMessage

func ParsePointMessage

func ParsePointMessage(message string) (*PointMessage, error)

ParsePointMessage ...

func (*PointMessage) PrepareMessageForSend

func (p *PointMessage) PrepareMessageForSend() string

PrepareMessageForSend Make base64 encoded message. Client.

func (*PointMessage) String

func (p *PointMessage) String() string

String from PointMessage

func (*PointMessage) Validate

func (p *PointMessage) Validate() error

Validate point message Returns error if one of the message fields is invalid Also, attach repto into body is it does not

type Tags

type Tags struct {
	II    string `json:"ii"`
	Repto string `json:"repto"`
}

Tags IDEC message tags

func ParseTags

func ParseTags(tags string) (Tags, error)

parseTags parse message tags and return Tags struct

func (Tags) CollectTags

func (t Tags) CollectTags() (string, error)

CollectTags make ii/ok message from Tags

Jump to

Keyboard shortcuts

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