Skip to content

Showing active gateway if more than oneΒ #842

@oleua

Description

@oleua

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions