```
feat(iptables): 更新 iptables 规则命令并添加 reload 功能 移除了 iptables 命令中的冗余协议参数 `-p tcp`,统一使用更通用的匹配方式。 新增 `-s reload` 参数支持重新加载 iptables 规则,提升操作便利性。 同时更新了依赖库版本,包括 ip2region 和 golang.org/x 包。 ```
This commit is contained in:
4
ipset.go
4
ipset.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user