File transfer fixes.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 14 Feb 2007 14:59:33 +0000 (14:59 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 14 Feb 2007 14:59:33 +0000 (14:59 +0000)
apps/irssi/docs/help/in/file.in
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/fe-common/silc/module-formats.h
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-servers.c

index cb6ee86fa051e6ff3725844f78b6eb12d1cb50e0..61a719a45e2a697cdf38e392ca92a0a3a9fc72d3 100644 (file)
@@ -22,7 +22,7 @@ Commands:
 
       If the <local IP> is provided then the key exchange
       protocol listener will be bound to that address.  If
-      <local port> is defined it is bound to that port. 
+      <local port> is defined it is bound to that port.
       If they are not defined then the local IP address
       of your machine is used to bind the listener.
 
@@ -31,6 +31,17 @@ Commands:
       the point of connect.  This is usefull when the sender
       is behind NAT device.
 
+      If the <local IP> and <local port> are ommitted and the
+      -no-listener option is not given, the boolean variable
+      use_auto_addr will be examined.  If it is set the value
+      of auto_bind_ip will be used as the IP address to bound
+      the listener, the value of auto_public_ip will be the IP
+      address sent to the remote client, and the auto_bind_port
+      will be the port value to be bound to and sent to the remote
+      client.  If auto_public_ip is unset, but auto_bind_ip is
+      set, SILC client will send the auto_bind_ip variable's
+      value to the remote client.
+
     ACCEPT  [<nickname>]
 
       Accepts the file transfer request and starts the file
@@ -42,4 +53,3 @@ Commands:
       Closes the file transfer session, or rejects
       file transfer request.  If this command is given
       during the file transfer process it will be cancelled.
-
index 2171d607e448498cbc977aceeef53a96d75026f6..291f001b1d57a5f3417bdb98693ae9a455742e84 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2006 Pekka Riikonen
+  Copyright (C) 2001 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -108,6 +108,9 @@ FORMAT_REC fecommon_silc_formats[] = {
        { "notice_private_signed", "{notice {flag_signed}$0{pvtnotice_host $1}}$2", 3, { 0, 0, 0 } },
        { "notice_private_unknown", "{notice {flag_unknown}$0{pvtnotice_host $1}}$2", 3, { 0, 0, 0 } },
        { "notice_private_failed", "{notice {flag_failed}$0{pvtnotice_host $1}}$2", 3, { 0, 0, 0 } },
+       { "many", "There are now $0 {channick_hilight $1}'s on this channel", 2, { 0, 0 } },
+       { "user_appears", "{channick_hilight $0} will appear as {channick_hilight $1}", 2, { 0, 0 } },
+
 
        /* WHOIS, WHOWAS and USERS (alias WHO) messages */
        { NULL, "Who Queries", 0 },
index bb5666ad0337222eb6189a05a4218699ea52c488..b7a0fc93e4a863fef1b3f8e17d783e38add0f7ba 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2003 Pekka Riikonen
+  Copyright (C) 2001 - 2003, 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -105,7 +105,8 @@ enum {
   SILCTXT_NOTICE_PRIVATE_SIGNED,
   SILCTXT_NOTICE_PRIVATE_UNKNOWN,
   SILCTXT_NOTICE_PRIVATE_FAILED,
-
+  SILCTXT_CHANNEL_MANY_NICKS,
+  SILCTXT_CHANNEL_USER_APPEARS,
 
   SILCTXT_FILL_2,
 
@@ -236,7 +237,7 @@ enum {
   SILCTXT_ATTR_SAVED,
 
   SILCTXT_FILL_7,
-  
+
   SILCTXT_LISTKEY_PUB_FILE,
   SILCTXT_LISTKEY_PUB_ALG,
   SILCTXT_LISTKEY_PUB_VER,
index 854334203fe91b4d1ccaff3e50b26b7542a5eddd..5f1ff5d0f98f9fa9c6f66a008b638a36c46d27bc 100644 (file)
@@ -553,7 +553,7 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
 
   server = conn == NULL ? NULL : conn->context;
   memset(userhost, 0, sizeof(userhost));
-  if (sender->username)
+  if (sender->username[0])
     snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
             sender->username, sender->hostname);
 
@@ -568,11 +568,11 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
 
   if (flags & SILC_MESSAGE_FLAG_DATA) {
     silc_emit_mime_sig(server,
-               sender->nickname ?
+               sender->nickname[0] ?
                (WI_ITEM_REC *)query_find(SERVER(server), sender->nickname) :
                NULL,
                message, message_len,
-               sender->nickname ? sender->nickname : "[<unknown>]",
+               sender->nickname[0] ? sender->nickname : "[<unknown>]",
                flags & SILC_MESSAGE_FLAG_SIGNED ? verified : -1);
     message = NULL;
   }
@@ -593,24 +593,24 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
                        cp, message_len);
       if (flags & SILC_MESSAGE_FLAG_SIGNED)
         signal_emit("message silc signed_private_action", 6, server, cp,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL,
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL,
                    NULL, verified);
       else
         signal_emit("message silc private_action", 5, server, cp,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL, NULL);
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL, NULL);
       silc_free(dm);
     } else {
       if (flags & SILC_MESSAGE_FLAG_SIGNED)
         signal_emit("message silc signed_private_action", 6, server, message,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL,
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL,
                    NULL, verified);
       else
         signal_emit("message silc private_action", 5, server, message,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL, NULL);
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL, NULL);
     }
   else if (flags & SILC_MESSAGE_FLAG_NOTICE)
     if(flags & SILC_MESSAGE_FLAG_UTF8 && !silc_term_utf8()) {
@@ -625,24 +625,24 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
                        cp, message_len);
       if (flags & SILC_MESSAGE_FLAG_SIGNED)
         signal_emit("message silc signed_private_notice", 6, server, cp,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL,
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL,
                    NULL, verified);
       else
         signal_emit("message silc private_notice", 5, server, cp,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL, NULL);
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL, NULL);
       silc_free(dm);
     } else {
       if (flags & SILC_MESSAGE_FLAG_SIGNED)
         signal_emit("message silc signed_private_notice", 6, server, message,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL,
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL,
                    NULL, verified);
       else
         signal_emit("message silc private_notice", 5, server, message,
-                   sender->nickname ? sender->nickname : "[<unknown>]",
-                   sender->username ? userhost : NULL, NULL);
+                   sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                   sender->username[0] ? userhost : NULL, NULL);
     }
   else {
     if (flags & SILC_MESSAGE_FLAG_UTF8 && !silc_term_utf8()) {
@@ -659,24 +659,24 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
                     cp, message_len);
       if (flags & SILC_MESSAGE_FLAG_SIGNED)
         signal_emit("message signed_private", 5, server, cp,
-                 sender->nickname ? sender->nickname : "[<unknown>]",
-                 sender->username ? userhost : NULL, verified);
+                 sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                 sender->username[0] ? userhost : NULL, verified);
       else
         signal_emit("message private", 4, server, cp,
-                 sender->nickname ? sender->nickname : "[<unknown>]",
-                 sender->username ? userhost : NULL);
+                 sender->nickname[0] ? sender->nickname : "[<unknown>]",
+                 sender->username[0] ? userhost : NULL);
       silc_free(dm);
       return;
     }
 
     if (flags & SILC_MESSAGE_FLAG_SIGNED)
       signal_emit("message signed_private", 5, server, message,
-              sender->nickname ? sender->nickname : "[<unknown>]",
-              sender->username ? userhost : NULL, verified);
+              sender->nickname[0] ? sender->nickname : "[<unknown>]",
+              sender->username[0] ? userhost : NULL, verified);
     else
       signal_emit("message private", 4, server, message,
-              sender->nickname ? sender->nickname : "[<unknown>]",
-              sender->username ? userhost : NULL);
+              sender->nickname[0] ? sender->nickname : "[<unknown>]",
+              sender->username[0] ? userhost : NULL);
   }
 }
 
