firewall

package
v0.0.0-...-e2c201e Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PACKET_ICMP = iota
	PACKET_UDP  = iota
	PACKET_TCP  = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Firewall

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

func NewFirewall

func NewFirewall() *Firewall

func (*Firewall) AddFirewallSubscriber

func (firewall *Firewall) AddFirewallSubscriber(subscriber FirewallSubscriber)

func (*Firewall) GenerateTraffic

func (firewall *Firewall) GenerateTraffic(reputation *supplier.Reputation, time time.Time)

func (*Firewall) GetDatacenterClassBNetwork

func (firewall *Firewall) GetDatacenterClassBNetwork() string

GetDatacenterClassBNetwork returns the first 2 numbers of the A.B.C.D/16 of the Datacenter ipv4 class B network

func (*Firewall) GetLastEvents

func (firewall *Firewall) GetLastEvents() []*FirewallEvent

func (*Firewall) GetRules

func (firewall *Firewall) GetRules() string

func (*Firewall) Load

func (firewall *Firewall) Load(data map[string]interface{})

func (*Firewall) RemoveFirewallSubscriber

func (firewall *Firewall) RemoveFirewallSubscriber(subscriber FirewallSubscriber)

func (*Firewall) ResetRules

func (firewall *Firewall) ResetRules()

func (*Firewall) Save

func (firewall *Firewall) Save() string

func (*Firewall) SetRulesAndApply

func (firewall *Firewall) SetRulesAndApply(rules string) error

SetRulesAndApply will try to load the rules into the lua interpreter return error if the rules cannot be applied

func (*Firewall) SubmitIcmp

func (firewall *Firewall) SubmitIcmp(ipsrc, ipdst string, header [8]byte, payload string) bool

SubmitIcmp submit an ICMP packet and returns true if it passes through the firewall

func (*Firewall) SubmitTcp

func (firewall *Firewall) SubmitTcp(ipsrc, ipdst string, srcPort, dstPort uint16, flags uint8, payload string) bool

SubmitTcp submit a TCP packet and returns true if it passes through the firewall

func (*Firewall) SubmitUdp

func (firewall *Firewall) SubmitUdp(ipsrc, ipdst string, srcPort, dstPort uint16, payload string) bool

SubmitUdp submit an UDP packet and returns true if it passes through the firewall

type FirewallEvent

type FirewallEvent struct {
	Time   time.Time
	Packet *Packet
	Pass   bool
}

type FirewallSubscriber

type FirewallSubscriber interface {
	// when a rack change from status (RACK_NORMAL_STATE, RACK_OVER_CURRENT, RACK_HEAT_WARNING, RACK_OVER_HEAT, RACK_MELTING)
	PacketFiltered(event *FirewallEvent)
}

FirewallSubscriber is used to be inform when a packet has been filtered by the firewall (mainly used by MainFirewallWidget)

type JsonPacket

type JsonPacket struct {
	PacketType string
	Ipsrc      string // ip, [IP_IN], or [IP_OUT]
	Ipdst      string // ip, [IP_IN], or [IP_OUT]
	SrcPort    string // port, or [RANDOM]
	DstPort    string // port, or [RANDOM]
	IcmpHeader string // header (base64)
	Payload    string // payload, or [65K]
	Tcpflags   string // [FIN] and/or [SYN] and/or [RST] and/or [PSH] and/or [ACK] and/or [URG] and/or [ECE] and/or [CWR]
	Harmless   bool
}

JsonPacket is the format used to serialize (savegame) a Packet the string values can be a value, or a '[KEYWORD]'

type Packet

type Packet struct {
	PacketType int
	Ipsrc      string
	Ipdst      string
	SrcPort    uint16
	DstPort    uint16
	IcmpHeader [8]byte
	Payload    string
	Tcpflags   uint8
	Harmless   bool
}

Packet is the internal memory structure representing a normal (or offensive) packet going through the firewall

func NewPacket

func NewPacket(data map[string]interface{}) *Packet

func (*Packet) Save

func (packet *Packet) Save() string

type PacketGenerator

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

func NewPacketGenerator

func NewPacketGenerator(dcclassb string) *PacketGenerator

func (*PacketGenerator) GenerateRandomPacket

func (generator *PacketGenerator) GenerateRandomPacket() *Packet

func (*PacketGenerator) SetGame

func (generator *PacketGenerator) SetGame(dcclassb string)

Jump to

Keyboard shortcuts

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