78 lines
1.9 KiB
Go
78 lines
1.9 KiB
Go
package iptables
|
|
|
|
// iptables 内置动作
|
|
var (
|
|
ACCEPT Action = "ACCEPT"
|
|
DROP Action = "DROP"
|
|
REJECT Action = "REJECT"
|
|
RETURN Action = "RETURN"
|
|
)
|
|
|
|
type Action string
|
|
type PolicyTarget string
|
|
|
|
type Table string
|
|
|
|
type Policy struct {
|
|
Name Chain `json:"name"`
|
|
Target PolicyTarget `json:"target"`
|
|
}
|
|
|
|
type Chain string
|
|
|
|
type Rule struct {
|
|
Chain Chain `json:"chain"`
|
|
// -j [target Chain]
|
|
Jump Chain `json:"jump"`
|
|
// -g [chain Chain]
|
|
Goto Chain `json:"goto"`
|
|
|
|
// -i [interface]
|
|
InputInterface string `json:"inputInterface"`
|
|
// ! -i [interface]
|
|
ExcludeInputInterface string `json:"excludeInputInterface"`
|
|
|
|
// -o [interface]
|
|
OutputInterface string `json:"outputInterface"`
|
|
// ! -o [interface]
|
|
ExcludeOutputInterface string `json:"excludeOutputInterface"`
|
|
|
|
// -s [source] example: 192.168.1.1, 192.168.1.0/24
|
|
Source string `json:"source"`
|
|
// ! -s [source] example: 192.168.1.1, 192.168.1.0/24
|
|
ExcludeSource string `json:"excludeSource"`
|
|
|
|
// -d [dest] example: 192.168.1.1, 192.168.1.0/24
|
|
Destination string `json:"destination"`
|
|
// ! -d [source] example: 192.168.1.1, 192.168.1.0/24
|
|
ExcludeDestination string `json:"excludeDestination"`
|
|
|
|
// -p [proto] example: all, tcp, udp, icmp
|
|
Protocol string `json:"protocol"`
|
|
// ! -p [proto] example: all, tcp, udp, icmp
|
|
ExcludeProtocol string `json:"excludeProtocol"`
|
|
|
|
// -m [match] 用于匹配扩展模块 example: tcp udp icmp
|
|
Match string `json:"match"`
|
|
|
|
// --sport example: 22 80
|
|
SrcPort string `json:"srcPort"`
|
|
// --sports example: 20000:40000
|
|
SrcPorts string `json:"srcPorts"`
|
|
// --dport example: 80
|
|
DstPort string `json:"dstPort"`
|
|
// --dports example: 45000:46000
|
|
DstPorts string `json:"dstPorts"`
|
|
|
|
// --limit example: 3/min
|
|
Limit string `json:"limit"`
|
|
|
|
Cmd string `json:"cmd"`
|
|
}
|
|
|
|
type Info struct {
|
|
Policies []Policy `json:"policies"`
|
|
Chains []Chain `json:"chains"`
|
|
Rules []Rule `json:"rules"`
|
|
}
|