packets

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler packets handler

func NewHandler

func NewHandler(r Repository) *Handler

NewHandler creates a new packets Handler

func (Handler) GetAll

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

GetAll handles GET requests to return a JSON representation of Packets objects

func (Handler) Save

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

Save handles POST requests to save new Packet objects

type Packet

type Packet struct {
	ID             primitive.ObjectID `json:"id" bson:"_id"`
	Device         string             `json:"device" bson:"Device"`
	Type           float64            `json:"type" bson:"Type"`
	SrcIP          string             `json:"src_ip" bson:"SrcIP"`
	DstIP          string             `json:"dst_ip" bson:"DstIP"`
	SrcPort        string             `json:"src_port" bson:"SrcPort"`
	DstPort        string             `json:"dst_port" bson:"DstPort"`
	Payload        string             `json:"payload" bson:"Payload"`
	CapturedAt     *time.Time         `json:"captured_at" bson:"CapturedAt"`
	CapturedAtNano int64              `bson:"CapturedAtNano"`
}

Packet used to hold packet data

func (*Packet) GetType

func (p *Packet) GetType() string

GetType returns a string representing it packet's type

type Repository

type Repository interface {
	// FindAll returns all the packets from storage
	FindAll() ([]Packet, error)
	// Store stores a new packet
	Store(p Packet) error
}

Repository defines the methods to be implemented by the storage layer.

func NewRepository

func NewRepository(c *mongo.Client) Repository

NewRepository returns a new mongo Repository

Jump to

Keyboard shortcuts

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