diff --git a/README.md b/README.md index 51668fc5..c0790bb7 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ The default configuration file comes with a sample configuration, making it easy use_ssl = False # enables connection via API-SSL servis no_ssl_certificate = False # enables API_SSL connect without router SSL certificate ssl_certificate_verify = False # turns SSL certificate verification on / off + plaintext_login = True # for legacy RouterOS versions below 6.43 use False installed_packages = True # Installed packages dhcp = True # DHCP general metrics diff --git a/mktxp/cli/config/config.py b/mktxp/cli/config/config.py index 98451d78..8fd88e4d 100755 --- a/mktxp/cli/config/config.py +++ b/mktxp/cli/config/config.py @@ -64,6 +64,7 @@ class MKTXPConfigKeys: SSL_KEY = 'use_ssl' NO_SSL_CERTIFICATE = 'no_ssl_certificate' SSL_CERTIFICATE_VERIFY = 'ssl_certificate_verify' + PLAINTEXT_LOGIN_KEY = 'plaintext_login' FE_PACKAGE_KEY = 'installed_packages' FE_DHCP_KEY = 'dhcp' @@ -145,8 +146,8 @@ class MKTXPConfigKeys: SSL_CERTIFICATE_VERIFY, FE_IPV6_FIREWALL_KEY, FE_IPV6_NEIGHBOR_KEY, FE_CONNECTION_STATS_KEY, FE_BGP_KEY} # Feature keys enabled by default - BOOLEAN_KEYS_YES = {FE_DHCP_KEY, FE_PACKAGE_KEY, FE_DHCP_LEASE_KEY, FE_DHCP_POOL_KEY, FE_IP_CONNECTIONS_KEY, FE_INTERFACE_KEY, FE_FIREWALL_KEY, - FE_MONITOR_KEY, FE_ROUTE_KEY, MKTXP_USE_COMMENTS_OVER_NAMES, + BOOLEAN_KEYS_YES = {PLAINTEXT_LOGIN_KEY, FE_DHCP_KEY, FE_PACKAGE_KEY, FE_DHCP_LEASE_KEY, FE_DHCP_POOL_KEY, FE_IP_CONNECTIONS_KEY, FE_INTERFACE_KEY, + FE_FIREWALL_KEY, FE_MONITOR_KEY, FE_ROUTE_KEY, MKTXP_USE_COMMENTS_OVER_NAMES, FE_WIRELESS_KEY, FE_WIRELESS_CLIENTS_KEY, FE_CAPSMAN_KEY, FE_CAPSMAN_CLIENTS_KEY, FE_POE_KEY, FE_NETWATCH_KEY, FE_PUBLIC_IP_KEY, FE_USER_KEY, FE_QUEUE_KEY} @@ -167,7 +168,7 @@ class MKTXPConfigKeys: class ConfigEntry: MKTXPConfigEntry = namedtuple('MKTXPConfigEntry', [MKTXPConfigKeys.ENABLED_KEY, MKTXPConfigKeys.HOST_KEY, MKTXPConfigKeys.PORT_KEY, MKTXPConfigKeys.USER_KEY, MKTXPConfigKeys.PASSWD_KEY, - MKTXPConfigKeys.SSL_KEY, MKTXPConfigKeys.NO_SSL_CERTIFICATE, MKTXPConfigKeys.SSL_CERTIFICATE_VERIFY, + MKTXPConfigKeys.SSL_KEY, MKTXPConfigKeys.NO_SSL_CERTIFICATE, MKTXPConfigKeys.SSL_CERTIFICATE_VERIFY, MKTXPConfigKeys.PLAINTEXT_LOGIN_KEY, MKTXPConfigKeys.FE_DHCP_KEY, MKTXPConfigKeys.FE_PACKAGE_KEY, MKTXPConfigKeys.FE_DHCP_LEASE_KEY, MKTXPConfigKeys.FE_DHCP_POOL_KEY, MKTXPConfigKeys.FE_INTERFACE_KEY, MKTXPConfigKeys.FE_FIREWALL_KEY, MKTXPConfigKeys.FE_MONITOR_KEY, MKTXPConfigKeys.FE_ROUTE_KEY, MKTXPConfigKeys.FE_WIRELESS_KEY, MKTXPConfigKeys.FE_WIRELESS_CLIENTS_KEY, MKTXPConfigKeys.FE_IP_CONNECTIONS_KEY, MKTXPConfigKeys.FE_CONNECTION_STATS_KEY, MKTXPConfigKeys.FE_CAPSMAN_KEY, MKTXPConfigKeys.FE_CAPSMAN_CLIENTS_KEY, MKTXPConfigKeys.FE_POE_KEY, diff --git a/mktxp/cli/config/mktxp.conf b/mktxp/cli/config/mktxp.conf index f27984eb..841a1634 100644 --- a/mktxp/cli/config/mktxp.conf +++ b/mktxp/cli/config/mktxp.conf @@ -28,6 +28,7 @@ use_ssl = False # enables connection via API-SSL servis no_ssl_certificate = False # enables API_SSL connect without router SSL certificate ssl_certificate_verify = False # turns SSL certificate verification on / off + plaintext_login = True # for legacy RouterOS versions below 6.43 use False installed_packages = True # Installed packages dhcp = True # DHCP general metrics diff --git a/mktxp/flow/router_connection.py b/mktxp/flow/router_connection.py index 5d63ae3d..4706eb4b 100644 --- a/mktxp/flow/router_connection.py +++ b/mktxp/flow/router_connection.py @@ -78,12 +78,8 @@ def connect(self): return try: print(f'Connecting to router {self.router_name}@{self.config_entry.hostname}') - try: - self.api = self.connection.get_api() - except: - self.connection.plaintext_login = False - self.api = self.connection.get_api() - + self.connection.plaintext_login = self.config_entry.plaintext_login + self.api = self.connection.get_api() self._set_connect_state(success = True, connect_time = connect_time) except (socket.error, socket.timeout, Exception) as exc: self._set_connect_state(success = False, connect_time = connect_time, exc = exc)