firewalltracker

package
v0.0.0-...-05217b6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionTrigger

type AdditionTrigger interface {
	TriggerAddition(string, Host) error
}

type Connection

type Connection struct {
	Host               Host
	Timer              *time.Timer
	DurationExtensions []DurationExtension
}

type DurationExtension

type DurationExtension struct {
	Extended time.Time
	Duration int
}

type ExpirationTrigger

type ExpirationTrigger interface {
	TriggerExpiration(string, Host) error
}

type Host

type Host struct {
	ClientDeviceID string
	ClientIP       net.IP
	ServerIP       net.IP
	Protocol       string
	StartPort      int
	EndPort        int
	BehindNAT      bool
	Date           time.Time // when we created the host
	Duration       int       // original duration in seconds
}

type HostHistory

type HostHistory struct {
	ConnectionID       string
	Host               Host
	Revoked            time.Time
	DurationExtensions []DurationExtension
}

type State

type State struct {
	Connections          map[string]*Connection
	AcceptNewConnections bool
	TriggerAddition      AdditionTrigger
	TriggerExpiration    ExpirationTrigger
	History              []HostHistory
	StuckConnections     []StuckConnection
	// contains filtered or unexported fields
}

func Create

func Create(addTrig AdditionTrigger, expTrig ExpirationTrigger) *State

func (*State) AddHost

func (s *State) AddHost(connId string, h Host) error

func (*State) ExtendDurationForHost

func (s *State) ExtendDurationForHost(h Host) (connId string, err error)

Prolongs the timer for a host if a connection exists and return its connectionId otherwise throw an error.

func (*State) ListStuck

func (s *State) ListStuck() []StuckConnection

func (*State) PrintHistory

func (s *State) PrintHistory()

func (*State) RemoveHost

func (s *State) RemoveHost(connId string, h Host, lock bool) error

Removes a host connection. In case the triggerExpiration method fails, we will mark the connection as stuck. The lock should be always true, it is set to false only when used in the shutdown SignalReceiver so that it mass shutdowns all connections. The reasoning was since we have the lock the mutex in the function we cannot call the RemoveHost function since it will wait for the mutex to unlock. This admittedly is a terrible solution and the entire firewall tracker system would need to be refactored to support a more clean channel centric solution. TODO - refactor firewall tracker package to use channels instead of mutexes.

func (*State) SignalReceiver

func (s *State) SignalReceiver(sig chan os.Signal, shutdown chan bool)

When launched due to receiving a signal, will remove all hosts that are in the state firewall connection map.

type StuckConnection

type StuckConnection struct {
	ConnectionID      string
	Host              Host
	DurationExtension []DurationExtension
	Since             time.Time
}

Jump to

Keyboard shortcuts

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