mirror of
https://github.com/openNDS/openNDS.git
synced 2026-01-09 11:57:55 -05:00
Fix - remove redundant client_reset()
Signed-off-by: Rob White <rob@blue-wave.net>
This commit is contained in:
@@ -95,6 +95,7 @@ client_list_init(void)
|
||||
static t_client *
|
||||
_client_list_append(const char mac[], const char ip[])
|
||||
{
|
||||
char *hash;
|
||||
t_client *client, *prevclient;
|
||||
s_config *config;
|
||||
|
||||
@@ -116,9 +117,15 @@ _client_list_append(const char mac[], const char ip[])
|
||||
|
||||
client->mac = safe_strdup(mac);
|
||||
client->ip = safe_strdup(ip);
|
||||
client->counters.last_updated = time(NULL);
|
||||
|
||||
// Reset volatile fields and create new token
|
||||
client_reset(client);
|
||||
// Create new token and hid
|
||||
hash = safe_calloc(STATUS_BUF);
|
||||
client->token = safe_calloc(STATUS_BUF);
|
||||
safe_snprintf(client->token, STATUS_BUF, "%04hx%04hx", rand16(), rand16());
|
||||
hash_str(hash, STATUS_BUF, client->token);
|
||||
client->hid = safe_strdup(hash);
|
||||
free(hash);
|
||||
|
||||
// Trusted client does not trigger the splash page.
|
||||
if (is_trusted_mac(mac)) {
|
||||
@@ -146,59 +153,6 @@ _client_list_append(const char mac[], const char ip[])
|
||||
return client;
|
||||
}
|
||||
|
||||
/** @internal
|
||||
* Reset volatile fields
|
||||
*/
|
||||
void client_reset(t_client *client)
|
||||
{
|
||||
char *hash;
|
||||
char *msg;
|
||||
char *cidinfo;
|
||||
|
||||
debug(LOG_DEBUG, "Resetting client [%s]", client->mac);
|
||||
// Reset traffic counters
|
||||
client->counters.incoming = 0;
|
||||
client->counters.outgoing = 0;
|
||||
client->counters.last_updated = time(NULL);
|
||||
|
||||
// Reset session time
|
||||
client->session_start = 0;
|
||||
client->session_end = 0;
|
||||
|
||||
// Reset token and hid
|
||||
hash = safe_calloc(STATUS_BUF);
|
||||
client->token = safe_calloc(STATUS_BUF);
|
||||
safe_snprintf(client->token, STATUS_BUF, "%04hx%04hx", rand16(), rand16());
|
||||
hash_str(hash, STATUS_BUF, client->token);
|
||||
client->hid = safe_strdup(hash);
|
||||
free(hash);
|
||||
|
||||
// Reset custom, client_type and cpi_query
|
||||
client->custom = safe_calloc(MID_BUF);
|
||||
client->client_type = safe_calloc(STATUS_BUF);
|
||||
|
||||
if (!client->cpi_query) {
|
||||
client->cpi_query = safe_calloc(STATUS_BUF);
|
||||
}
|
||||
|
||||
//Reset cid and remove cidfile using rmcid
|
||||
if (client->cid) {
|
||||
|
||||
if (strlen(client->cid) > 0) {
|
||||
msg = safe_calloc(SMALL_BUF);
|
||||
cidinfo = safe_calloc(MID_BUF);
|
||||
safe_snprintf(cidinfo, MID_BUF, "cid=\"%s\"", client->cid);
|
||||
write_client_info(msg, SMALL_BUF, "rmcid", client->cid, cidinfo);
|
||||
free(msg);
|
||||
free(cidinfo);
|
||||
}
|
||||
}
|
||||
|
||||
free(client->cid);
|
||||
client->cid = safe_calloc(SMALL_BUF);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an IP address, add a client corresponding to that IP to client list.
|
||||
* Return a pointer to the new client list entry, or to an existing entry
|
||||
|
||||
@@ -110,9 +110,6 @@ t_client *client_list_find_by_mac(const char mac[]); /* needed by ndsctl_thread.
|
||||
/** @brief Finds a client by its token */
|
||||
t_client *client_list_find_by_token(const char token[]);
|
||||
|
||||
/** @brief Reset volatile client fields */
|
||||
void client_reset(t_client *client);
|
||||
|
||||
/** @brief Deletes a client from the client list */
|
||||
void client_list_delete(t_client *client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user