updates.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 14 Apr 2002 17:49:26 +0000 (17:49 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 14 Apr 2002 17:49:26 +0000 (17:49 +0000)
apps/silcd/command.c

index 184382eaf0b3c14a34332b375cee4fa8d9468390..ee6aa9ba50206fe2c6fdc693297f9a4cc2d5da5b 100644 (file)
@@ -4686,6 +4686,19 @@ SILC_TASK_CALLBACK(silc_server_command_detach_cb)
   silc_free(q);
 }
 
+SILC_TASK_CALLBACK(silc_server_command_detach_timeout)
+{
+  QuitInternal q = (QuitInternal)context;
+  SilcClientEntry client = (SilcClientEntry)q->sock;
+
+  SILC_LOG_DEBUG(("Start"));
+
+  if (client->mode & SILC_UMODE_DETACHED)
+    silc_server_free_client_data(q->server, NULL, client, TRUE,
+                                "Detach timeout");
+  silc_free(q);
+}
+
 /* Server side of DETACH command.  Detached the client from the network
    by closing the connection but preserving the session. */
 
@@ -4696,6 +4709,12 @@ SILC_SERVER_CMD_FUNC(detach)
   SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
   QuitInternal q;
 
+  if (server->config->detach_disabled) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_DETACH,
+                                         SILC_STATUS_ERR_UNKNOWN_COMMAND);
+    goto out;
+  }
+
   if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
     goto out;
 
@@ -4715,6 +4734,16 @@ SILC_SERVER_CMD_FUNC(detach)
   silc_schedule_task_add(server->schedule, 0, silc_server_command_detach_cb,
                         q, 0, 200000, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
 
+  if (server->config->detach_timeout) {
+    q = silc_calloc(1, sizeof(*q));
+    q->server = server;
+    q->sock = (void *)client;
+    silc_schedule_task_add(server->schedule, 0, 
+                          silc_server_command_detach_timeout,
+                          q, server->config->detach_timeout * 60,
+                          0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
+  }
+
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_DETACH,
                                        SILC_STATUS_OK);