```
feat(iptables): 更新 iptables 规则命令并添加 reload 功能 移除了 iptables 命令中的冗余协议参数 `-p tcp`,统一使用更通用的匹配方式。 新增 `-s reload` 参数支持重新加载 iptables 规则,提升操作便利性。 同时更新了依赖库版本,包括 ip2region 和 golang.org/x 包。 ```
This commit is contained in:
19
main.go
19
main.go
@@ -449,7 +449,7 @@ func HandleCmd() {
|
||||
flag.BoolVar(&InterfacesList, "l", false, "列出可用的网络接口")
|
||||
Protocol = flag.String("f", "'tcp' or 'udp' or 'tcp or udp'", "指定 BPF 过滤器")
|
||||
PcapFile = flag.String("o", "", "保存捕获数据的输出文件(可选)")
|
||||
flag.StringVar(&instruction, "s", "", "-s start 启动 Iptables 规则\n-s stop 停止 Iptables 规则\n-s list 打印 Iptables 规则")
|
||||
flag.StringVar(&instruction, "s", "", "-s start 启动 Iptables 规则\n-s stop 停止 Iptables 规则\n-s list 打印 Iptables 规则\n-s reload 重启 Iptables 规则")
|
||||
flag.BoolVar(&help, "h", false, "")
|
||||
flag.BoolVar(&help, "help", false, "帮助信息")
|
||||
flag.Parse()
|
||||
@@ -480,6 +480,23 @@ func HandleCmd() {
|
||||
_name := fmt.Sprintf("root%d", i)
|
||||
iptables_del(_name)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
case "r":
|
||||
fallthrough
|
||||
case "restart":
|
||||
fallthrough
|
||||
case "reload":
|
||||
for i := 0; i < MAX_IPSET_NAME; i++ {
|
||||
_name := fmt.Sprintf("root%d", i)
|
||||
iptables_del(_name)
|
||||
}
|
||||
|
||||
for i := 0; i < MAX_IPSET_NAME; i++ {
|
||||
_name := fmt.Sprintf("root%d", i)
|
||||
iptables_add(_name)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
case "l":
|
||||
fallthrough
|
||||
|
||||
Reference in New Issue
Block a user