nextcloud / nextcloud/serverinfo

Showing active gateway if more than one

Open
#842 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
130
Forks
64
Avg merge
1d 1h
Merged PRs (30d)
49

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the network information code in Linux.php and the settings-admin.php template, then trace where getNetworkInfo is used elsewhere. Preserve the existing gateway display while adding a separate active-gateway value for Linux, update the related functions and template output, and verify the dashboard shows both values correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
awk, linux, php
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.