fwcom

package
v0.0.0-...-2fa181f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Firewall Common includes common stuff may be used while dealing with all firewalls, like Srouce IP, Destination IP, Destination Port and Application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateIPs

func ValidateIPs(ips []string) ([]string, error)

The goal is to get a list of IPs and check if all are valid IP addresses. ValidateIPs gets a slice of strings and if all IPs are valid return list of IPs as a slice of string and nil as error. Otherwise, it returns an empty slice and an error

func WriteFwRuleCSV

func WriteFwRuleCSV(fpath string, fwr []FwRule) error

WriteFwRuleCSV ...

func WriteFwRuleSimpleCSV

func WriteFwRuleSimpleCSV(fpath string, fws []FwRuleSimple) error

WriteFwRuleSimpleCSV ...

Types

type FwRule

type FwRule struct {
	SrcIPs      []string
	DstIPs      []string
	Protocol    []string // TCP/UDP
	Ports       []string
	Application string
	Needed      bool // If firewall rule is needed
}

FwRule ...

func ConvertSimpleToFwRule

func ConvertSimpleToFwRule(fws []FwRuleSimple) []FwRule

ConvertSimpleToFwRule ...

func ParseRecords

func ParseRecords(record []string, csvColumns map[string]int) (FwRule, error)

ParseRecords is to parse

func ReadFWRulesFile

func ReadFWRulesFile(fpath string) ([]FwRule, error)

The goal is to read an CSV file and convert it to firewall rules. The assumtion is that the file is in the right format as the function ParseRecords on his package expected. ReadFWRulesFile gets a file patch, reads it and return a slice of FwRule

type FwRuleSimple

type FwRuleSimple struct {

	// If the Type FwRule is used, FwRuleIdx is the index of FwRule
	FwRuleIdx int
	SrcIP     string // Srouce IP
	SrcZone   string // Source Zone
	SrcInt    string // Source Interface

	DstIP   string // Destination IP
	DstZone string // Destination Zone
	DstInt  string // Destination Interface

	Protocol    string // TCP/UDP
	Port        string
	Application string
	Needed      bool // If firewall rule is needed
}

FwRuleSimple ...

func ConvertFwRuleToSimple

func ConvertFwRuleToSimple(fwr []FwRule) []FwRuleSimple

ConvertFwRuleToSimple converts a slice of FwRule to a slice of FwRuleSimple

Jump to

Keyboard shortcuts

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