firewall

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateIP

func ValidateIP(ip string) error

ValidateIP validates an IP address or CIDR notation

func ValidatePortForServer

func ValidatePortForServer(allocations *environment.Allocations, port int) bool

ValidatePortForServer validates that a port is allocated to a server

Types

type Manager

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

Manager handles firewall rule management and iptables operations

func NewManager

func NewManager() *Manager

NewManager creates a new firewall manager instance

func (*Manager) ApplyRule

func (m *Manager) ApplyRule(rule *models.FirewallRule) error

ApplyRule applies a firewall rule to iptables

func (*Manager) CleanupInvalidPortRules

func (m *Manager) CleanupInvalidPortRules(serverUUID string, validPorts map[int]bool) error

CleanupInvalidPortRules removes firewall rules for ports that are no longer allocated to a server

func (*Manager) CreateRule

func (m *Manager) CreateRule(rule *models.FirewallRule) error

CreateRule creates a new firewall rule

func (*Manager) DeleteAllRulesForServer

func (m *Manager) DeleteAllRulesForServer(serverUUID string) error

DeleteAllRulesForServer deletes all firewall rules for a server

func (*Manager) DeleteRule

func (m *Manager) DeleteRule(ruleID uint) error

DeleteRule deletes a firewall rule For block rules, this will unblock the IP by removing the DROP rule from iptables For allow rules, this will remove the explicit ALLOW rule (default behavior will apply)

func (*Manager) GetRuleByID

func (m *Manager) GetRuleByID(ruleID uint) (*models.FirewallRule, error)

GetRuleByID returns a single firewall rule by ID

func (*Manager) GetRules

func (m *Manager) GetRules(serverUUID string) ([]models.FirewallRule, error)

GetRules returns all firewall rules for a server

func (*Manager) GetRulesByPort

func (m *Manager) GetRulesByPort(serverUUID string, port int) ([]models.FirewallRule, error)

GetRulesByPort returns all firewall rules for a specific port

func (*Manager) RebuildAllRules

func (m *Manager) RebuildAllRules() error

RebuildAllRules rebuilds all firewall rules in iptables (useful for system restart)

func (*Manager) RemoveRule

func (m *Manager) RemoveRule(rule *models.FirewallRule) error

RemoveRule removes a firewall rule from iptables

func (*Manager) SyncRules

func (m *Manager) SyncRules(serverUUID string) error

SyncRules syncs all firewall rules from database to iptables

func (*Manager) UpdateRule

func (m *Manager) UpdateRule(ruleID uint, updates *models.FirewallRule) error

UpdateRule updates an existing firewall rule

Jump to

Keyboard shortcuts

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