| 97 | } |
| 98 | |
| 99 | func (mod *PacketProxy) runRule(enable bool) (err error) { |
| 100 | action := "-I" |
| 101 | if !enable { |
| 102 | action = "-D" |
| 103 | } |
| 104 | |
| 105 | args := []string{ |
| 106 | action, mod.chainName, |
| 107 | } |
| 108 | |
| 109 | if mod.rule != "" { |
| 110 | rule := strings.Split(mod.rule, " ") |
| 111 | args = append(args, rule...) |
| 112 | } |
| 113 | |
| 114 | args = append(args, []string{ |
| 115 | "-j", "NFQUEUE", |
| 116 | "--queue-num", fmt.Sprintf("%d", mod.queueNum), |
| 117 | }...) |
| 118 | |
| 119 | mod.Debug("iptables %s", args) |
| 120 | |
| 121 | _, err = core.Exec("iptables", args) |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | func (mod *PacketProxy) Configure() (err error) { |
| 126 | mod.destroyQueue() |