go-ipset icon indicating copy to clipboard operation
go-ipset copied to clipboard

Added ipset.{Names,List,Add,Del,Destroy}()

Open xaionaro opened this issue 7 years ago • 3 comments

xaionaro avatar Feb 20 '18 13:02 xaionaro

What's the point of extraction List method out of IPSet struct' interface? It's the method on set, so should be binded to some set.

vanch avatar Feb 21 '18 10:02 vanch

There's no "NewIPSet()", so what is the correct way to extract a list of a set that was created by an external program? I could use something like ipset.IPSet{Name: "SL50"}.List(), but:

  • List() uses a pointer to IPSet (while it's not really required, BTW), so cannot call pointer method on ipset.IPSet literal. So I have to create a temporary useless variable like tempIPSet.
  • It is a hacky way (which can stop work somewhere in future), anyway.

There's "New()", but:

New creates a new set and returns an Interface to it.

(it creates a new set)

xaionaro avatar Feb 21 '18 11:02 xaionaro

In fact, ipset.IPSet{Name: "SL50"}.List() doesn't even work in many cases because List doesn't call initCheck. Unless you call some other method that does call initCheck before, ipsetPath will be an empty string at the time of List call.

WGH- avatar Apr 05 '18 18:04 WGH-