From 45297924e95dc7a15f981da7348b651671f5f3df Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 12 Apr 2019 15:35:06 +0200 Subject: [PATCH] Routing, gateways. extend Gateways class with getInterface() to return technical interface and getInterfaceName() to return its name, for https://github.com/opnsense/core/issues/2279 --- .../app/library/OPNsense/Routing/Gateways.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php index e5481a500..74df2a94f 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php +++ b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php @@ -329,4 +329,32 @@ class Gateways return null; } + /** + * @param string $name gateway name + * @return string|null gateway interface + */ + public function getInterface($name) + { + foreach ($this->getGateways() as $gateway) { + if ($gateway['name'] == $name && !empty($gateway['if'])){ + return $gateway['if']; + } + } + return null; + } + + /** + * @param string $name gateway name + * @return string|null gateway interface + */ + public function getInterfaceName($name) + { + foreach ($this->getGateways() as $gateway) { + if ($gateway['name'] == $name && !empty($gateway['interface'])){ + return $gateway['interface']; + } + } + return null; + } + }