def _correctly_configured(self): ''' :return: True if the plugin is correctly configured to run. ''' listen_address = self._listen_address listen_port = self._listen_port if listen_address and listen_port: with self._plugin_lock: # If we have an active instance then we're OK! if webserver.is_running(listen_address, listen_port): return True # Test if it's possible to bind the address s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.bind((listen_address, listen_port)) except socket.error: return False finally: s.close() del s return True
def _correctly_configured(self): ''' @return: True if the plugin is correctly configured to run. ''' listen_address = self._listen_address if not listen_address: if not self._use_w3af_site: return False else: with self._plugin_lock: # If we have an active instance then we're OK! if webserver.is_running(listen_address, self._listen_port): return True else: # Now test if it's possible to bind the address s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.bind((listen_address, self._listen_port)) except socket.error: return False finally: s.close() del s return True