analyzer

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

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

Matrix DAG Analyzer

Matrix DAG Analyzer is an experimental tool for parsing matrix room DAGs and generating useful metrics about them.

Documentation

Index

Constants

View Source
const DefaultPowerLevel = 0
View Source
const EVENT_TYPE_CREATE = "m.room.create"
View Source
const EVENT_TYPE_JOIN_RULES = "m.room.join_rules"
View Source
const EVENT_TYPE_MEMBER = "m.room.member"
View Source
const EVENT_TYPE_POWER_LEVELS = "m.room.power_levels"
View Source
const EVENT_TYPE_SERVER_ACL = "m.room.server_acl"
View Source
const EVENT_TYPE_THIRD_PARTY_INVITE = "m.room.third_party_invite"

Variables

Functions

func IsAuthEvent

func IsAuthEvent(eventType EventType) bool

func IsPowerEvent

func IsPowerEvent(event *Event) bool

Types

type AuthResult

type AuthResult int64
const (
	AuthReject AuthResult = iota
	AuthSoftFail
	AuthAccept
)

func EventAuthExperimental

func EventAuthExperimental(event *EventNode, powerDAG LinearPowerDAG) AuthResult

NOTE: The powerDAG input is the entirety of the linearized power DAG

type CreateEventContent

type CreateEventContent struct {
	Creator     string       `json:"creator"`
	Federate    *bool        `json:"m.federate,omitempty"`
	Predecessor PreviousRoom `json:"predecessor,omitempty"`
	RoomVersion string       `json:"room_version,omitempty"`
	Type        string       `json:"type,omitempty"`
}

type DAGGenerationMetrics

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

type DAGTraversalMetrics

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

type DAGType

type DAGType int64
const (
	AuthDAGType DAGType = iota
	RoomDAGType
	StateDAGType
	AuthChainType
	PowerDAGType
)

type Event

type Event struct {
	EventID            string   `json:"_event_id"`
	RoomVersion        string   `json:"_room_version"`
	AuthEvents         []string `json:"auth_events"`
	Content            RawJSON  `json:"content"`
	Depth              int64    `json:"depth"`
	Hashes             RawJSON  `json:"hashes"`
	OriginTS           int64    `json:"origin_server_ts"`
	PrevEvents         []string `json:"prev_events"`
	Redacts            *string  `json:"redacts,omitempty"`
	RoomID             string   `json:"room_id"`
	Sender             string   `json:"sender"`
	Signatures         RawJSON  `json:"signatures,omitempty"`
	StateKey           *string  `json:"state_key,omitempty"`
	Type               string   `json:"type"`
	Unsigned           RawJSON  `json:"unsigned,omitempty"`
	MembershipContent  *MemberEventContent
	CreateContent      *CreateEventContent
	PowerLevelsContent *PowerLevelsEventContent
}

type EventEnumType

type EventEnumType int64
const (
	AuthEvent EventEnumType = iota
	StateEvent
	PowerEvent
	NewStateTimelineEvent
)

type EventID

type EventID = string

type EventIDNode

type EventIDNode struct {
	ID   EventID
	Node *EventNode
}

type EventNode

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

type EventQueue

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

func NewEventQueue

func NewEventQueue() EventQueue

func (*EventQueue) AddChild

func (e *EventQueue) AddChild(eventID EventID, event *EventNode, eventType EventEnumType)

func (*EventQueue) AddChildrenFromNode

func (e *EventQueue) AddChildrenFromNode(event *EventNode, eventType EventEnumType)

func (*EventQueue) Pop

func (e *EventQueue) Pop()

func (*EventQueue) Push

func (e *EventQueue) Push(event *EventNode)

type EventType

type EventType = string

type ExperimentalEvent

type ExperimentalEvent struct {
	EventID     string   `json:"_event_id"`
	RoomVersion string   `json:"_room_version"`
	AuthEvents  []string `json:"auth_events"`
	Content     RawJSON  `json:"content"`
	Depth       int64    `json:"depth"`
	Hashes      RawJSON  `json:"hashes"`
	OriginTS    int64    `json:"origin_server_ts"`
	PrevEvents  []string `json:"prev_events"`
	Redacts     *string  `json:"redacts,omitempty"`
	RoomID      string   `json:"room_id"`
	Sender      string   `json:"sender"`
	Signatures  RawJSON  `json:"signatures,omitempty"`
	StateKey    *string  `json:"state_key,omitempty"`
	Type        string   `json:"type"`
	Unsigned    RawJSON  `json:"unsigned,omitempty"`
}

type GraphMetrics

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

type LinearPowerDAG

type LinearPowerDAG []*EventNode

type MemberEventContent

type MemberEventContent struct {
	Membership                   string   `json:"membership"`
	AvatarURL                    *string  `json:"avatar_url,omitempty"`
	DisplayName                  *string  `json:"displayname,omitempty"`
	IsDirect                     *bool    `json:"is_direct,omitempty"`
	JoinAuthorisedViaUsersServer *string  `json:"join_authorised_via_users_server,omitempty"`
	Reason                       *string  `json:"reason,omitempty"`
	ThirdPartyInvite             *RawJSON `json:"third_party_invite,omitempty"`
}
type PowerEventLinks struct {
	PrevPowerEvent *PowerEventNode
}

type PowerEventNode

type PowerEventNode *EventNode

type PowerLevel

type PowerLevel int

type PowerLevels

type PowerLevels struct {
	Default PowerLevel
	Users   map[UserID]PowerLevel
}

type PowerLevelsEventContent

type PowerLevelsEventContent struct {
	Users        map[string]int `json:"users"`
	UsersDefault int            `json:"users_default"`
}

type PreviousRoom

type PreviousRoom struct {
	EventID string `json:"event_id"`
	RoomID  string `json:"room_id"`
}

type RawJSON

type RawJSON []byte

func (RawJSON) MarshalJSON

func (r RawJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface using a value receiver. This means that RawJSON used as an embedded value will still encode correctly.

func (*RawJSON) UnmarshalJSON

func (r *RawJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface using a pointer receiver.

type RoomDAG

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

func NewRoomDAG

func NewRoomDAG() RoomDAG

func ParseDAGFromFile

func ParseDAGFromFile(filename string, outputFilename string) (*RoomDAG, error)

func (*RoomDAG) CreatePowerDAGJSON

func (d *RoomDAG) CreatePowerDAGJSON(outputFilename string) error

func (*RoomDAG) EventCountByType

func (d *RoomDAG) EventCountByType(eventType string) int

func (*RoomDAG) EventsInFile

func (d *RoomDAG) EventsInFile() int

func (*RoomDAG) IsDuplicate

func (d *RoomDAG) IsDuplicate(newEvent Event) bool

func (*RoomDAG) PrintMetrics

func (d *RoomDAG) PrintMetrics()

func (*RoomDAG) TotalEvents

func (d *RoomDAG) TotalEvents() int

type RoomMode

type RoomMode int64
const (
	RoomModePublic RoomMode = iota
	RoomModeInvite
	RoomModeRestricted
)

type RoomState

type RoomState struct {
	Mode RoomMode
}
type StateEventLinks struct {
	PrevPowerEvent  *PowerEventNode
	PrevStateEvents []*StateEventNode
}

type StateEventNode

type StateEventNode *EventNode
type TimelineEventLinks struct {
	PrevPowerEvent     *PowerEventNode
	PrevTimelineEvents []*TimelineEventNode
}

type TimelineEventNode

type TimelineEventNode *EventNode

type UserID

type UserID string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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