def req_scan_ip_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = "" if reqs['cmd'] == ['get_range']: data = ip_range.load_range_content() elif reqs['cmd'] == ['update']: #update ip_range if needed content = self.postvars['ip_range'][0] #check ip_range checksums, update if needed default_digest = hashlib.md5( ip_range.load_range_content(default=True)).hexdigest() old_digest = hashlib.md5(ip_range.load_range_content()).hexdigest() new_digest = hashlib.md5(content).hexdigest() if new_digest == default_digest: ip_range.remove_user_range() else: if old_digest != new_digest: ip_range.update_range_content(content) if old_digest != new_digest: ip_range.load_ip_range() #update auto_adjust_scan_ip and scan_ip_thread_num should_auto_adjust_scan_ip = int( self.postvars['auto_adjust_scan_ip_thread_num'][0]) thread_num_for_scan_ip = int( self.postvars['scan_ip_thread_num'][0]) use_ipv6 = self.postvars['use_ipv6'][0] if user_config.user_special.use_ipv6 != use_ipv6: xlog.debug("use_ipv6 change to %s", use_ipv6) user_config.user_special.use_ipv6 = use_ipv6 #update user config settings user_config.user_special.auto_adjust_scan_ip_thread_num = should_auto_adjust_scan_ip user_config.user_special.scan_ip_thread_num = thread_num_for_scan_ip user_config.save() config.load() #update google_ip settings google_ip.auto_adjust_scan_ip_thread_num = should_auto_adjust_scan_ip if google_ip.max_scan_ip_thread_num != thread_num_for_scan_ip: google_ip.adjust_scan_thread_num(thread_num_for_scan_ip) #reponse data = '{"res":"success"}' elif reqs['cmd'] == ['get_scan_ip_log']: data = scan_ip_log.get_log_content() mimetype = 'text/plain' self.send_response_nc(mimetype, data)
def req_scan_ip_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = "" if reqs['cmd'] == ['get_range']: data = ip_range.load_range_content() elif reqs['cmd'] == ['update']: #update ip_range if needed content = self.postvars['ip_range'][0] #check ip_range checksums, update if needed default_digest = hashlib.md5(ip_range.load_range_content(default=True)).hexdigest() old_digest = hashlib.md5(ip_range.load_range_content()).hexdigest() new_digest = hashlib.md5(content).hexdigest() if new_digest == default_digest: ip_range.remove_user_range() else: if old_digest != new_digest: ip_range.update_range_content(content) if old_digest != new_digest: ip_range.load_ip_range() #update auto_adjust_scan_ip and scan_ip_thread_num should_auto_adjust_scan_ip = int(self.postvars['auto_adjust_scan_ip_thread_num'][0]) thread_num_for_scan_ip = int(self.postvars['scan_ip_thread_num'][0]) use_ipv6 = self.postvars['use_ipv6'][0] if user_config.user_special.use_ipv6 != use_ipv6: xlog.debug("use_ipv6 change to %s", use_ipv6) user_config.user_special.use_ipv6 = use_ipv6 #update user config settings user_config.user_special.auto_adjust_scan_ip_thread_num = should_auto_adjust_scan_ip user_config.user_special.scan_ip_thread_num = thread_num_for_scan_ip user_config.save() config.load() #update google_ip settings google_ip.auto_adjust_scan_ip_thread_num = should_auto_adjust_scan_ip if google_ip.max_scan_ip_thread_num != thread_num_for_scan_ip: google_ip.adjust_scan_thread_num(thread_num_for_scan_ip) #reponse data='{"res":"success"}' elif reqs['cmd'] == ['get_scan_ip_log']: data = scan_ip_log.get_log_content() mimetype = 'text/plain' self.send_response_nc(mimetype, data)
def req_scan_ip_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = "" if reqs['cmd'] == ['get_range']: data = ip_range.load_range_content() elif reqs['cmd'] == ['set_range']: content = self.postvars['ip_range'][0] ip_range.update_range_content(content) ip_range.load_ip_range() data = '{"res":"success"}' elif reqs['cmd'] == ['set_auto_adjust_scan_ip_thread_num']: user_config.user_special.auto_adjust_scan_ip_thread_num = int(self.postvars['auto_adjust_scan_ip_thread_num'][0]) user_config.save() google_ip.auto_adjust_scan_ip_thread_num = user_config.user_special.auto_adjust_scan_ip_thread_num data = '{"res":"success"}' elif reqs['cmd'] == ['set_scan_thread_num']: user_config.user_special.scan_ip_thread_num = int(self.postvars['scan_ip_thread_num'][0]) user_config.save() scan_ip_thread_num = int(self.postvars['scan_ip_thread_num'][0]) google_ip.adjust_scan_thread_num(scan_ip_thread_num) data = '{"res":"success"}' elif reqs['cmd'] == ['get_scan_ip_log']: data = scan_ip_log.get_log_content() mimetype = 'text/plain' self.send_response(mimetype, data)
def req_scan_ip_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = "" if reqs['cmd'] == ['get_range']: data = ip_range.load_range_content() elif reqs['cmd'] == ['set_range']: content = self.postvars['ip_range'][0] ip_range.update_range_content(content) ip_range.load_ip_range() data = '{"res":"success"}' elif reqs['cmd'] == ['set_auto_adjust_scan_ip_thread_num']: user_config.user_special.auto_adjust_scan_ip_thread_num = int( self.postvars['auto_adjust_scan_ip_thread_num'][0]) user_config.save() google_ip.auto_adjust_scan_ip_thread_num = user_config.user_special.auto_adjust_scan_ip_thread_num data = '{"res":"success"}' elif reqs['cmd'] == ['set_scan_thread_num']: user_config.user_special.scan_ip_thread_num = int( self.postvars['scan_ip_thread_num'][0]) user_config.save() scan_ip_thread_num = int(self.postvars['scan_ip_thread_num'][0]) google_ip.adjust_scan_thread_num(scan_ip_thread_num) data = '{"res":"success"}' elif reqs['cmd'] == ['get_scan_ip_log']: data = scan_ip_log.get_log_content() mimetype = 'text/plain' self.send_response(mimetype, data)