core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleHeartbeatAck

func HandleHeartbeatAck(heartbeatAck *nraySchema.HeartbeatAck) (bool, bool)

HandleHeartbeatAck unpacks the message and returns the values

func HandleRegisteredNode

func HandleRegisteredNode(registeredNode *nraySchema.RegisteredNode) (string, time.Duration, *viper.Viper)

HandleRegisteredNode extracts the assigned scanner ID as well as the clock offset

func InitGlobalServerConfig

func InitGlobalServerConfig(config *viper.Viper) error

InitGlobalServerConfig initializes the GlobalConfig from the values provided by viper

func RunNode

func RunNode(args NodeCmdArgs)

RunNode is called by the main function of the node binary and gets everything up and running

func SendMessage

func SendMessage(sock mangos.Socket, message *nraySchema.NrayServerMessage)

SendMessage takes a socket and a servermessage that is going to be sent on the socket

func Start

func Start()

Start starts the core

Types

type GlobalConfig

type GlobalConfig struct {
	ListenPorts   []uint32
	ListenHost    string
	TLSConfig     *tls.Config
	Pools         []*Pool
	EventHandlers []events.EventHandler
}

GlobalConfig holds configuration settings that are relevant for the operation of the core

var CurrentConfig GlobalConfig

CurrentConfig is the initialized struct containing the configuration

func (GlobalConfig) CloseEventHandlers

func (gc GlobalConfig) CloseEventHandlers()

CloseEventHandlers calls Close() on all registered event handlers

func (GlobalConfig) LogEvents

func (gc GlobalConfig) LogEvents(events []*nraySchema.Event)

LogEvents sends a slice of events to all registered event handlers

type Job

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

Job keeps the state regarding work items

type JobState

type JobState int

JobState defines the state a Job is currently in

type Node

type Node struct {
	ID            string
	Name          string
	MetaInfo      string
	LastHeartbeat time.Time
	CurrentWork   *targetgeneration.AnyTargets
	// contains filtered or unexported fields
}

Node represents relevant information about a node

type NodeCmdArgs

type NodeCmdArgs struct {
	Server                     string
	Port                       string
	Debug                      bool
	PreferredPool              int32
	NodeName                   string
	UseTLS                     bool
	TLSIgnoreServerCertificate bool
	TLSCACertPath              string
	TLSClientKeyPath           string
	TLSClientCertPath          string
	TLSServerSAN               string
}

NodeCmdArgs holds user data that is passed on to scanner node

type Pool

type Pool struct {
	TargetChan <-chan targetgeneration.AnyTargets

	CountTargets  uint64
	CountWorkDone uint64
	// contains filtered or unexported fields
}

Pool is a container that contains nodes and work those nodes have still to do

func (*Pool) AddJobToJobArea

func (p *Pool) AddJobToJobArea(job *Job)

AddJobToJobArea adds a new job to this pool's job queue

func (*Pool) GetJobForNode

func (p *Pool) GetJobForNode(nodeID string) *Job

GetJobForNode returns the next job for a given node ID

func (*Pool) GetNumberOfAllJobs

func (p *Pool) GetNumberOfAllJobs() int

GetNumberOfAllJobs returns the length of the JobArea. If it is 0, we can likely stop all nodes and the server

func (*Pool) GetNumberOfWaitingJobs

func (p *Pool) GetNumberOfWaitingJobs() int

GetNumberOfWaitingJobs returns how many jobs are currently open

func (*Pool) IsJobGenerationDone

func (p *Pool) IsJobGenerationDone() bool

IsJobGenerationDone queries the flag indicating that all jobs were generated

func (*Pool) NodeHasOpenJobs

func (p *Pool) NodeHasOpenJobs(nodeID string) bool

NodeHasOpenJobs returns true if the node did not finish all of its jobs, false otherwise

func (*Pool) NodesEmpty

func (p *Pool) NodesEmpty() bool

NodesEmpty returns true if there are no nodes left in the pool

func (*Pool) ResumeAllNodes

func (p *Pool) ResumeAllNodes()

ResumeAllNodes resumes all nodes in this pool

func (*Pool) ResumeNode

func (p *Pool) ResumeNode(nodeID string)

ResumeNode resumes a single node identified by its ID

func (*Pool) SetJobGenerationDone

func (p *Pool) SetJobGenerationDone()

SetJobGenerationDone sets the flag that job generation is done

func (*Pool) SetTargetCount added in v1.1.0

func (p *Pool) SetTargetCount(targetCount uint64)

SetTargetCount is goroutine safe for setting the target count

func (*Pool) StopAllNodes

func (p *Pool) StopAllNodes()

StopAllNodes pauses all nodes in this pool

func (*Pool) StopNode

func (p *Pool) StopNode(nodeID string)

StopNode pauses a single node identified by its ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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