@@ -704,7 +704,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
   char buf[512];
   char *name, *tmp, *cipher, *hmac;
   GSList *list1, *list_tmp;
-  SilcDList chpks;
+  SilcDList chpks, clients;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -761,12 +761,32 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
     }
 
     memset(buf, 0, sizeof(buf));
-    if (client_entry->username)
-    snprintf(buf, sizeof(buf) - 1, "%s@%s",
-            client_entry->username, client_entry->hostname);
+    if (client_entry->username[0])
+      snprintf(buf, sizeof(buf) - 1, "%s@%s",
+              client_entry->username, client_entry->hostname);
     signal_emit("message join", 4, server, channel->channel_name,
                client_entry->nickname,
                client_entry->username == NULL ? "" : buf);
+
+    /* If there are multiple same nicknames on channel now, tell it to user. */
+    if (client_entry != server->conn->local_entry) {
+      char nick[128 + 1], tmp[32];
+
+      silc_parse_userfqdn(client_entry->nickname, nick, sizeof(nick), NULL, 0);
+      clients = silc_client_get_clients_local(client, conn, nick, NULL);
+      if (!clients || silc_dlist_count(clients) < 2) {
+       silc_client_list_free(client, conn, clients);
+       break;
+      }
+      silc_snprintf(tmp, sizeof(tmp), "%d", silc_dlist_count(clients));
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_MANY_NICKS,
+                        tmp, nick);
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_USER_APPEARS,
+                        buf, client_entry->nickname);
+      silc_client_list_free(client, conn, clients);
+    }
     break;
 
   case SILC_NOTIFY_TYPE_LEAVE:
