Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandRunner ¶
type CommandRunner struct {
Adapter Adapter
}
func IndentSection(txt string) *text.SplitterResult { indentRegexMap := map[string]string{ "regex": `(?P<section>^\w[^\n]+(\n[ \t]+[^\n]+)+)`, "name": "intent", "flags": "m", "pcre": "true", }
indentRegexSplitter, err := text.NewSplitterFromMap(indentRegexMap) if err != nil { panic(err) }
indentResult, err := indentRegexSplitter.Input(txt) if err != nil { panic(err) }
return indentResult }
func (*CommandRunner) RunConfig ¶
func (c *CommandRunner) RunConfig(config interface{}) (output interface{}, err error)
type FwAdapter ¶
FwAdapter 防火墙适配器通用接口 基于对 ASA、SecPath、Fortigate、SRX、USG、Dptech 等实现的总结
所有防火墙适配器都需要实现 api.Adapter 接口,该接口包含以下核心方法:
Info(force bool) (*device.DeviceBaseInfo, error) 获取设备基本信息(主机名、版本、型号、序列号等)
ParseName(force bool) string 解析设备名称/主机名
PortList(force bool) []api.Port 获取端口列表,包含端口名称、IP地址、VRF等信息
RouteTable(force bool) (ipv4TableMap, ipv6TableMap map[string]*network.AddressTable) 获取路由表,返回 IPv4 和 IPv6 路由表,按 VRF 组织
GetConfig(force bool) interface{} 获取设备配置(完整配置或部分配置)
GetRawConfig(apiPath string, force bool) (any, error) 获取原始配置(支持指定 API 路径,某些适配器如 Fortigate 支持)
BatchRun(p interface{}) (interface{}, error) 批量执行命令(多次登录设备) 参数: []*command.CliCmdList 或 []*command.HttpCmdList
BatchConfig(p ...interface{}) (interface{}, error) 批量配置(单次登录,合并执行) 参数: []*command.CliCmdList、[]string 等类型
TaskId() uint 获取任务 ID(用于关联任务)
AttachChannel(out chan string) bool 附加输出通道(用于实时输出)
注意:所有防火墙适配器都实现了 api.Adapter 接口
Directories
¶
| Path | Synopsis |
|---|---|
|
fw
|
|
|
dptech/example
command
|
|
|
forti/example
command
|
|
|
sangfor/example
command
|
|
|
usg/example
command
|
|
|
lb
|
|