feat(iptables): 更新 iptables 规则命令并添加 reload 功能

移除了 iptables 命令中的冗余协议参数 `-p tcp`,统一使用更通用的匹配方式。
新增 `-s reload` 参数支持重新加载 iptables 规则,提升操作便利性。
同时更新了依赖库版本,包括 ip2region 和 golang.org/x 包。
```
This commit is contained in:
2025-12-09 13:25:08 +08:00
parent 4fb84e3312
commit 7c783f7bdf
5 changed files with 31 additions and 6 deletions

View File

@@ -130,7 +130,7 @@ func RemoveIPIfInSets(prefix string, max int, ip string) (string, error) {
// 添加 Iptables 规则
func iptables_add(setName string) error {
cmd := exec.Command("sh", "-c", fmt.Sprintf("iptables -A INPUT -p tcp -m set --match-set %s src -j DROP", setName))
cmd := exec.Command("sh", "-c", fmt.Sprintf("iptables -A INPUT -m set --match-set %s src -j DROP", setName))
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
@@ -148,7 +148,7 @@ func iptables_add(setName string) error {
// 删除 Iptables 规则
func iptables_del(setName string) error {
cmd := exec.Command("sh", "-c", fmt.Sprintf("iptables -D INPUT -p tcp -m set --match-set %s src -j DROP", setName))
cmd := exec.Command("sh", "-c", fmt.Sprintf("iptables -D INPUT -m set --match-set %s src -j DROP", setName))
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout