Documentation
¶
Index ¶
- func GetPublicIP() (string, error)
- func SetNameForCountry(code string) string
- type IptablesManager
- func (m *IptablesManager) CreateIPSet(name string, maxElem int) error
- func (m *IptablesManager) DestroyIPSet(name string) error
- func (m *IptablesManager) FlushIPSet(name string) error
- func (m *IptablesManager) RemoveGeoBlockRules() error
- func (m *IptablesManager) RestoreIPSet(name string, cidrs []string) error
- func (m *IptablesManager) SetDefaultDeny(port string) error
- func (m *IptablesManager) SetRule(setName, port, action string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPublicIP ¶
GetPublicIP attempts to discover the public IP of the server.
func SetNameForCountry ¶
SetNameForCountry generates the ipset name for a country code.
Types ¶
type IptablesManager ¶
type IptablesManager struct{}
IptablesManager wraps iptables/ipset commands.
func NewIptablesManager ¶
func NewIptablesManager() *IptablesManager
NewIptablesManager creates a new IptablesManager.
func (*IptablesManager) CreateIPSet ¶
func (m *IptablesManager) CreateIPSet(name string, maxElem int) error
CreateIPSet creates an ipset with hash:net family inet.
func (*IptablesManager) DestroyIPSet ¶
func (m *IptablesManager) DestroyIPSet(name string) error
DestroyIPSet destroys an ipset.
func (*IptablesManager) FlushIPSet ¶
func (m *IptablesManager) FlushIPSet(name string) error
FlushIPSet flushes all entries from an ipset.
func (*IptablesManager) RemoveGeoBlockRules ¶
func (m *IptablesManager) RemoveGeoBlockRules() error
RemoveGeoBlockRules removes all popugate geo-block rules.
func (*IptablesManager) RestoreIPSet ¶
func (m *IptablesManager) RestoreIPSet(name string, cidrs []string) error
RestoreIPSet loads CIDR entries via ipset restore.
func (*IptablesManager) SetDefaultDeny ¶
func (m *IptablesManager) SetDefaultDeny(port string) error
SetDefaultDeny adds a default deny rule (for whitelist mode).
func (*IptablesManager) SetRule ¶
func (m *IptablesManager) SetRule(setName, port, action string) error
SetRule creates an iptables rule for geo-blocking. action: "DROP" or "ACCEPT"
Click to show internal directories.
Click to hide internal directories.