From 231c599fcb44a00645655e2908cbb13fd29d9339 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 14 Feb 2007 14:59:33 +0000 Subject: [PATCH] File transfer fixes. --- apps/irssi/docs/help/in/file.in | 14 +- .../irssi/src/fe-common/silc/module-formats.c | 5 +- .../irssi/src/fe-common/silc/module-formats.h | 7 +- apps/irssi/src/silc/core/client_ops.c | 100 ++++++----- apps/irssi/src/silc/core/silc-servers.c | 170 +++++++++++------- 5 files changed, 181 insertions(+), 115 deletions(-) diff --git a/apps/irssi/docs/help/in/file.in b/apps/irssi/docs/help/in/file.in index cb6ee86f..61a719a4 100644 --- a/apps/irssi/docs/help/in/file.in +++ b/apps/irssi/docs/help/in/file.in @@ -22,7 +22,7 @@ Commands: If the is provided then the key exchange protocol listener will be bound to that address. If - is defined it is bound to that 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 and 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 [] 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. - diff --git a/apps/irssi/src/fe-common/silc/module-formats.c b/apps/irssi/src/fe-common/silc/module-formats.c index 2171d607..291f001b 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.c +++ b/apps/irssi/src/fe-common/silc/module-formats.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 }, diff --git a/apps/irssi/src/fe-common/silc/module-formats.h b/apps/irssi/src/fe-common/silc/module-formats.h index bb5666ad..b7a0fc93 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.h +++ b/apps/irssi/src/fe-common/silc/module-formats.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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, diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 85433420..5f1ff5d0 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -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 : "[]", + sender->nickname[0] ? sender->nickname : "[]", 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 : "[]", - sender->username ? userhost : NULL, + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, NULL, verified); else signal_emit("message silc private_action", 5, server, cp, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL, NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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 : "[]", - sender->username ? userhost : NULL, + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, NULL, verified); else signal_emit("message silc private_action", 5, server, message, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL, NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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 : "[]", - sender->username ? userhost : NULL, + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, NULL, verified); else signal_emit("message silc private_notice", 5, server, cp, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL, NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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 : "[]", - sender->username ? userhost : NULL, + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, NULL, verified); else signal_emit("message silc private_notice", 5, server, message, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL, NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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 : "[]", - sender->username ? userhost : NULL, verified); + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, verified); else signal_emit("message private", 4, server, cp, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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 : "[]", - sender->username ? userhost : NULL, verified); + sender->nickname[0] ? sender->nickname : "[]", + sender->username[0] ? userhost : NULL, verified); else signal_emit("message private", 4, server, message, - sender->nickname ? sender->nickname : "[]", - sender->username ? userhost : NULL); + sender->nickname[0] ? sender->nickname : "[]", + 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); diff --git a/apps/irssi/src/silc/core/silc-servers.c b/apps/irssi/src/silc/core/silc-servers.c index 11f1032e..38ea4f48 100644 --- a/apps/irssi/src/silc/core/silc-servers.c +++ b/apps/irssi/src/silc/core/silc-servers.c @@ -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 [[@]] [-details] [-pubkey ] [] */ /* SYNTAX: WHOWAS [@] [] */ /* SYNTAX: CLOSE [] */ -/* SYNTAX: SHUTDOWN */ /* SYNTAX: MOTD [] */ /* SYNTAX: LIST [] */ /* SYNTAX: ME */ @@ -569,7 +569,6 @@ char *silc_server_get_channels(SILC_SERVER_REC *server) /* SYNTAX: NOTICE [-sign] [-channel] */ /* SYNTAX: PART [] */ /* SYNTAX: PING */ -/* SYNTAX: SCONNECT [] */ /* SYNTAX: USERS */ /* SYNTAX: FILE SEND [ []] [-no-listener]*/ /* SYNTAX: FILE ACCEPT [] */ @@ -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(¶ms, 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, ¶ms, + 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(¶ms, 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, ¶ms, + 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(¶ms, 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, ¶ms, + 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) { -- 2.24.0