From cde77fa279926dcfa546f3813ec84914adeaf987 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 30 Apr 2021 03:54:08 +0500 Subject: [PATCH] bug fix: add timeout to curl --- cyberpanel.sh | 2 +- install/installLog.py | 2 +- plogical/CyberPanelUpgrade.py | 7 +++++-- plogical/upgrade.py | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 135e07ab3..ae51530c5 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -104,7 +104,7 @@ echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug.log Debug_Log2() { Check_Server_IP "$@" >/dev/null 2>&1 echo -e "\n${1}" >> /var/log/installLogs.txt -curl -d '{"ipAddress": "'"$Server_IP"'", "InstallCyberPanelStatus": "'"$1"'"}' -H "Content-Type: application/json" -X POST https://cloud.cyberpanel.net/servers/RecvData >/dev/null 2>&1 +curl --max-time 20 -d '{"ipAddress": "'"$Server_IP"'", "InstallCyberPanelStatus": "'"$1"'"}' -H "Content-Type: application/json" -X POST https://cloud.cyberpanel.net/servers/RecvData >/dev/null 2>&1 } Branch_Check() { diff --git a/install/installLog.py b/install/installLog.py index fd950272d..58a3ed2c7 100755 --- a/install/installLog.py +++ b/install/installLog.py @@ -30,6 +30,6 @@ class InstallLog: try: finalData = json.dumps({'ipAddress': InstallLog.ServerIP, "InstallCyberPanelStatus": message}) - requests.post(InstallLog.LogURL, data=finalData) + requests.post(InstallLog.LogURL, data=finalData, timeout=10) except: pass diff --git a/plogical/CyberPanelUpgrade.py b/plogical/CyberPanelUpgrade.py index 0ae9c793e..8055f46ea 100644 --- a/plogical/CyberPanelUpgrade.py +++ b/plogical/CyberPanelUpgrade.py @@ -23,8 +23,11 @@ class UpgradeCyberPanel: def PostStatus(self, message): finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message}) - resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False) - print (resp.text) + + try: + resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False, timeout=10) + except: + pass def RestoreOldCP(self): diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 29665a48d..5e4425776 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -2596,6 +2596,7 @@ vmail Upgrade.stdOut("Upgrade Completed.") def main(): + parser = argparse.ArgumentParser(description='CyberPanel Installer') parser.add_argument('branch', help='Install from branch name.')