ZP-739 Enforce the maximum value for PING_HIGHER_BOUND_LIFETIME and...

ZP-739 Enforce the maximum value for PING_HIGHER_BOUND_LIFETIME and PING_LOWER_BOUND_LIFETIME to 3540. Released under the Affero GNU General Public License (AGPL) version 3.
parent d6f7ca08
...@@ -225,10 +225,12 @@ ...@@ -225,10 +225,12 @@
// might not be able to send a higher value than the one specificied here and thus // might not be able to send a higher value than the one specificied here and thus
// unable to start a push connection. // unable to start a push connection.
// If set to false, there will be no lower bound to the ping lifetime. // If set to false, there will be no lower bound to the ping lifetime.
// The minimum accepted value is 1 second. The maximum accepted value is 3540 seconds (59 minutes).
define('PING_LOWER_BOUND_LIFETIME', false); define('PING_LOWER_BOUND_LIFETIME', false);
// The maximum accepted time in second that a ping command should last. // The maximum accepted time in second that a ping command should last.
// If set to false, there will be no higher bound to the ping lifetime. // If set to false, there will be no higher bound to the ping lifetime.
// The minimum accepted value is 1 second. The maximum accepted value is 3540 seconds (59 minutes).
define('PING_HIGHER_BOUND_LIFETIME', false); define('PING_HIGHER_BOUND_LIFETIME', false);
/********************************************************************************** /**********************************************************************************
......
...@@ -286,14 +286,14 @@ class ZPush { ...@@ -286,14 +286,14 @@ class ZPush {
if (!defined('PING_LOWER_BOUND_LIFETIME')) { if (!defined('PING_LOWER_BOUND_LIFETIME')) {
define('PING_LOWER_BOUND_LIFETIME', false); define('PING_LOWER_BOUND_LIFETIME', false);
} }
elseif(PING_LOWER_BOUND_LIFETIME !== false && (!is_int(PING_LOWER_BOUND_LIFETIME) || PING_LOWER_BOUND_LIFETIME < 1)){ elseif(PING_LOWER_BOUND_LIFETIME !== false && (!is_int(PING_LOWER_BOUND_LIFETIME) || PING_LOWER_BOUND_LIFETIME < 1 || PING_LOWER_BOUND_LIFETIME > 3540)){
throw new FatalMisconfigurationException("The PING_LOWER_BOUND_LIFETIME value must be 'false' or a number higher than 0."); throw new FatalMisconfigurationException("The PING_LOWER_BOUND_LIFETIME value must be 'false' or a number between 1 and 3540 inclusively.");
} }
if (!defined('PING_HIGHER_BOUND_LIFETIME')) { if (!defined('PING_HIGHER_BOUND_LIFETIME')) {
define('PING_HIGHER_BOUND_LIFETIME', false); define('PING_HIGHER_BOUND_LIFETIME', false);
} }
elseif(PING_HIGHER_BOUND_LIFETIME !== false && (!is_int(PING_HIGHER_BOUND_LIFETIME) || PING_HIGHER_BOUND_LIFETIME < 1)){ elseif(PING_HIGHER_BOUND_LIFETIME !== false && (!is_int(PING_HIGHER_BOUND_LIFETIME) || PING_HIGHER_BOUND_LIFETIME < 1 || PING_HIGHER_BOUND_LIFETIME > 3540)){
throw new FatalMisconfigurationException("The PING_HIGHER_BOUND_LIFETIME value must be 'false' or a number higher than 0."); throw new FatalMisconfigurationException("The PING_HIGHER_BOUND_LIFETIME value must be 'false' or a number between 1 and 3540 inclusively.");
} }
if(PING_HIGHER_BOUND_LIFETIME !== false && PING_LOWER_BOUND_LIFETIME !== false && PING_HIGHER_BOUND_LIFETIME < PING_LOWER_BOUND_LIFETIME){ if(PING_HIGHER_BOUND_LIFETIME !== false && PING_LOWER_BOUND_LIFETIME !== false && PING_HIGHER_BOUND_LIFETIME < PING_LOWER_BOUND_LIFETIME){
throw new FatalMisconfigurationException("The PING_HIGHER_BOUND_LIFETIME value must be greater or equal to PING_LOWER_BOUND_LIFETIME."); throw new FatalMisconfigurationException("The PING_HIGHER_BOUND_LIFETIME value must be greater or equal to PING_LOWER_BOUND_LIFETIME.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment