serverinfo icon indicating copy to clipboard operation
serverinfo copied to clipboard

Showing active gateway if more than one

Open oleua opened this issue 6 months ago • 2 comments

Hi! I have more than one gateway, so the dashboard shows all of them. I suggest to show the active one separately. My suggestion to update Linux.php file in case of using Linux:

        public function getNetworkInfo(): array {
                $result = [
                        'gateway' => '',
                        'current_gateway' => '',
                        'hostname' => \gethostname(),
                ];

                if (function_exists('shell_exec')) {
                        $result['gateway'] = shell_exec('ip route | awk \'/default/ { print $3 }\'');
                        $result['current_gateway'] = shell_exec('ip route | awk \'/default/\' | awk \'/metric 1/\' | awk \'{ print $3 }\'');
                }

                return $result;
        }

And in settings-admin.php template file:

                        <div class="col col-12">
                                <?php p($l->t('Hostname:')); ?>
                                <span class="info"><?php p($_['networkinfo']['hostname']); ?></span>
                        </div>
                        <div class="col col-12">
                                <?php p($l->t('Gateways:')); ?>
                                <span class="info"><?php p($_['networkinfo']['gateway']); ?></span>
                        </div>

                        <div class="col col-12">
                                <?php p($l->t('Active gateway:')); ?>
                                <span class="info"><?php p($_['networkinfo']['current_gateway']); ?></span>
                        </div>

Of course, to update functions everywhere.

oleua avatar Jun 17 '25 12:06 oleua