From 9ec27d3bc1cc280ec22c4544a5dbd7c4584b8762 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 4 Nov 2001 15:38:45 +0000 Subject: [PATCH] updates. --- CHANGES | 17 ++++++++++++++ apps/irssi/config | 1 + apps/irssi/docs/help/in/key.in | 11 +++++++++ apps/irssi/src/silc/core/silc-channels.c | 29 +++++++++++++++++++++++- apps/irssi/src/silc/core/silc-core.c | 10 ++++++++ lib/silcclient/client_keyagr.c | 18 ++++++++++++--- lib/silcclient/silcapi.h | 3 ++- 7 files changed, 84 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index a6448920..d350218d 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,23 @@ Sat Nov 3 23:48:23 EET 2001 Pekka Riikonen * Find correct make to use in prepare-clean. A patch by toma. Affected file prepare-clean. +Sat Nov 3 22:04:00 PST 2001 Brian Costello + + * Added irssi variables use_auto_addr, auto_bind_ip, + auto_bind_port and auto_public_ip. + + * Changed the interface for silc_client_send_key_agreement + in lib/silcclient/silcapi.h + + Affected files: + + irssi/src/silc/core/silc-core.c + irssi/config + lib/silcclient/silcapi.h + irssi/src/silc/core/silc-channels.c + lib/silcclient/client_keyagr.c + irssi/docs/help/key + Sat Nov 3 17:48:55 EET 2001 Pekka Riikonen * Added silc_pkcs_public_key_compare to compare two diff --git a/apps/irssi/config b/apps/irssi/config index 40e10e67..b930de3d 100644 --- a/apps/irssi/config +++ b/apps/irssi/config @@ -57,6 +57,7 @@ settings = { use_msgs_window = "no"; autocreate_windows = "no"; autocreate_query_level = "none"; + use_auto_addr = "no"; }; "fe-text" = { topicbar = "no"; mail_counter = "yes"; indent = "8"; }; }; diff --git a/apps/irssi/docs/help/in/key.in b/apps/irssi/docs/help/in/key.in index b2ff1838..b4874c91 100644 --- a/apps/irssi/docs/help/in/key.in +++ b/apps/irssi/docs/help/in/key.in @@ -72,6 +72,17 @@ Commands: you can reply to the sender with the hostname and port of your key agreement server with this command. + If the hostname and port are ommitted, the irssi + boolean variable use_auto_addr will be examined. If + this variable is set, the value of auto_bind_ip will + be used as the IP address to listen for the return + reply, the value of auto_public_ip will be the IP + address sent to the remote client, and 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, irssi will send the auto_bind_ip + variable's value to the remote client. + negotiate [ []] This may be called to start the key agreement with diff --git a/apps/irssi/src/silc/core/silc-channels.c b/apps/irssi/src/silc/core/silc-channels.c index 499b0cfe..c02d61d2 100644 --- a/apps/irssi/src/silc/core/silc-channels.c +++ b/apps/irssi/src/silc/core/silc-channels.c @@ -861,6 +861,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server, uint32 argc = 0; unsigned char **argv; uint32 *argv_lens, *argv_types; + char *bindhost = NULL; if (!server || !IS_SILC_SERVER(server) || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); @@ -1172,6 +1173,31 @@ static void command_key(const char *data, SILC_SERVER_REC *server, internal = silc_calloc(1, sizeof(*internal)); internal->type = type; internal->server = server; + + if (!hostname) { + if (settings_get_bool("use_auto_addr")) { + + hostname = (char *)settings_get_str("auto_public_ip"); + +/* If the hostname isn't set, treat this case as if auto_public_ip wasn't + * set. + */ + if ((hostname) && (*hostname == '\0')) { + hostname = NULL; + } + else { + bindhost = (char *)settings_get_str("auto_bind_ip"); + +/* if the bind_ip isn't set, but the public_ip IS, then assume then + * public_ip is the same value as the bind_ip. + */ + if ((bindhost) && (*bindhost == '\0')) { + bindhost = hostname; + } + port = settings_get_int("auto_bind_port"); + } + } /* if use_auto_addr */ + } } /* Start command is used to start key agreement (after receiving the @@ -1201,7 +1227,8 @@ static void command_key(const char *data, SILC_SERVER_REC *server, SILCTXT_KEY_AGREEMENT, argv[2]); internal->responder = TRUE; silc_client_send_key_agreement(silc_client, conn, client_entry, hostname, - port, 120, keyagr_completion, internal); + bindhost, port, 120, keyagr_completion, + internal); if (!hostname) silc_free(internal); goto out; diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index 1a833661..767cb0b1 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -275,6 +275,16 @@ void silc_core_init_finish(void) /* Do some irssi initializing */ settings_add_bool("server", "skip_motd", FALSE); settings_add_str("server", "alternate_nick", NULL); + + /* Initialize the auto_addr variables Is "server" the best choice for + * this? No existing category seems to apply. + */ + + settings_add_bool("server", "use_auto_addr", FALSE); + settings_add_str("server", "auto_bind_ip", ""); + settings_add_str("server", "auto_public_ip", ""); + settings_add_int("server", "auto_bind_port", 0); + silc_init_userinfo(); /* Initialize client parameters */ diff --git a/lib/silcclient/client_keyagr.c b/lib/silcclient/client_keyagr.c index 336ea5b7..d584baef 100644 --- a/lib/silcclient/client_keyagr.c +++ b/lib/silcclient/client_keyagr.c @@ -295,7 +295,8 @@ SILC_TASK_CALLBACK(silc_client_key_agreement_timeout) void silc_client_send_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, - char *hostname, + const char *hostname, + const char *bindhost, int port, uint32 timeout_secs, SilcKeyAgreementCallback completion, @@ -310,18 +311,28 @@ void silc_client_send_key_agreement(SilcClient client, if (client_entry->ke) return; - /* Create the listener if hostname and port was provided */ + /* Create the listener if hostname and port was provided. + * also, use bindhost if it was specified. + */ + if (hostname) { ke = silc_calloc(1, sizeof(*ke)); + + if (bindhost) { + ke->fd = silc_net_create_server(port, bindhost); + } + else { ke->fd = silc_net_create_server(port, hostname); + } if (ke->fd < 0) { client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR, "Cannot create listener on %s on port %d: %s", - hostname, port, strerror(errno)); + (bindhost) ? bindhost:hostname, port, strerror(errno)); completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE, NULL, context); silc_free(ke); + return; } @@ -358,6 +369,7 @@ void silc_client_send_key_agreement(SilcClient client, client_entry->id, SILC_ID_CLIENT, NULL, NULL, buffer->data, buffer->len, FALSE); silc_buffer_free(buffer); + } static int diff --git a/lib/silcclient/silcapi.h b/lib/silcclient/silcapi.h index 1038074a..155ea2da 100644 --- a/lib/silcclient/silcapi.h +++ b/lib/silcclient/silcapi.h @@ -1586,7 +1586,8 @@ void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys, void silc_client_send_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, - char *hostname, + const char *hostname, + const char *bindhost, int port, uint32 timeout_secs, SilcKeyAgreementCallback completion, -- 2.24.0