libnetwork/iptables: move firewalld helpers together

Move the exported helpers to a separate file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-08-16 01:53:25 +02:00
parent 9efb1aabeb
commit 27067b2441
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 27 additions and 26 deletions

View file

@ -180,20 +180,6 @@ func (fwd *firewalldConnection) registerReloadCallback(callback func()) {
fwd.onReloaded = append(fwd.onReloaded, &callback)
}
// OnReloaded adds a callback to be executed when firewalld is reloaded.
// Adding a callback is idempotent; it ignores the given callback if it's
// already registered.
//
// Callbacks can be registered regardless if firewalld is currently running,
// but it will initialize firewalld before executing.
func OnReloaded(callback func()) {
// Make sure firewalld is initialized before we register callbacks.
// This function is also called from setupArrangeUserFilterRule,
// which is called during controller initialization.
_ = initCheck()
firewalld.registerReloadCallback(callback)
}
// checkRunning checks if firewalld is running.
//
// It calls some remote method to see whether the service is actually running.
@ -366,18 +352,6 @@ func (fwd *firewalldConnection) delInterface(intf string) error {
return nil
}
// AddInterfaceFirewalld adds the interface to the trusted zone. It is a
// no-op if firewalld is not running.
func AddInterfaceFirewalld(intf string) error {
return firewalld.addInterface(intf)
}
// DelInterfaceFirewalld removes the interface from the trusted zone It is a
// no-op if firewalld is not running.
func DelInterfaceFirewalld(intf string) error {
return firewalld.delInterface(intf)
}
type interfaceNotFound struct{ error }
func (interfaceNotFound) NotFound() {}

View file

@ -0,0 +1,27 @@
package iptables
// OnReloaded adds a callback to be executed when firewalld is reloaded.
// Adding a callback is idempotent; it ignores the given callback if it's
// already registered.
//
// Callbacks can be registered regardless if firewalld is currently running,
// but it will initialize firewalld before executing.
func OnReloaded(callback func()) {
// Make sure firewalld is initialized before we register callbacks.
// This function is also called from setupArrangeUserFilterRule,
// which is called during controller initialization.
_ = initCheck()
firewalld.registerReloadCallback(callback)
}
// AddInterfaceFirewalld adds the interface to the trusted zone. It is a
// no-op if firewalld is not running.
func AddInterfaceFirewalld(intf string) error {
return firewalld.addInterface(intf)
}
// DelInterfaceFirewalld removes the interface from the trusted zone It is a
// no-op if firewalld is not running.
func DelInterfaceFirewalld(intf string) error {
return firewalld.delInterface(intf)
}