utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const LIIDLEN int = 12

LIIDLEN specifiy the len of the LIID number

View Source
const META string = "meta.json"

META set the meta file name

Variables

This section is empty.

Functions

func CompressEncrypt

func CompressEncrypt(in *[]byte, out *[]byte, key *[32]byte) error

CompressEncrypt compress with zsdt and then encrypt with chacha20-poly1305. After this it will be save the result in out so you can hash the data and not must load it again in mem.

func DecryptDecomp

func DecryptDecomp(in *[]byte, out *[]byte, key *[32]byte) error

DecryptDecomp decrypt the input with chacha20-poly1305 and decompress it. After this it will be save the result in out.

func DecryptDecompFile

func DecryptDecompFile(in, out string, key *[32]byte) error

DecryptDecompFile decrypt the encrypted file with chacha20-poly1305 and decompress it. After this it will be save the result to output file.

func TrimSuffix

func TrimSuffix(s, suffix string) (string, error)

TrimSuffix trim the given suffix from string

Types

type Capture

type Capture struct {
	Compressed int64
	Size       int64
	Hash       string
	// contains filtered or unexported fields
}

Capture hold all information about a capture file parsed from filename and fileinfo

func NewCapture

func NewCapture(path string, file os.FileInfo) (*Capture, error)

NewCapture create a parses pcap and enc file if its format is valid

type Meta

type Meta struct {
	LIID       string             `json:"liid"`
	Key        string             `json:"key"`
	Date       string             `json:"date"`
	Count      int                `json:"count"`
	Size       int64              `json:"size"`
	Compressed int64              `json:"compressed"`
	Files      map[string]Capture `json:"files"`
	// contains filtered or unexported fields
}

Meta holds the data for one day and file representations. Writes the meta.json file. Use NewMeta for a new struct.

func NewMeta

func NewMeta() *Meta

NewMeta init a new Meta skeleton

func (*Meta) Append

func (m *Meta) Append(c *Capture)

Append a Capture to Meta

func (*Meta) Close

func (m *Meta) Close() error

Close the file handler for the meta file

func (*Meta) Load

func (m *Meta) Load() ([]byte, error)

Load the meta file json data to struct and return the byte representation

func (*Meta) Open

func (m *Meta) Open(path string) error

Open a existing meta file or create a new one. the underlying dir struct must be exists.

func (*Meta) Write

func (m *Meta) Write() error

Write the meta data to file as json and overwrite previous data in file

type Node

type Node struct {
	KeyPair  crypt.KeyPair
	Shared   [32]byte
	Endpoint [32]byte
}

Node is the local instance holds his keypair and the shared secret

func NewNode

func NewNode(priv, endpoint []byte) *Node

NewNode create a Node with private key and shared secret

func (Node) Pack

func (n Node) Pack(in string, out string, move bool) error

Pack use a input folder and a output folder to collect all files and compress and encrypt the files. if move is true the files will be deleted in the input folder

func (Node) Pull

func (n Node) Pull(in string, out string, client *SSHClient) error

Pull fetch files from remote. If hash change a error msg will be printed. If a file in remote will be deleted after download it will not be synced.

func (Node) Push

func (n Node) Push(in string, out string, client *SSHClient) error

Push upload encrypted files to remote over sftp

func (Node) Unpack

func (n Node) Unpack(in string, out string, move bool) error

Unpack use a input folder and a output folder to collect all files and decompress and decrypt the files. if move is true the files will be deleted in the input folder

type SSHClient

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

SSHClient holds all information to connect to a ssh server

func NewSSHClient

func NewSSHClient(ip string, port int, user string) *SSHClient

NewSSHClient create a new ssh client with connection informations After creation use SetKeyAuth or SetPassAuth for auth method.

func (*SSHClient) Close

func (c *SSHClient) Close()

Close the session and the client connection to server

func (*SSHClient) Connect

func (c *SSHClient) Connect() error

Connect init a connection with config and auth to the ssh server

func (*SSHClient) RunCmd

func (c *SSHClient) RunCmd(cmd string) ([]byte, error)

RunCmd run the given command on the ssh server and return the output

func (*SSHClient) SetKeyAuth

func (c *SSHClient) SetKeyAuth(file string) error

SetKeyAuth use a keyfile to authenticate to the ssh server

func (*SSHClient) SetPassAuth

func (c *SSHClient) SetPassAuth(pass string)

SetPassAuth use the password authentication to connect to ssh server

Jump to

Keyboard shortcuts

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