def run_check_proxy_pool(**kwargs): """ check if proxy_pool is usable """ session = kwargs.get("session", None) # update via user config file session.read_config() # check tor tor_status = "Unknown" def check_tor(): # also check tor try: requests.get("http://ifconfig.me", timeout=10, proxies=dict(http='socks5://127.0.0.1:9050', https='socks5://127.0.0.1:9050')) except BaseException: return False return True def run_check(res): res['tor_status'] = "DISCONNECTED" if check_tor(): res['tor_status'] = "OK" if session is None: console.print_error("[-] info: session not exist") return # check proxy chain res['proxy_status'] = "DISCONNECTED" if session.test_proxy(): res['proxy_status'] = "OK" if session.proxy_pool_api == '': console.print_warning("[!] proxy_pool_api not configured") else: res = Manager().dict() proc = Process(target=run_check, args=(res,)) proc.start() console.print_status( "[*] please wait while checking proxy chain connectivity...", proc ) proc.join() tor_status = res['tor_status'] session.proxy_status = res['proxy_status'] colors.colored_print(f""" proxy ----- [*] proxy_pool API: {session.proxy_pool_api} [*] tor connectivity: {tor_status} [*] proxy chain connectivity: {session.proxy_status} """, colors.CYAN)
def call_update(self, silent=False): """ update mec record update result and act accordingly """ if self.auto_update: console.print_success("[-] auto-update is enabled") def update(res): ''' check updates from https://github.com/jm33-m0/mec ''' # current version old_ver = get_version() if old_ver == "": res['status'] = "[-] cannot get version" return os.chdir(MECROOT) # pull all tags try: check = "git pull --tags" out = subprocess.check_output( ["/bin/sh", "-c", check], stderr=subprocess.STDOUT, timeout=30) check_res = out.decode("utf-8") except KeyboardInterrupt: return except BaseException: res['status'] = f"[-] Failed to check for updates:\n{traceback.format_exc()}" return if "Already up to date" in check_res: res['status'] = "[+] already up to date" return # pull if needed pull = "git pull" try: out = subprocess.check_output( ["/bin/sh", "-c", pull], stderr=subprocess.STDOUT, timeout=30) pull_res = out.decode("utf-8") except KeyboardInterrupt: return except BaseException: res['status'] = f"[-] Failed to update mec: {traceback.format_exc()}" return if "error:" in pull_res: res['status'] = f"[-] Failed to update mec:\n{pull_res}, press enter to continue..." return res['status'] = f"[+] mec has been updated:\n{old_ver}->{get_version()}" return # update in child process if silent: res = {} update_job = Process(target=update, args=(res,)) update_job.start() return # check for result res = Manager().dict() update_job = Process(target=update, args=(res,)) update_job.start() # print status console.print_status( "[*] fetching updates from github...", update_job) update_job.join() # wait for result try: status = res['status'] except BaseException: status = "" if "[+]" in status: console.print_success(status) if "already up to date" in status: return if console.yes_no("[?] Exit mec (to apply updates) ?"): sys.exit(0) elif "[-]" in status: console.print_error(status)