tree

package
v0.0.0-...-18f703b Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintNodesAtLevel

func PrintNodesAtLevel(n *Node, currentLevel int, level int)

PrintNodesAtLevel prints all nodes by given level in the tree

Types

type Edge

type Edge struct {
	Src string
	Dst string
}

Edge holds source and destiny data of a node

func EdgesFromString

func EdgesFromString(s string) []Edge

EdgesFromString return an array of Edges taking as input an string in gographiz format

type FlowTree

type FlowTree struct {
	ID         string   `json:"id"`
	Type       string   `json:"type"`
	SrcIP      string   `json:"src_ip"`
	DstIP      string   `json:"dst_ip"`
	SrcPort    string   `json:"src_port"`
	DstPort    string   `json:"dst_port"`
	Nodes      string   `json:"nodes"`
	NodesImg   string   `json:"nodes_img"`
	CapturedAt int64    `json:"captured_at"`
	Level      int      `json:"level"`
	Edges      [][]Edge `json:"-"`
	IsSat      bool     `json:"is_sat"`
}

FlowTree represents a data-path which a particular packet follows.

func NewFlowTree

func NewFlowTree(ID string, p packets.Packet) *FlowTree

NewFlowTree creates a new FlowTree with packets metadata

type Generator

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

Generator holds the topology to be used by the generation process

func NewGenerator

func NewGenerator(topo topology.Topology, props []smt.Property) *Generator

NewGenerator creates a new Generator object

func (*Generator) Generate

func (g *Generator) Generate(packets map[string][]packets.Packet) ([]FlowTree, error)

Generate iterates over all packets receive to construct a FlowTree or set of them

func (*Generator) Merge

func (g *Generator) Merge(grouped map[string][]FlowTree) ([]FlowTree, error)

Merge merges a grouped set/slice of FlowTree and returns a new slice of them merged.

type Handler

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

Handler topology struct

func NewHandler

func NewHandler(repo packets.Repository, topoRepo topology.Repository, smtRepo smt.Repository) *Handler

NewHandler returns a new FlowTree Handler

func (*Handler) GetAll

func (h *Handler) GetAll(response http.ResponseWriter, request *http.Request)

GetAll handles HTTP GET requests and returns a JSON representation of the generated FlowTrees

type Node

type Node struct {
	Name          string
	Label         string
	Parent        *Node
	Children      []*Node
	TimeOfIngress *time.Time
	TimeOfEgress  *time.Time

	Level int
	// contains filtered or unexported fields
}

Node a single node that composes the tree

func NewNode

func NewNode(name, label string) *Node

NewNode creates a new tree Node

func (*Node) AddChild

func (n *Node) AddChild(c *Node)

AddChild add a new child to the node

func (*Node) SetParent

func (n *Node) SetParent(p *Node)

SetParent sets the parent node

func (*Node) String

func (n *Node) String() string

String returns a string representation of this tree

type Tree

type Tree struct {
	Root       *Node
	LeafsLevel int
	// contains filtered or unexported fields
}

Tree represents a rooted tree objected

func NewTree

func NewTree(root *Node) *Tree

NewTree returns a new instance of Tree

func (*Tree) AddNode

func (t *Tree) AddNode(n *Node)

AddNode adds a new Node to the tree

func (*Tree) DFS

func (t *Tree) DFS(n *Node) [][]*Node

DFS returns an array of parent and children nodes after traversing the tree using depth-first search algorithm

func (*Tree) Edges

func (t *Tree) Edges() [][]Edge

Edges returns an array of edges for all the nodes in tree

func (*Tree) FindNode

func (t *Tree) FindNode(label string) *Node

FindNode returns the first node that matches its label

func (*Tree) FindNodeByLevel

func (t *Tree) FindNodeByLevel(label string, level int) *Node

FindNodeByLevel finds a new at a given level of the tree

func (*Tree) String

func (t *Tree) String(n *Node, s string)

String returns a string representation of the tree

func (*Tree) ToDOT

func (t *Tree) ToDOT(names, label string) string

ToDOT returns a string of the current tree in DOT format.

Jump to

Keyboard shortcuts

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