/*
* $Id$
* $Log$
+ * Revision 1.10 2000/07/17 11:47:30 priikone
+ * Added command lagging support. Added idle counting support.
+ *
* Revision 1.9 2000/07/12 05:59:41 priikone
* Major rewrite of ID Cache system. Support added for the new
* ID cache system. Major rewrite of ID List stuff on server. All
{
SilcServerCommandContext ctx;
SilcServerCommand *cmd;
+
+ /* Check whether it is allowed for this connection to execute any
+ command. */
+ if (sock->type == SILC_SOCKET_TYPE_CLIENT) {
+ time_t curtime;
+ SilcClientEntry client = (SilcClientEntry)sock->user_data;
+
+ if (!client)
+ goto out;
+
+ /* Allow only one command executed in 2 seconds. */
+ curtime = time(NULL);
+ if (client->last_command && (curtime - client->last_command) < 2)
+ goto out;
+
+ /* Update access time */
+ client->last_command = curtime;
+ }
/* Allocate command context. This must be free'd by the
command routine receiving it. */
return;
}
+ out:
silc_buffer_free(packet->buffer);
}
/* XXX */
if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT) {
char nh[256], uh[256];
+ unsigned char idle[4];
SilcSocketConnection hsock;
memset(uh, 0, sizeof(uh));
len = hsock->hostname ? strlen(hsock->hostname) : strlen(hsock->ip);
strncat(uh, hsock->hostname ? hsock->hostname : hsock->ip, len);
+ SILC_PUT32_MSB((time(NULL) - entry->last_receive), idle);
+
/* XXX */
if (entry->userinfo)
packet =
silc_command_encode_reply_payload_va(SILC_COMMAND_WHOIS,
- SILC_STATUS_OK, 4,
+ SILC_STATUS_OK, 5,
2, id_string, SILC_ID_CLIENT_LEN,
3, nh, strlen(nh),
4, uh, strlen(uh),
5, entry->userinfo,
- strlen(entry->userinfo));
+ strlen(entry->userinfo),
+ 7, idle, 4);
else
packet =
silc_command_encode_reply_payload_va(SILC_COMMAND_WHOIS,
- SILC_STATUS_OK, 3,
+ SILC_STATUS_OK, 4,
2, id_string, SILC_ID_CLIENT_LEN,
3, nh, strlen(nh),
- 4, uh, strlen(uh));
+ 4, uh, strlen(uh),
+ 7, idle, 4);
} else {
/* XXX */
/*
* $Id$
* $Log$
+ * Revision 1.6 2000/07/17 11:47:30 priikone
+ * Added command lagging support. Added idle counting support.
+ *
* Revision 1.5 2000/07/12 05:59:41 priikone
* Major rewrite of ID Cache system. Support added for the new
* ID cache system. Major rewrite of ID List stuff on server. All
silc_pkcs_public_key_free(entry->public_key);
if (entry->hmac)
silc_hmac_free(entry->hmac);
- if (entry->hmac_key) {
- memset(entry->hmac_key, 0, entry->hmac_key_len);
- silc_free(entry->hmac_key);
- }
}
}
the server SILC will ever need. These are also the informations
that is broadcasted between servers and routers in the SILC network.
+ long last_receive
+
+ Time when data was received from the server last time.
+
SilcServerEntry router
This is a pointer back to the server list. This is the router server
it doesn't have a route this is NULL.
SilcCipher send_key
-
SilcCipher receive_key
+ Data sending and receiving keys.
+
void *connection
A pointer, usually, to the socket list for fast referencing to
char *server_name;
int server_type;
SilcServerID *id;
+ long last_receive;
/* TRUE when server is registered to server */
int registered;
Client's mode. Client maybe for example server operator or
router operator (SILC operator).
+ long last_receive
+
+ Time of last time data was received from the client. This is
+ result of normal time().
+
+ long last_command
+
+ Time of last time client executed command. We are strict and will
+ not allow any command to be exeucted more than once in about
+ 2 seconds. This is result of normal time().
+
+ int registered
+
+ Boolean value to indicate whether this client has registered itself
+ to the server. After KE and authentication protocols has been
+ successfully completed will client become registered.
+
SilcServerEntry router
This is a pointer to the server list. This is the router server whose
PKCS of the client. This maybe NULL.
SilcHmac hmac
- unsigned char *hmac_key
- unsigned int hmac_key_len
MAC key used to compute MAC's for packets.
SilcClientID *id;
int mode;
+ /* Time of last accesses of the client */
+ long last_receive;
+ long last_command;
+
/* TRUE when client is registered to server */
int registered;
SilcPKCS pkcs;
SilcHmac hmac;
SilcPublicKey public_key;
- unsigned char *hmac_key;
- unsigned int hmac_key_len;
/* Connection data */
void *connection;
/*
* $Id$
* $Log$
+ * Revision 1.10 2000/07/17 11:47:30 priikone
+ * Added command lagging support. Added idle counting support.
+ *
* Revision 1.9 2000/07/14 06:15:47 priikone
* Moved all the generic packet sending, encryption, reception,
* decryption and processing functions to library as they were
break;
}
- client->hmac_key = conn_data->hmac_key;
- client->hmac_key_len = conn_data->hmac_key_len;
-
/* Free the temporary connection data context from key exchange */
silc_free(conn_data);
if (!clnt)
break;
+ clnt->last_receive = time(NULL);
+
cipher = clnt->receive_key;
hmac = clnt->hmac;
break;
if (!srvr)
break;
+ srvr->last_receive = time(NULL);
+
cipher = srvr->receive_key;
hmac = srvr->hmac;
break;
#include "serverincludes.h"
-const char server_version[] = "10072000";
+const char server_version[] = "14072000";