diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | glances/main.py | 5 | ||||
-rw-r--r-- | glances/plugins/ip/__init__.py | 16 |
3 files changed, 21 insertions, 6 deletions
@@ -223,6 +223,9 @@ run-debug: ## Start Glances in debug console mode (also called standalone) run-local-conf: ## Start Glances in console mode with the system conf file ./venv/bin/python -m glances +run-local-conf-hide-public: ## Start Glances in console mode with the system conf file and hide public information + ./venv/bin/python -m glances --hide-public-info + run-min: ## Start minimal Glances in console mode (also called standalone) ./venv-min/bin/python -m glances -C ./conf/glances.conf @@ -256,6 +259,9 @@ run-webserver: ## Start Glances in Web server mode run-webserver-local-conf: ## Start Glances in Web server mode with the system conf file ./venv/bin/python -m glances -w +run-webserver-local-conf-hide-public: ## Start Glances in Web server mode with the system conf file and hide public info + ./venv/bin/python -m glances -w --hide-public-info + run-restapiserver: ## Start Glances in REST API server mode ./venv/bin/python -m glances -C ./conf/glances.conf -w --disable-webui diff --git a/glances/main.py b/glances/main.py index 5b425b52..767a3b79 100644 --- a/glances/main.py +++ b/glances/main.py @@ -537,9 +537,10 @@ Examples of use: help='disable unicode characters in the curses interface', ) parser.add_argument( - '--theme-white', + '--hide-public-info', + action='store_true', default=False, - help='(deprecated, no effect)', + help='hide public information (like public IP)', ) # Globals options parser.add_argument( diff --git a/glances/plugins/ip/__init__.py b/glances/plugins/ip/__init__.py index 449f01d4..9c079ef9 100644 --- a/glances/plugins/ip/__init__.py +++ b/glances/plugins/ip/__init__.py @@ -2,7 +2,7 @@ # # This file is part of Glances. # -# SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> +# SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # @@ -12,7 +12,7 @@ import threading from ujson import loads -from glances.globals import urlopen, queue, urlopen_auth +from glances.globals import queue, urlopen_auth from glances.logger import logger from glances.timer import Timer from glances.timer import getTimeSinceLastUpdate @@ -135,8 +135,12 @@ class PluginModel(GlancesPluginModel): except (KeyError, AttributeError) as e: logger.debug("Cannot grab public IP information ({})".format(e)) else: - stats['public_address'] = self.public_address - stats['public_info_human'] = self.public_info_for_human(self.public_info) + stats['public_address'] = ( + self.public_address if not self.args.hide_public_info else self.__hide_ip(self.public_address) + ) + stats['public_info_human'] = ( + self.public_info_for_human(self.public_info) + ) elif self.input_method == 'snmp': # Not implemented yet @@ -147,6 +151,10 @@ class PluginModel(GlancesPluginModel): return self.stats + def __hide_ip(self, ip): + """Hide last to digit of the given IP address""" + return '.'.join(ip.split('.')[0:2]) + '.*.*' + def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message |