coreos / go-iptables

Go wrapper around iptables utility
Apache License 2.0
1.14k stars 257 forks source link

feat: add ListById function and test #96

Closed alegrey91 closed 2 years ago

alegrey91 commented 2 years ago

Fix #95

alegrey91 commented 2 years ago

Hi @squeed, thanks for your reply. So, you mean something like this?

// List rules in specified table/chain
func (ipt *IPTables) ListById(table, chain string, Id int) (string, error) {
    args := []string{"-t", table, "-S", chain, strconv.Itoa(Id)}
    rule, err := ipt.executeList(args)
    if err != nil {
        return "", err
    }
    return rule[0], nil
}
alegrey91 commented 2 years ago

I think could be more appropriate the name ListById() for this function, right?