@@ -784,7 +804,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
       snprintf(buf, sizeof(buf) - 1, "%s@%s",
               client_entry->username, client_entry->hostname);
     signal_emit("message part", 5, server, channel->channel_name,
-               client_entry->nickname,  client_entry->username ?
+               client_entry->nickname,  client_entry->username[0] ?
                buf : "", client_entry->nickname);
 
     chanrec = silc_channel_find_entry(server, channel);
@@ -805,20 +825,18 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
     client_entry = va_arg(va, SilcClientEntry);
     tmp = va_arg(va, char *);
 
-#if 0
     silc_server_free_ftp(server, client_entry);
-#endif
 
     /* Print only if we have the nickname.  If this cliente has just quit
        when we were only resolving it, it is possible we don't have the
        nickname. */
-    if (client_entry->nickname) {
+    if (client_entry->nickname[0]) {
       memset(buf, 0, sizeof(buf));
       if (client_entry->username)
         snprintf(buf, sizeof(buf) - 1, "%s@%s",
                 client_entry->username, client_entry->hostname);
       signal_emit("message quit", 4, server, client_entry->nickname,
-                 client_entry->username ? buf : "",
+                 client_entry->username[0] ? buf : "",
                  tmp ? tmp : "");
     }
 
@@ -1174,9 +1192,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
                      "server signoff");
        }
 
-#if 0
        silc_server_free_ftp(server, client_entry);
