Documentation
¶
Index ¶
- type Action
- type BackendError
- type Firewall
- type FirewalldBackend
- func (b *FirewalldBackend) AddRule(ctx context.Context, rule Rule) (string, error)
- func (b *FirewalldBackend) Disable(ctx context.Context) (string, error)
- func (b *FirewalldBackend) Enable(ctx context.Context) (string, error)
- func (b *FirewalldBackend) ListRules(ctx context.Context) (string, error)
- func (b *FirewalldBackend) Name() string
- func (b *FirewalldBackend) Reload(ctx context.Context) (string, error)
- func (b *FirewalldBackend) RemoveRule(ctx context.Context, rule Rule) (string, error)
- func (b *FirewalldBackend) Status(ctx context.Context) (string, error)
- type IptablesBackend
- func (b *IptablesBackend) AddRule(ctx context.Context, rule Rule) (string, error)
- func (b *IptablesBackend) Disable(ctx context.Context) (string, error)
- func (b *IptablesBackend) Enable(ctx context.Context) (string, error)
- func (b *IptablesBackend) ListRules(ctx context.Context) (string, error)
- func (b *IptablesBackend) Name() string
- func (b *IptablesBackend) Reload(ctx context.Context) (string, error)
- func (b *IptablesBackend) RemoveRule(ctx context.Context, rule Rule) (string, error)
- func (b *IptablesBackend) Status(ctx context.Context) (string, error)
- type NftablesBackend
- func (b *NftablesBackend) AddRule(ctx context.Context, rule Rule) (string, error)
- func (b *NftablesBackend) Disable(ctx context.Context) (string, error)
- func (b *NftablesBackend) Enable(ctx context.Context) (string, error)
- func (b *NftablesBackend) ListRules(ctx context.Context) (string, error)
- func (b *NftablesBackend) Name() string
- func (b *NftablesBackend) Reload(ctx context.Context) (string, error)
- func (b *NftablesBackend) RemoveRule(ctx context.Context, rule Rule) (string, error)
- func (b *NftablesBackend) Status(ctx context.Context) (string, error)
- type Protocol
- type Rule
- type UfwBackend
- func (b *UfwBackend) AddRule(ctx context.Context, rule Rule) (string, error)
- func (b *UfwBackend) Disable(ctx context.Context) (string, error)
- func (b *UfwBackend) Enable(ctx context.Context) (string, error)
- func (b *UfwBackend) ListRules(ctx context.Context) (string, error)
- func (b *UfwBackend) Name() string
- func (b *UfwBackend) Reload(ctx context.Context) (string, error)
- func (b *UfwBackend) RemoveRule(ctx context.Context, rule Rule) (string, error)
- func (b *UfwBackend) Status(ctx context.Context) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendError ¶
BackendError 定义防火墙后端错误
func (*BackendError) Error ¶
func (e *BackendError) Error() string
type Firewall ¶
type Firewall interface {
Name() string
Status(ctx context.Context) (string, error)
Enable(ctx context.Context) (string, error)
Disable(ctx context.Context) (string, error)
ListRules(ctx context.Context) (string, error)
AddRule(ctx context.Context, rule Rule) (string, error)
RemoveRule(ctx context.Context, rule Rule) (string, error)
Reload(ctx context.Context) (string, error)
}
Firewall 接口定义了防火墙管理的通用操作
func DetectFirewall ¶
DetectFirewall 自动探测系统使用的防火墙后端
type FirewalldBackend ¶
type FirewalldBackend struct {
// contains filtered or unexported fields
}
func NewFirewalldBackend ¶
func NewFirewalldBackend(exec executor.Executor, zone string) *FirewalldBackend
func (*FirewalldBackend) Disable ¶
func (b *FirewalldBackend) Disable(ctx context.Context) (string, error)
func (*FirewalldBackend) Enable ¶
func (b *FirewalldBackend) Enable(ctx context.Context) (string, error)
func (*FirewalldBackend) ListRules ¶
func (b *FirewalldBackend) ListRules(ctx context.Context) (string, error)
func (*FirewalldBackend) Name ¶
func (b *FirewalldBackend) Name() string
func (*FirewalldBackend) Reload ¶
func (b *FirewalldBackend) Reload(ctx context.Context) (string, error)
func (*FirewalldBackend) RemoveRule ¶
type IptablesBackend ¶
type IptablesBackend struct {
// contains filtered or unexported fields
}
func NewIptablesBackend ¶
func NewIptablesBackend(exec executor.Executor) *IptablesBackend
func (*IptablesBackend) Disable ¶
func (b *IptablesBackend) Disable(ctx context.Context) (string, error)
func (*IptablesBackend) Enable ¶
func (b *IptablesBackend) Enable(ctx context.Context) (string, error)
func (*IptablesBackend) ListRules ¶
func (b *IptablesBackend) ListRules(ctx context.Context) (string, error)
func (*IptablesBackend) Name ¶
func (b *IptablesBackend) Name() string
func (*IptablesBackend) Reload ¶
func (b *IptablesBackend) Reload(ctx context.Context) (string, error)
func (*IptablesBackend) RemoveRule ¶
type NftablesBackend ¶
type NftablesBackend struct {
// contains filtered or unexported fields
}
func NewNftablesBackend ¶
func NewNftablesBackend(exec executor.Executor) *NftablesBackend
func (*NftablesBackend) Disable ¶
func (b *NftablesBackend) Disable(ctx context.Context) (string, error)
func (*NftablesBackend) Enable ¶
func (b *NftablesBackend) Enable(ctx context.Context) (string, error)
func (*NftablesBackend) ListRules ¶
func (b *NftablesBackend) ListRules(ctx context.Context) (string, error)
func (*NftablesBackend) Name ¶
func (b *NftablesBackend) Name() string
func (*NftablesBackend) Reload ¶
func (b *NftablesBackend) Reload(ctx context.Context) (string, error)
func (*NftablesBackend) RemoveRule ¶
type Rule ¶
type Rule struct {
Port string // 例如 "80", "8080:8090"
Service string // 例如 "http", "ssh"
Protocol Protocol // tcp, udp, any
Action Action // allow, deny, reject, drop
Source string // 源 IP 或 CIDR, 为空表示所有
Comment string
}
Rule 定义通用防火墙规则
type UfwBackend ¶
type UfwBackend struct {
// contains filtered or unexported fields
}
func NewUfwBackend ¶
func NewUfwBackend(exec executor.Executor) *UfwBackend
func (*UfwBackend) Name ¶
func (b *UfwBackend) Name() string
func (*UfwBackend) RemoveRule ¶
Click to show internal directories.
Click to hide internal directories.