From 0d73d8ab817ed0e0e1578d26fff98201b2cff961 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 31 Jan 2018 07:26:12 +0100 Subject: mpm: rpc_server: Declare local connection for *all* local IPs Before, it was possible to trick the RPC server in believing a connection was remote when the incoming connection was from a local IP address that was not 127.0.0.1. --- mpm/python/usrp_mpm/rpc_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mpm/python/usrp_mpm') diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index 4eed6b79b..062396082 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -26,6 +26,7 @@ from mprpc import RPCServer from usrp_mpm.mpmlog import get_main_logger from usrp_mpm.mpmutils import to_binary_str from usrp_mpm.sys_utils import watchdog +from usrp_mpm.sys_utils import net TIMEOUT_INTERVAL = 3.0 # Seconds before claim expires (default value) TOKEN_LEN = 16 # Length of the token string @@ -289,7 +290,7 @@ class MPMServer(RPCServer): self._state.claim_token.value, self.client_host ) - if self.client_host in ["127.0.0.1", "::1"]: + if self.client_host in net.get_local_ip_addrs(): self.periph_manager.set_connection_type("local") else: self.periph_manager.set_connection_type("remote") @@ -384,7 +385,7 @@ class MPMServer(RPCServer): This is as safe method which can be called without a claim on the device """ info = self.periph_manager.get_device_info() - if self.client_host in ["127.0.0.1", "::1"]: + if self.client_host in net.get_local_ip_addrs(): info["connection"] = "local" else: info["connection"] = "remote" -- cgit v1.2.3