Documentation
¶
Index ¶
Constants ¶
const PanelStateFile = "/var/lib/nftban/panels/enabled.conf"
PanelStateFile location
Variables ¶
This section is empty.
Functions ¶
func AddPortToFile ¶
AddPortToFile adds a port rule to a configuration file
func LoadEnabledPanels ¶ added in v1.0.20
LoadEnabledPanels reads the panel state file and returns enabled panel names
func RemovePortFromFile ¶
RemovePortFromFile removes a port rule from a configuration file
func SetPanelEnabled ¶ added in v1.0.20
SetPanelEnabled updates the panel state file to enable/disable a panel
Types ¶
type PanelConfig ¶ added in v1.0.20
type PanelConfig struct {
Name string // Panel name (directadmin, cpanel, plesk)
Enabled bool // Whether panel is enabled
ConfigFile string // Path to panel config file
TCPIn []int // TCP input ports
TCPOut []int // TCP output ports (for OUTPUT chain)
UDPIn []int // UDP input ports
UDPOut []int // UDP output ports (for OUTPUT chain)
}
PanelConfig represents a control panel's port configuration
func LoadPanelConfig ¶ added in v1.0.20
func LoadPanelConfig(configDir, panelName string) (*PanelConfig, error)
LoadPanelConfig loads port configuration for a specific panel by reading its bash config file
type PortConfig ¶
type PortConfig struct {
TCPPorts []int // All TCP ports (from T and B rules)
UDPPorts []int // All UDP ports (from U and B rules)
AllRules []PortRule // All rules with metadata
PortMap map[int][]string // port -> protocols (for deduplication)
}
PortConfig holds all port rules loaded from configuration
func LoadAllPanelPorts ¶ added in v1.0.20
func LoadAllPanelPorts(configDir string) (*PortConfig, error)
LoadAllPanelPorts loads port configuration for all enabled panels
func LoadAllPorts ¶ added in v1.0.20
func LoadAllPorts(configDir string) (*PortConfig, error)
LoadAllPorts loads ports from BOTH ports.d/ directory AND enabled panel configs
func LoadPortsFromDirectory ¶
func LoadPortsFromDirectory(dir string) (*PortConfig, error)
LoadPortsFromDirectory loads all port configuration files from a directory Expected format: PORT/PROTOCOL where PROTOCOL is T (TCP), U (UDP), or B (Both) Example: 22/T, 53/B, 80/T
func LoadPortsFromFile ¶
func LoadPortsFromFile(filePath string) (*PortConfig, error)
LoadPortsFromFile loads port rules from a single configuration file
func (*PortConfig) GetAllPorts ¶
func (c *PortConfig) GetAllPorts() []int
GetAllPorts returns all unique ports regardless of protocol
func (*PortConfig) GetTCPPorts ¶
func (c *PortConfig) GetTCPPorts() []int
GetTCPPorts returns all TCP ports (from T and B rules)
func (*PortConfig) GetUDPPorts ¶
func (c *PortConfig) GetUDPPorts() []int
GetUDPPorts returns all UDP ports (from U and B rules)