def salt_ip_verify_tool():
 salt_config = cherrypy.config.get('saltopts', None)
 if salt_config:
  cherrypy_conf = salt_config.get('rest_cherrypy', None)
  if cherrypy_conf:
   auth_ip_list = cherrypy_conf.get('authorized_ips', None)
   if auth_ip_list:
    logger.debug('Found IP list: {0}'.format(auth_ip_list))
    rem_ip = cherrypy.request.headers.get('Remote-Addr', None)
    logger.debug('Request from IP: {0}'.format(rem_ip))
    if (rem_ip not in auth_ip_list):
     logger.error('Blocked IP: {0}'.format(rem_ip))
     raise cherrypy.HTTPError(403, 'Bad IP')

def salt_ip_verify_tool ( ) : salt_config = cherrypy . config . get ( 'saltopts' , None ) if salt_config : cherrypy_conf = salt_config . get ( 'rest_cherrypy' , None ) if cherrypy_conf : auth_ip_list = cherrypy_conf . get ( 'authorized_ips' , None ) if auth_ip_list : logger . debug ( 'Found IP list: {0}' . format ( auth_ip_list ) ) rem_ip = cherrypy . request . headers . get ( 'Remote-Addr' , None ) logger . debug ( 'Request from IP: {0}' . format ( rem_ip ) ) if ( rem_ip not in auth_ip_list ) : logger . error ( 'Blocked IP: {0}' . format ( rem_ip ) ) raise cherrypy . HTTPError ( 403 , 'Bad IP' )
if there is a list of restricted ips .