瀏覽代碼

libnetwork/iptables: move firewalld helpers together

Move the exported helpers to a separate file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 年之前
父節點
當前提交
27067b2441
共有 2 個文件被更改,包括 27 次插入26 次删除
  1. 0 26
      libnetwork/iptables/firewalld.go
  2. 27 0
      libnetwork/iptables/firewalld_helpers_linux.go

+ 0 - 26
libnetwork/iptables/firewalld.go

@@ -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() {}

+ 27 - 0
libnetwork/iptables/firewalld_helpers_linux.go

@@ -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)
+}