Fix - consistantly use sessiontimeout rather than session_length or session_timeout

Signed-off-by: Rob White <rob@blue-wave.net>
This commit is contained in:
Rob White
2025-06-09 09:18:02 +01:00
parent b2801d9f14
commit 3baaf97d6b
10 changed files with 41 additions and 41 deletions

View File

@@ -104,14 +104,14 @@ click_to_continue() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -121,7 +121,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -130,7 +130,7 @@ check_voucher() {
# "Punch" the voucher by setting the timestamp to now
voucher_expiration=$(($current_time + $voucher_time_limit * 60))
# Override session length according to voucher
session_length=$voucher_time_limit
sessiontimeout=$voucher_time_limit
sed -i -r "s/($voucher.*,)(0)/\1$current_time/" $voucher_roll
return 0
else
@@ -142,7 +142,7 @@ check_voucher() {
time_remaining=$(( ($voucher_expiration - $current_time) / 60 ))
#echo "Voucher is still valid - You have $time_remaining minutes left <br>"
# Override session length according to voucher
session_length=$time_remaining
sessiontimeout=$time_remaining
# Nothing to change in the roll
return 0
else
@@ -169,7 +169,7 @@ voucher_validation() {
#echo "Voucher is Valid, click Continue to finish login<br>"
# Refresh quotas with ones imported from the voucher roll.
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Set voucher used (useful if for accounting reasons you track who received which voucher)
userinfo="$title - $voucher"
@@ -185,7 +185,7 @@ voucher_validation() {
</big-red>
<hr>
</p>
This voucher is valid for $session_length minutes.
This voucher is valid for $sessiontimeout minutes.
<hr>
<p>
<italic-black>
@@ -451,14 +451,14 @@ display_terms() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -468,7 +468,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -415,14 +415,14 @@ display_terms() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -432,7 +432,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -470,14 +470,14 @@ display_terms() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -487,7 +487,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -428,14 +428,14 @@ display_terms() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -445,7 +445,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -487,14 +487,14 @@ display_terms() {
#########################################
# Set length of session in minutes (eg 24 hours is 1440 minutes - if set to 0 then defaults to global sessiontimeout value):
# eg for 100 mins:
# session_length="100"
# sessiontimeout="100"
#
# eg for 20 hours:
# session_length=$((20*60))
# sessiontimeout=$((20*60))
#
# eg for 20 hours and 30 minutes:
# session_length=$((20*60+30))
session_length="0"
# sessiontimeout=$((20*60+30))
sessiontimeout="0"
# Set Rate and Quota values for the client
# The session length, rate and quota values could be determined by this script, on a per client basis.
@@ -504,7 +504,7 @@ download_rate="0"
upload_quota="0"
download_quota="0"
quotas="$session_length $upload_rate $download_rate $upload_quota $download_quota"
quotas="$sessiontimeout $upload_rate $download_rate $upload_quota $download_quota"
# Define the list of Parameters we expect to be sent sent from openNDS ($ndsparamlist):
# Note you can add custom parameters to the config file and to read them you must also add them here.

View File

@@ -248,7 +248,7 @@ config_init(int argc, char **argv)
free(msg);
//
sscanf(set_option_str("sessiontimeout", DEFAULT_SESSION_TIMEOUT, debug_level), "%u", &config.session_timeout);
sscanf(set_option_str("sessiontimeout", DEFAULT_SESSIONTIMEOUT, debug_level), "%u", &config.sessiontimeout);
sscanf(set_option_str("preauthidletimeout", DEFAULT_PREAUTH_IDLE_TIMEOUT, debug_level), "%u", &config.preauth_idle_timeout);
sscanf(set_option_str("authidletimeout", DEFAULT_AUTH_IDLE_TIMEOUT, debug_level), "%u", &config.auth_idle_timeout);
sscanf(set_option_str("maxclients", DEFAULT_MAXCLIENTS, debug_level), "%u", &config.maxclients);

View File

@@ -72,7 +72,7 @@
#define DEFAULT_FASKEY ""
#define DEFAULT_BINAUTH "/usr/lib/opennds/binauth_log.sh"
#define DEFAULT_CHECKINTERVAL "15"
#define DEFAULT_SESSION_TIMEOUT "1440"
#define DEFAULT_SESSIONTIMEOUT "1440"
#define DEFAULT_PREAUTH_IDLE_TIMEOUT "30"
#define DEFAULT_AUTH_IDLE_TIMEOUT "120"
#define DEFAULT_REMOTES_REFRESH_INTERVAL "0"
@@ -234,7 +234,7 @@ typedef struct {
char *authdir; //@brief Notional relative dir for authentication URL
char *denydir; //@brief Notional relative dir for denial URL
char *preauthdir; //@brief Notional relative dir for preauth URL
int session_timeout; //@brief Minutes of the default session length
int sessiontimeout; //@brief Minutes of the default session length
int preauth_idle_timeout; //@brief Minutes a preauthenticated client will be kept in the system
int auth_idle_timeout; //@brief Minutes an authenticated client will be kept in the system
int remotes_refresh_interval; //@brief Minutes before remote files will be refreshed

View File

@@ -582,7 +582,7 @@ static int authenticate_client(struct MHD_Connection *connection,
{
s_config *config = config_get_config();
time_t now = time(NULL);
int seconds = 60 * config->session_timeout;
int seconds = 60 * config->sessiontimeout;
unsigned long long int uploadrate = 0;
unsigned long long int downloadrate = 0;
unsigned long long int uploadquota = 0;
@@ -666,12 +666,12 @@ static int authenticate_client(struct MHD_Connection *connection,
// override remaining client values that might have been set by binauth
if (seconds == 0) {
seconds = (60 * config->session_timeout);
seconds = (60 * config->sessiontimeout);
}
debug(LOG_DEBUG, "timeout seconds: %d", seconds);
if (seconds != (60 * config->session_timeout)) {
if (seconds != (60 * config->sessiontimeout)) {
client->session_end = (client->session_start + seconds);
}

View File

@@ -284,7 +284,7 @@ ndsctl_auth(FILE *fp, char *arg)
t_client *client;
unsigned id;
int rc = -1;
int seconds = 60 * config->session_timeout;
int seconds = 60 * config->sessiontimeout;
int custom_seconds;
int uploadrate = config->upload_rate;
int downloadrate = config->download_rate;