Commit 6994d249 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(init_connection): Updated to initialize all fields. Several were forgotten.

(new_client): Set both connect_time and login_time.
(kill_client): Clear the remote_ip.
(handshake_ok): New function.
parent 25d4a681
/*
* $Id: internal-connections.c,v 0.58 2003/08/01 13:14:25 ceder Exp $
* $Id: internal-connections.c,v 0.59 2003/08/05 09:51:20 ceder Exp $
* Copyright (C) 1991-1994, 1996-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -79,12 +79,12 @@ init_connection(Connection *conn)
conn->next = NULL;
conn->pers_no = 0;
conn->person = NULL;
conn->session_start = timeval_ctor(0, 0);
conn->connect_time = timeval_ctor(0, 0);
conn->login_time = timeval_ctor(0, 0);
conn->cwc = 0;
conn->what_am_i_doing = EMPTY_STRING;
conn->ena_level = 0;
conn->username = EMPTY_STRING;
conn->hostname = EMPTY_STRING;
conn->ident_user = EMPTY_STRING;
conn->client_name = EMPTY_STRING;
conn->client_version = EMPTY_STRING;
......@@ -97,7 +97,11 @@ init_connection(Connection *conn)
conn->flags.reserved6 = FALSE;
conn->flags.reserved7 = FALSE;
conn->username_valid = FALSE;
conn->dns_done = FALSE;
conn->blocked_by_dns = FALSE;
conn->isc_session = NULL;
conn->remote_ip = EMPTY_STRING;
conn->peer = NULL;
conn->protocol = '\0';
conn->parse_pos = 0;
conn->fnc_parse_pos = 0;
......@@ -112,34 +116,30 @@ init_connection(Connection *conn)
conn->ref_no = 0;
conn->function = call_fnc_login_old;
conn->function_index = 0;
conn->num_list.length = 0;
conn->num_list.data = NULL;
conn->num0 = 0;
conn->num1 = 0;
conn->num2 = 0;
conn->num3 = 0;
conn->num4 = 0;
conn->c_string0 = EMPTY_STRING;
conn->c_string1 = EMPTY_STRING;
conn->string0 = EMPTY_STRING;
conn->misc_info_list.no_of_misc = 0;
conn->misc_info_list.misc = NULL;
conn->aux_item.data = EMPTY_STRING;
conn->dummy_aux_item.data = EMPTY_STRING;
conn->aux_item_list.items = NULL;
conn->aux_item_list.length = 0;
conn->aux_item.data = EMPTY_STRING;
conn->dummy_aux_item.data = EMPTY_STRING;
conn->c_local_text_no_p = NULL;
conn->read_range_list.ranges = NULL;
conn->read_range_list.length = 0;
conn->unparsed = EMPTY_STRING;
conn->first_to_parse = 0;
conn->more_to_parse = FALSE;
conn->kill_pending = FALSE;
conn->penalty = 0;
conn->penalty_generation = 0;
conn->active_time = current_time;
conn->session_no = 0;
conn->queue_next = NULL;
conn->queue_prev = NULL;
conn->on_queue = FALSE;
init_priv_bits(&conn->priv_bits);
init_conf_type(&conn->conf_type);
init_membership_type(&conn->membership_type);
init_struct_tm(&conn->time);
conn->info.pers_pres_conf = 0;
conn->info.conf_pres_conf = 0;
......@@ -151,8 +151,20 @@ init_connection(Connection *conn)
conn->info.aux_item_list.length = 0;
conn->info.aux_item_list.items = NULL;
conn->num_list.length = 0;
conn->num_list.data = NULL;
init_personal_flags(&conn->pers_flags);
conn->unparsed = EMPTY_STRING;
conn->first_to_parse = 0;
conn->more_to_parse = FALSE;
conn->kill_pending = FALSE;
conn->penalty = 0;
conn->penalty_generation = 0;
conn->queue_next = NULL;
conn->queue_prev = NULL;
conn->on_queue = FALSE;
conn->active_time = current_time;
conn->session_no = 0;
for (i = 0; i < ay_dummy_last; i++)
conn->want_async[i] = FALSE;
......@@ -161,11 +173,6 @@ init_connection(Connection *conn)
(size_t)i < sizeof(default_want_async)/sizeof(*default_want_async);
i++)
conn->want_async[default_want_async[i]] = TRUE;
init_priv_bits(&conn->priv_bits);
init_conf_type(&conn->conf_type);
init_struct_tm(&conn->time);
init_personal_flags(&conn->pers_flags);
}
static Connection *
......@@ -210,7 +217,8 @@ new_client(void)
c->active_time = current_time;
c->pers_no = 0;
c->person = NULL;
c->session_start = current_time;
c->connect_time = current_time;
c->login_time = current_time;
c->cwc = 0;
c->what_am_i_doing = EMPTY_STRING;
c->ena_level = 0;
......@@ -227,6 +235,8 @@ new_client(void)
c->flags.reserved6 = FALSE;
c->flags.reserved7 = FALSE;
c->username_valid = FALSE;
c->dns_done = FALSE;
c->blocked_by_dns = FALSE;
return c;
}
......@@ -271,10 +281,10 @@ kill_client(Connection *cp)
s_clear(&cp->unparsed);
s_clear(&cp->what_am_i_doing);
s_clear(&cp->username);
s_clear(&cp->hostname);
s_clear(&cp->ident_user);
s_clear(&cp->client_name);
s_clear(&cp->client_version);
s_clear(&cp->remote_ip);
if ( cp->isc_session != NULL )
{
......@@ -414,3 +424,13 @@ dump_allocated_connections(FILE *fp)
fprintf(fp, "\tConnection attempts: %lu\n",
(unsigned long)no_of_connection_attempts);
}
Bool
handshake_ok(struct connection *cptr,
enum ignored_conditions ignored)
{
if (!cptr->dns_done && !(ignored & ignore_dns))
return FALSE;
return cptr->username_valid == TRUE && cptr->dns_done == TRUE;
}
Supports Markdown
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