-#endif
 
        list1 = nicklist_get_same_unique(SERVER(server), client_entry);
        for (list_tmp = list1; list_tmp != NULL; list_tmp =
@@ -1685,7 +1701,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
 
       /* Get user list */
       while (silc_hash_table_get(user_list, NULL, (void *)&chu)) {
-       if (!chu->client->nickname)
+       if (!chu->client->nickname[0])
          continue;
        if (chu->mode & SILC_CHANNEL_UMODE_CHANFO)
          founder = chu->client;
@@ -1904,7 +1920,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        SilcClientEntry e = chu->client;
        char stat[5], *mode;
 
-       if (!e->nickname)
+       if (!e->nickname[0])
          continue;
 
        memset(stat, 0, sizeof(stat));
@@ -1931,8 +1947,8 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        printformat_module("fe-common/silc", server, channel->channel_name,
                           MSGLEVEL_CRAP, SILCTXT_USERS,
                           e->nickname, stat,
-                          e->username ? e->username : "",
-                          e->hostname ? e->hostname : "",
+                          e->username[0] ? e->username : "",
+                          e->hostname[0] ? e->hostname : "",
                           e->realname ? e->realname : "");
        if (mode)
          silc_free(mode);
index 11f1032e06fee5a891aa0dbf5ce04dda627fbf7c..38ea4f487addd8d4aa504621f8ab37caf35cbe1c 100644 (file)
@@ -377,6 +377,7 @@ static void silc_connect_cb(SilcClient client,
     silc_free(file);
 
     server->connection_lost = TRUE;
+    server->conn = NULL;
     if (server->conn)
       server->conn->context = NULL;
     if (!server->disconnected)
@@ -558,7 +559,6 @@ char *silc_server_get_channels(SILC_SERVER_REC *server)
 /* SYNTAX: WHOIS [<nickname>[@<hostname>]] [-details] [-pubkey <pubkeyfile>] [<count>] */
 /* SYNTAX: WHOWAS <nickname>[@<hostname>] [<count>] */
 /* SYNTAX: CLOSE <server> [<port>] */
-/* SYNTAX: SHUTDOWN */
 /* SYNTAX: MOTD [<server>] */
 /* SYNTAX: LIST [<channel>] */
 /* SYNTAX: ME <message> */
@@ -569,7 +569,6 @@ char *silc_server_get_channels(SILC_SERVER_REC *server)
 /* SYNTAX: NOTICE [-sign] [-channel] <target> <message> */
 /* SYNTAX: PART [<channel>] */
 /* SYNTAX: PING */
-/* SYNTAX: SCONNECT <server> [<port>] */
 /* SYNTAX: USERS <channel> */
 /* SYNTAX: FILE SEND <filepath> <nickname> [<local IP> [<local port>]] [-no-listener]*/
 /* SYNTAX: FILE ACCEPT [<nickname>] */
@@ -618,21 +617,6 @@ static void command_self(const char *data, SILC_SERVER_REC *server,
   signal_stop();
 }
 
-/* SCONNECT command.  Calls actually SILC's CONNECT command since Irssi
-   has CONNECT command for other purposes. */
-
-static void command_sconnect(const char *data, SILC_SERVER_REC *server)
-{
-  CMD_SILC_SERVER(server);
-  if (!IS_SILC_SERVER(server) || !server->connected) {
-    printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Not connected to server");
-    return;
-  }
-
-  silc_command_exec(server, "CONNECT", data);
-  signal_stop();
-}
-
 /* SMSG command, to send digitally signed messages */
 
 static void command_smsg(const char *data, SILC_SERVER_REC *server,
@@ -713,7 +697,6 @@ out:
   cmd_params_free(free_arg);
 }
 
-#if 0
 /* FILE command */
 
 SILC_TASK_CALLBACK(silc_client_file_close_later)
@@ -759,7 +742,8 @@ static void silc_client_file_monitor(SilcClient client,
   if (ftp == SILC_LIST_END)
     return;
 
-  if (status == SILC_CLIENT_FILE_MONITOR_ERROR) {
+  if (status == SILC_CLIENT_FILE_MONITOR_ERROR ||
+      status == SILC_CLIENT_FILE_MONITOR_DISCONNECT) {
     if (error == SILC_CLIENT_FILE_NO_SUCH_FILE)
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_FILE_ERROR_NO_SUCH_FILE,
@@ -772,9 +756,9 @@ static void silc_client_file_monitor(SilcClient client,
     else
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_FILE_ERROR, client_entry->nickname);
-    silc_schedule_task_add(silc_client->schedule, 0,
-                          silc_client_file_close_later, ftp,
-                          1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+    silc_schedule_task_add_timeout(silc_client->schedule,
+                                  silc_client_file_close_later, ftp,
+                                  1, 0);
     silc_dlist_del(server->ftp_sessions, ftp);
     if (ftp == server->current_session) {
       server->current_session = NULL;
@@ -812,9 +796,9 @@ static void silc_client_file_monitor(SilcClient client,
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_FILE_TRANSMITTED, filepath, fsize,
                         client_entry->nickname, ftp->kps);
-      silc_schedule_task_add(silc_client->schedule, 0,
-                            silc_client_file_close_later, ftp,
-                            1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+      silc_schedule_task_add_timeout(silc_client->schedule,
+                                    silc_client_file_close_later, ftp,
+                                    1, 0);
       silc_dlist_del(server->ftp_sessions, ftp);
       if (ftp == server->current_session) {
        server->current_session = NULL;
@@ -837,9 +821,9 @@ static void silc_client_file_monitor(SilcClient client,
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_FILE_RECEIVED, filepath, fsize,
                         client_entry->nickname, ftp->kps);
-      silc_schedule_task_add(silc_client->schedule, 0,
-                            silc_client_file_close_later, ftp,
-                            1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+      silc_schedule_task_add_timeout(silc_client->schedule,
+                                    silc_client_file_close_later, ftp,
+                                    1, 0);
       silc_dlist_del(server->ftp_sessions, ftp);
       if (ftp == server->current_session) {
        server->current_session = NULL;
@@ -860,8 +844,8 @@ typedef struct {
 
 static void silc_client_command_file_get_clients(SilcClient client,
                                                 SilcClientConnection conn,
-                                                SilcClientEntry *clients,
-                                                SilcUInt32 clients_count,
+                                                SilcStatus status,
+                                                SilcDList clients,
                                                 void *context)
 {
   FileGetClients internal = (FileGetClients)context;
@@ -887,10 +871,10 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                         WI_ITEM_REC *item)
 {
   SilcClientConnection conn;
-  SilcClientEntry *entrys, client_entry;
+  SilcClientEntry client_entry;
+  SilcDList entries;
   SilcClientFileError ret;
-  SilcUInt32 entry_count;
-  char *nickname = NULL, *tmp;
+  char nickname[128 + 1], *tmp;
   unsigned char **argv;
   SilcUInt32 argc;
   SilcUInt32 *argv_lens, *argv_types;
@@ -900,6 +884,7 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
   SilcUInt32 local_port = 0;
   SilcUInt32 session_id;
   bool do_not_bind = FALSE;
+  SilcClientConnectionParams params;
 
   CMD_SILC_SERVER(server);
   if (!server || !IS_SILC_SERVER(server) || !server->connected)
@@ -933,16 +918,16 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
       cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
 
     /* Parse the typed nickname. */
-    if (!silc_parse_userfqdn(argv[3], &nickname, NULL)) {
+    if (!silc_parse_userfqdn(argv[3], nickname, sizeof(nickname), NULL, 0)) {
       printformat_module("fe-common/silc", server, NULL,
                         MSGLEVEL_CRAP, SILCTXT_BAD_NICK, argv[3]);
       goto out;
     }
 
     /* Find client entry */
-    entrys = silc_client_get_clients_local(silc_client, conn, nickname,
-                                          argv[3], &entry_count);
-    if (!entrys) {
+    entries = silc_client_get_clients_local(silc_client, conn, nickname,
+                                           argv[3]);
+    if (!entries) {
       FileGetClients inter = silc_calloc(1, sizeof(*inter));
       inter->server = server;
       inter->data = strdup(data);
@@ -952,8 +937,8 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                              silc_client_command_file_get_clients, inter);
       goto out;
     }
-    client_entry = entrys[0];
-    silc_free(entrys);
+    silc_dlist_start(entries);
+    client_entry = silc_dlist_get(entries);
 
     if (argc >= 5) {
       if (!strcasecmp(argv[4], "-no-listener"))
@@ -972,10 +957,31 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
        do_not_bind = TRUE;
     }
 
-    ret =
-      silc_client_file_send(silc_client, conn, silc_client_file_monitor,
-                           server, local_ip, local_port, do_not_bind,
-                           client_entry, argv[2], &session_id);
+    memset(&params, 0, sizeof(params));
+    if (!do_not_bind) {
+      if (local_ip)
+        params.local_ip = strdup(local_ip);
+      params.local_port = local_port;
+      if (!params.local_ip && settings_get_bool("use_auto_addr")) {
+       params.local_ip = (char *)settings_get_str("auto_public_ip");
+       if ((params.local_ip) && (*params.local_ip == '\0')) {
+         params.local_ip = silc_net_localip();
+       } else {
+         params.bind_ip = (char *)settings_get_str("auto_bind_ip");
+         if ((params.bind_ip) && (*params.bind_ip == '\0'))
+           params.bind_ip = NULL;
+         params.local_port = settings_get_int("auto_bind_port");
+       }
+      }
+      if (!params.local_ip)
+       params.local_ip = silc_net_localip();
+    }
+    params.timeout_secs = settings_get_int("key_exchange_timeout_secs");
+
+    ret = silc_client_file_send(silc_client, conn, client_entry, &params,
+                               irssi_pubkey, irssi_privkey,
+                               silc_client_file_monitor, server, argv[2],
+                               &session_id);
     if (ret == SILC_CLIENT_FILE_OK) {
       ftp = silc_calloc(1, sizeof(*ftp));
       ftp->session_id = session_id;
@@ -1001,21 +1007,22 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                           client_entry->nickname, argv[2]);
     }
 
+    silc_client_list_free(silc_client, server->conn, entries);
     break;
 
   case 2:
     /* Parse the typed nickname. */
     if (argc >= 3) {
-      if (!silc_parse_userfqdn(argv[2], &nickname, NULL)) {
+      if (!silc_parse_userfqdn(argv[2], nickname, sizeof(nickname), NULL, 0)) {
        printformat_module("fe-common/silc", server, NULL,
                           MSGLEVEL_CRAP, SILCTXT_BAD_NICK, argv[2]);
        goto out;
       }
 
       /* Find client entry */
-      entrys = silc_client_get_clients_local(silc_client, conn, nickname,
-                                            argv[2], &entry_count);
-      if (!entrys) {
+      entries = silc_client_get_clients_local(silc_client, conn, nickname,
+                                             argv[2]);
+      if (!entries) {
        FileGetClients inter = silc_calloc(1, sizeof(*inter));
        inter->server = server;
        inter->data = strdup(data);
@@ -1025,8 +1032,9 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                                silc_client_command_file_get_clients, inter);
        goto out;
       }
-      client_entry = entrys[0];
-      silc_free(entrys);
+      silc_dlist_start(entries);
+      client_entry = silc_dlist_get(entries);
+      silc_client_list_free(silc_client, server->conn, entries);
     } else {
       if (!server->current_session) {
        printformat_module("fe-common/silc", server, NULL,
@@ -1034,7 +1042,24 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
        goto out;
       }
 
-      ret = silc_client_file_receive(silc_client, conn,
+      memset(&params, 0, sizeof(params));
+      if (settings_get_bool("use_auto_addr")) {
+       params.local_ip = (char *)settings_get_str("auto_public_ip");
+       if ((params.local_ip) && (*params.local_ip == '\0')) {
+         params.local_ip = silc_net_localip();
+       } else {
+         params.bind_ip = (char *)settings_get_str("auto_bind_ip");
+         if ((params.bind_ip) && (*params.bind_ip == '\0'))
+           params.bind_ip = NULL;
+         params.local_port = settings_get_int("auto_bind_port");
+       }
+      }
+      if (!params.local_ip)
+       params.local_ip = silc_net_localip();
+      params.timeout_secs = settings_get_int("key_exchange_timeout_secs");
+
+      ret = silc_client_file_receive(silc_client, conn, &params,
+                                    irssi_pubkey, irssi_privkey,
                                     silc_client_file_monitor, server, NULL,
                                     server->current_session->session_id,
                                     NULL, NULL);
@@ -1066,7 +1091,24 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
     silc_dlist_start(server->ftp_sessions);
     while ((ftp = silc_dlist_get(server->ftp_sessions)) != SILC_LIST_END) {
       if (ftp->client_entry == client_entry && !ftp->filepath) {
-       ret = silc_client_file_receive(silc_client, conn,
+       memset(&params, 0, sizeof(params));
+       if (settings_get_bool("use_auto_addr")) {
+         params.local_ip = (char *)settings_get_str("auto_public_ip");
+         if ((params.local_ip) && (*params.local_ip == '\0')) {
+           params.local_ip = silc_net_localip();
+         } else {
+           params.bind_ip = (char *)settings_get_str("auto_bind_ip");
+           if ((params.bind_ip) && (*params.bind_ip == '\0'))
+             params.bind_ip = NULL;
+           params.local_port = settings_get_int("auto_bind_port");
+         }
+       }
+       if (!params.local_ip)
+         params.local_ip = silc_net_localip();
+       params.timeout_secs = settings_get_int("key_exchange_timeout_secs");
+
+       ret = silc_client_file_receive(silc_client, conn, &params,
+                                      irssi_pubkey, irssi_privkey,
                                       silc_client_file_monitor, server,
                                       NULL, ftp->session_id, NULL, NULL);
        if (ret != SILC_CLIENT_FILE_OK) {
@@ -1104,16 +1146,16 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
   case 3:
     /* Parse the typed nickname. */
     if (argc >= 3) {
-      if (!silc_parse_userfqdn(argv[2], &nickname, NULL)) {
+      if (!silc_parse_userfqdn(argv[2], nickname, sizeof(nickname), NULL, 0)) {
        printformat_module("fe-common/silc", server, NULL,
                           MSGLEVEL_CRAP, SILCTXT_BAD_NICK, argv[2]);
        goto out;
       }
 
       /* Find client entry */
-      entrys = silc_client_get_clients_local(silc_client, conn, nickname,
-                                            argv[2], &entry_count);
-      if (!entrys) {
+      entries = silc_client_get_clients_local(silc_client, conn, nickname,
+                                             argv[2]);
+      if (!entries) {
        FileGetClients inter = silc_calloc(1, sizeof(*inter));
        inter->server = server;
        inter->data = strdup(data);
@@ -1123,8 +1165,9 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                                silc_client_command_file_get_clients, inter);
        goto out;
       }
-      client_entry = entrys[0];
-      silc_free(entrys);
+      silc_dlist_start(entries);
+      client_entry = silc_dlist_get(entries);
+      silc_client_list_free(silc_client, server->conn, entries);
     } else {
       if (!server->current_session) {
        printformat_module("fe-common/silc", server, NULL,
@@ -1208,9 +1251,8 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
   }
 
  out:
-  silc_free(nickname);
+  return;
 }
-#endif /* 0 */
 
 void silc_server_init(void)
 {
@@ -1238,10 +1280,8 @@ void silc_server_init(void)
   command_bind_silc("ping", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("motd", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("close", MODULE_NAME, (SIGNAL_FUNC) command_self);
-  command_bind_silc("shutdown", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("getkey", MODULE_NAME, (SIGNAL_FUNC) command_self);
-  command_bind_silc("sconnect", MODULE_NAME, (SIGNAL_FUNC) command_sconnect);
-//  command_bind_silc("file", MODULE_NAME, (SIGNAL_FUNC) command_file);
+  command_bind_silc("file", MODULE_NAME, (SIGNAL_FUNC) command_file);
   command_bind_silc("detach", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("watch", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("stats", MODULE_NAME, (SIGNAL_FUNC) command_self);
@@ -1277,10 +1317,8 @@ void silc_server_deinit(void)
   command_unbind("motd", (SIGNAL_FUNC) command_self);
   command_unbind("ban", (SIGNAL_FUNC) command_self);
   command_unbind("close", (SIGNAL_FUNC) command_self);
-  command_unbind("shutdown", (SIGNAL_FUNC) command_self);
   command_unbind("getkey", (SIGNAL_FUNC) command_self);
-  command_unbind("sconnect", (SIGNAL_FUNC) command_sconnect);
-//  command_unbind("file", (SIGNAL_FUNC) command_file);
+  command_unbind("file", (SIGNAL_FUNC) command_file);
   command_unbind("detach", (SIGNAL_FUNC) command_self);
   command_unbind("watch", (SIGNAL_FUNC) command_self);
   command_unbind("stats", (SIGNAL_FUNC) command_self);
@@ -1288,7 +1326,6 @@ void silc_server_deinit(void)
   command_unbind("smsg", (SIGNAL_FUNC) command_smsg);
 }
 
-#if 0
 void silc_server_free_ftp(SILC_SERVER_REC *server,
                          SilcClientEntry client_entry)
 {
@@ -1303,7 +1340,6 @@ void silc_server_free_ftp(SILC_SERVER_REC *server,
     }
   }
 }
-#endif /* 0 */
 
 bool silc_term_utf8(void)
 {