MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / ProxyCommand

Class ProxyCommand

keepercommander/commands/utils.py:1660–1693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1658 api.send_keepalive(params)
1659
1660class ProxyCommand(Command):
1661 def get_parser(self): # type: () -> Optional[argparse.ArgumentParser]
1662 return proxy_parser
1663
1664 def is_authorised(self):
1665 return False
1666
1667 def execute(self, params, **kwargs): # type: (KeeperParams, any) -> any
1668 action = kwargs.get('action')
1669 if action == 'add':
1670 proxy_server = kwargs.get('address') # type: str
1671 if proxy_server:
1672 is_valid = False
1673 for prefix in {'socks5', 'http', 'https'}:
1674 if proxy_server.startswith(prefix):
1675 is_valid = True
1676 break
1677 if not is_valid:
1678 logging.warning('Proxy server "%s" does not appear to be a valid proxy URL', proxy_server)
1679 proxy_server = ''
1680 else:
1681 logging.warning('"add" action requires "proxy" parameter.')
1682
1683 if proxy_server:
1684 params.proxy = proxy_server
1685 else:
1686 return
1687 elif action == 'remove':
1688 params.proxy = None
1689
1690 if params.proxy:
1691 logging.info('Proxy server: %s', params.proxy)
1692 else:
1693 logging.info('Proxy is not configured.')
1694
1695
1696class LoginCommand(Command):

Callers 1

register_commandsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected