client->mode = 0;
client->router = NULL;
client->connection = NULL;
+ client->data.created = silc_time();
+ silc_dlist_del(server->expired_clients, client);
silc_dlist_add(server->expired_clients, client);
} else {
silc_idlist_del_data(client);
client->mode = 0;
client->router = NULL;
client->connection = NULL;
+ client->data.created = silc_time();
+ silc_dlist_del(server->expired_clients, client);
silc_dlist_add(server->expired_clients, client);
} else {
silc_idlist_del_data(client);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_BAD_VERSION,
"You support too old protocol version");
+ silc_server_free_sock_user_data(server, sock, NULL);
return FALSE;
}
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_BAD_VERSION,
"You support too old software version");
+ silc_server_free_sock_user_data(server, sock, NULL);
return FALSE;
}
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_BAD_VERSION,
"Your software is not supported");
+ silc_server_free_sock_user_data(server, sock, NULL);
return FALSE;
}
}
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_RESOURCE_LIMIT,
"Server is full, try again later");
+ silc_server_free_sock_user_data(server, sock, NULL);
return FALSE;
}
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_RESOURCE_LIMIT,
"Too many connections from your host");
+ silc_server_free_sock_user_data(server, sock, NULL);
return FALSE;
}
if (remote_client->connection) {
/* Remove locally conneted client */
SilcPacketStream sock = remote_client->connection;
- silc_server_free_client_data(server, sock, remote_client, FALSE, NULL);
- silc_server_close_connection(server, sock);
+
+ if (sock)
+ silc_packet_stream_ref(sock);
+
+ silc_server_free_sock_user_data(server, sock, NULL);
+
+ if (sock) {
+ silc_packet_set_context(sock, NULL);
+ silc_server_close_connection(server, sock);
+ silc_packet_stream_unref(sock);
+ }
} else {
/* Update statistics */
server->stat.clients--;
}
/* Remove remote client */
+ silc_dlist_del(server->expired_clients, remote_client);
silc_idlist_del_data(remote_client);
if (!silc_idlist_del_client(server->global_list, remote_client)) {
/* Remove this client from watcher list if it is */
SilcUInt8 type, void *check)
{
unsigned char *tmp = NULL;
- SilcUInt32 len = 0, t;
+ SilcUInt32 len = 0;
SilcHashTableList htl;
SilcBuffer entry, idp = NULL, pkp = NULL;
SilcBool ret = FALSE;
+ void *t;
SILC_LOG_DEBUG(("Matching invite/ban"));
/* Compare the list */
silc_hash_table_list(list, &htl);
while (silc_hash_table_get(&htl, (void *)&t, (void *)&entry)) {
- if (type == t) {
+ if (type == SILC_PTR_TO_32(t)) {
if (type == 1) {
if (silc_string_match(entry->data, tmp)) {
ret = TRUE;
break;
}
- } else if (!memcmp(entry->data, tmp, len)) {
+ } else if (silc_buffer_len(entry) == len &&
+ !memcmp(entry->data, tmp, len)) {
ret = TRUE;
break;
}
{
unsigned char *tmp;
SilcUInt32 type, len;
+ void *ptype;
SilcBuffer tmp2;
SilcHashTableList htl;
/* Check if the string is added already */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 1 && silc_string_match(tmp2->data, tmp)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 1 &&
+ silc_string_match(tmp2->data, tmp)) {
tmp = NULL;
break;
}
/* Check if the public key is in the list already */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 2 && !memcmp(tmp2->data, tmp, len)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 2 && !memcmp(tmp2->data, tmp, len)) {
tmp = NULL;
break;
}
/* Check if the ID is in the list already */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 3 && !memcmp(tmp2->data, tmp, len)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 3 && !memcmp(tmp2->data, tmp, len)) {
tmp = NULL;
break;
}
/* Delete from the list */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 1 && silc_string_match(tmp2->data, tmp)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 1 &&
+ silc_string_match(tmp2->data, tmp)) {
silc_hash_table_del_by_context(list, (void *)1, tmp2);
break;
}
/* Delete from the invite list */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 2 && !memcmp(tmp2->data, tmp, len)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 2 && !memcmp(tmp2->data, tmp, len)) {
silc_hash_table_del_by_context(list, (void *)2, tmp2);
break;
}
/* Delete from the invite list */
silc_hash_table_list(list, &htl);
- while (silc_hash_table_get(&htl, (void *)&type, (void *)&tmp2)) {
- if (type == 3 && !memcmp(tmp2->data, tmp, len)) {
+ while (silc_hash_table_get(&htl, (void *)&ptype, (void *)&tmp2)) {
+ if (SILC_PTR_TO_32(ptype) == 3 && !memcmp(tmp2->data, tmp, len)) {
silc_hash_table_del_by_context(list, (void *)3, tmp2);
break;
}
silc_hash_table_list(channel->channel_pubkeys, &htl);
while (silc_hash_table_get(&htl, NULL, (void *)&pk)) {
pkp = silc_public_key_payload_encode(pk);
+ if (!pkp)
+ continue;
list = silc_argument_payload_encode_one(list, pkp->data,
silc_buffer_len(pkp),
announce ? 0x03 :