replay

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright © 2020 Stamus Networks oss@stamus-networks.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var DelayGrace = 100 * time.Microsecond

Functions

func DumpSetJSON

func DumpSetJSON(path string, set PcapSet) error

DumpSetJSON writes a Set object to user-defined JSON file

func FindPcapFiles

func FindPcapFiles(dir, suffix string) ([]string, error)

func Open

func Open(path string) (io.ReadCloser, error)

open opens a file handle while accounting for compression extracted from file magic

Types

type Config

type Config struct {
	Set            PcapSet
	WriteInterface string
	FilterRegex    *regexp.Regexp
	OutBpf         string
	DisableWait    bool
	Reorder        bool

	ScaleDuration time.Duration
	ScaleEnabled  bool
	ScalePerFile  bool

	SkipOutOfOrder bool
	SkipMTU        int

	TimeFrom, TimeTo time.Time
	Ctx              context.Context
}

Config is used for passing Handle configurations when creating a new replay object

func (Config) Validate

func (c Config) Validate() error

Validate implements a standard interface for checking config struct validity and setting sane default values.

type Content

type Content int

Content is enum signifying common file formats

const (
	Octet Content = iota
	Plaintext
	Gzip
	Xz
	Bzip
	Utf8
	Utf16
)

type Handle

type Handle struct {
	FileSet PcapSet
	// contains filtered or unexported fields
}

Handle is the core object managing replay state

func NewHandle

func NewHandle(c Config) (*Handle, error)

NewHandle creates a new Handle object and conducts pre-flight setup for pcap replay

func (*Handle) Play

func (h *Handle) Play() error

Play starts the replay sequence once Handle object has been constructed

type MapConfig

type MapConfig struct {
	Directory string
	Suffix    string
	Pattern   string
	Workers   int
}

type Pcap

type Pcap struct {
	Path string `json:"path"`

	Snaplen uint32 `json:"snaplen"`

	models.Counters
	models.Period
	models.Rates

	Delay      time.Duration `json:"delay"`
	DelayHuman string        `json:"delay_human"`
}

type PcapSet

type PcapSet struct {
	models.Period

	Files []*Pcap `json:"files"`
}

func LoadSetJSON

func LoadSetJSON(path string) (*PcapSet, error)

LoadSetJSON loads Set object from filesystem JSON dump

func NewPcapSet

func NewPcapSet(c MapConfig) (*PcapSet, error)

NewPcapSetFromList instantiates a new Set object from a list of Pcaps from filesystem module. Used for initial metadata scan.

func (*PcapSet) FilterFilesByRegex

func (s *PcapSet) FilterFilesByRegex(pattern *regexp.Regexp) error

FilterFilesByRegex subsets pcap Set by applying regexp pattern on file names.

func (*PcapSet) FilterFilesByTime

func (s *PcapSet) FilterFilesByTime(ts time.Time, beginning bool) error

FilterFilesByTime subsets pcap Set by extracting only files where Period beginning is after or end is before user-provided timestamp value.

func (*PcapSet) UpdateDelay

func (s *PcapSet) UpdateDelay() error

func (PcapSet) Validate

func (s PcapSet) Validate() error

Validate implements a standard interface for checking config struct validity and setting sane default values.

Jump to

Keyboard shortcuts

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