github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/controller/pkg/cleaner/cleaner.go (about)

     1  package cleaner
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"go.aporeto.io/enforcerd/trireme-lib/controller/constants"
     7  	"go.aporeto.io/enforcerd/trireme-lib/controller/internal/supervisor/iptablesctrl"
     8  	"go.aporeto.io/enforcerd/trireme-lib/controller/pkg/fqconfig"
     9  	"go.aporeto.io/enforcerd/trireme-lib/policy"
    10  )
    11  
    12  // CleanAllTriremeACLs cleans up all previous Trireme ACLs. It can be called from
    13  // other packages for housekeeping.
    14  // TODO: fix this, this was ok before, but it's ugly now because we have to
    15  //       injecting iptablesLockfile here..
    16  //       iptables and it's configuration is part of trireme and iptables cleanup should
    17  //       be done when the trireme instance starts up.
    18  func CleanAllTriremeACLs(iptablesLockfile string) error {
    19  
    20  	fq := fqconfig.NewFilterQueue(0, nil)
    21  
    22  	ipt, err := iptablesctrl.NewInstance(fq, constants.LocalServer, true, nil, iptablesLockfile, policy.None)
    23  	if err != nil {
    24  		return fmt.Errorf("unable to initialize cleaning iptables controller: %s", err)
    25  	}
    26  
    27  	return ipt.CleanUp()
    28  }