iptables-helper/pkg/utils/iptables/iptables.go

78 lines
1.9 KiB
Go
Raw Normal View History

2023-11-02 14:01:46 +08:00
package iptables
2023-11-02 23:27:36 +08:00
// iptables 内置动作
2023-11-02 14:01:46 +08:00
var (
ACCEPT Action = "ACCEPT"
DROP Action = "DROP"
2023-11-02 23:27:36 +08:00
REJECT Action = "REJECT"
RETURN Action = "RETURN"
2023-11-02 14:01:46 +08:00
)
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"`
2023-11-02 15:02:55 +08:00
// -j [target Chain]
Jump Chain `json:"jump"`
2023-11-02 18:30:54 +08:00
// -g [chain Chain]
Goto Chain `json:"goto"`
2023-11-02 15:02:55 +08:00
// -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"`
2023-11-03 10:31:11 +08:00
// ! -d [source] example: 192.168.1.1, 192.168.1.0/24
2023-11-02 15:02:55 +08:00
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"`
2023-11-02 20:19:38 +08:00
// -m [match] 用于匹配扩展模块 example: tcp udp icmp
Match string `json:"match"`
// --sport example: 22 80
SrcPort string `json:"srcPort"`
2023-11-02 20:43:44 +08:00
// --sports example: 20000:40000
SrcPorts string `json:"srcPorts"`
2023-11-02 20:19:38 +08:00
// --dport example: 80
DstPort string `json:"dstPort"`
2023-11-02 20:43:44 +08:00
// --dports example: 45000:46000
DstPorts string `json:"dstPorts"`
// --limit example: 3/min
Limit string `json:"limit"`
2023-11-03 10:31:11 +08:00
Cmd string `json:"cmd"`
2023-11-02 14:01:46 +08:00
}
2023-11-02 23:27:36 +08:00
type Info struct {
Policies []Policy `json:"policies"`
Chains []Chain `json:"chains"`
Rules []Rule `json:"rules"`
}