Documentation
¶
Index ¶
- func ValidateIP(ip string) error
- func ValidatePortForServer(allocations *environment.Allocations, port int) bool
- type Manager
- func (m *Manager) ApplyRule(rule *models.FirewallRule) error
- func (m *Manager) CleanupInvalidPortRules(serverUUID string, validPorts map[int]bool) error
- func (m *Manager) CreateRule(rule *models.FirewallRule) error
- func (m *Manager) DeleteAllRulesForServer(serverUUID string) error
- func (m *Manager) DeleteRule(ruleID uint) error
- func (m *Manager) GetRuleByID(ruleID uint) (*models.FirewallRule, error)
- func (m *Manager) GetRules(serverUUID string) ([]models.FirewallRule, error)
- func (m *Manager) GetRulesByPort(serverUUID string, port int) ([]models.FirewallRule, error)
- func (m *Manager) RebuildAllRules() error
- func (m *Manager) RemoveRule(rule *models.FirewallRule) error
- func (m *Manager) SyncRules(serverUUID string) error
- func (m *Manager) UpdateRule(ruleID uint, updates *models.FirewallRule) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateIP ¶
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 (*Manager) ApplyRule ¶
func (m *Manager) ApplyRule(rule *models.FirewallRule) error
ApplyRule applies a firewall rule to iptables
func (*Manager) CleanupInvalidPortRules ¶
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 ¶
DeleteAllRulesForServer deletes all firewall rules for a server
func (*Manager) DeleteRule ¶
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 ¶
GetRulesByPort returns all firewall rules for a specific port
func (*Manager) RebuildAllRules ¶
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) UpdateRule ¶
func (m *Manager) UpdateRule(ruleID uint, updates *models.FirewallRule) error
UpdateRule updates an existing firewall rule