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
if (silc_pkcs_get_type(pubkey) != SILC_PKCS_SILC)
continue;
- pk = silc_pkcs_public_key_encode(pubkey, &pk_len);
+ pk = silc_pkcs_public_key_encode(NULL, pubkey, &pk_len);
if (!pk)
continue;
fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
- silc_pubkey = silc_pkcs_get_context(SILC_PKCS_SILC, pubkey);
+ silc_pubkey = silc_pkcs_public_key_get_pkcs(SILC_PKCS_SILC, pubkey);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_LIST_ENTRY,
va_end(va);
}
+void static verify_message_signature_verified(SilcBool success,
+ void *context)
+{
+ *(SilcBool *)context = success;
+}
+
/* Try to verify a message using locally stored public key data */
int verify_message_signature(SilcClientEntry sender,
SilcUInt32 pk_datalen;
struct stat st;
int ret = SILC_MSG_SIGNED_VERIFIED, i;
+ SilcBool verified = FALSE;
/* get public key from the signature payload and compare it with the
one stored in the client entry */
if (pk != NULL) {
fingerprint = silc_hash_fingerprint(NULL, pk_data, pk_datalen);
- if (sender->fingerprint) {
+ if (sender->fingerprint[0]) {
fingerprint2 = silc_fingerprint(sender->fingerprint,
sizeof(sender->fingerprint));
if (strcmp(fingerprint, fingerprint2)) {
}
silc_free(fingerprint2);
}
- } else if (sender->fingerprint)
+ } else if (sender->fingerprint[0])
fingerprint = silc_fingerprint(sender->fingerprint,
sizeof(sender->fingerprint));
else
SilcPublicKey cached_pk=NULL;
/* try to load the file */
- if (!silc_pkcs_load_public_key(filename, &cached_pk)) {
+ if (!silc_pkcs_load_public_key(filename, SILC_PKCS_ANY, &cached_pk)) {
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_COULD_NOT_LOAD, "client");
if (pk == NULL)
}
/* the public key is now in pk, our "level of trust" in ret */
- if ((pk) && silc_message_signed_verify(message, pk,
- sha1hash)!= SILC_AUTH_OK)
- ret = SILC_MSG_SIGNED_FAILED;
+ if (pk) {
+ silc_message_signed_verify(message, pk, sha1hash,
+ verify_message_signature_verified, &verified);
+ if (!verified)
+ ret = SILC_MSG_SIGNED_FAILED;
+ }
if (pk)
silc_pkcs_public_key_free(pk);
SilcChannelUser chu = silc_client_on_channel(channel, sender);
if (chu)
nick = silc_nicklist_insert(chanrec, chu, FALSE);
+ if (!nick)
+ return;
}
/* If the messages is digitally signed, verify it, if possible. */
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);
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;
}
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()) {
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()) {
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);
}
}
char buf[512];
char *name, *tmp, *cipher, *hmac;
GSList *list1, *list_tmp;
- SilcDList chpks;
+ SilcDList chpks, clients;
SILC_LOG_DEBUG(("Start"));
name = va_arg(va, char *);
client_entry = va_arg(va, SilcClientEntry);
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s@%s",
- client_entry->username, client_entry->hostname);
- signal_emit("message invite", 4, server, channel ? channel->channel_name :
- name, client_entry->nickname, buf);
+ silc_snprintf(buf, sizeof(buf) - 1, "%s@%s",
+ client_entry->username, client_entry->hostname);
+ signal_emit("message invite", 4, server, name,
+ client_entry->nickname, buf);
break;
case SILC_NOTIFY_TYPE_JOIN:
if (client_entry == server->conn->local_entry) {
/* You joined to channel */
chanrec = silc_channel_find(server, channel->channel_name);
- if (chanrec != NULL && !chanrec->joined)
+ if (chanrec == NULL)
+ chanrec = silc_channel_create(server, channel->channel_name,
+ channel->channel_name, TRUE);
+ if (!chanrec->joined)
chanrec->entry = channel;
} else {
chanrec = silc_channel_find_entry(server, channel);
}
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);
+ !client_entry->username[0] ? "" : buf);
+
+ /* If there are multiple same nicknames on channel now, tell it to user. */
+ if (client_entry != server->conn->local_entry) {
+ char *nick, tmp[32];
+ int count = 0;
+
+ silc_client_nickname_parse(client, conn, client_entry->nickname, &nick);
+ clients = silc_client_get_clients_local(client, conn, nick, TRUE);
+ if (!clients || silc_dlist_count(clients) < 2) {
+ silc_free(nick);
+ silc_client_list_free(client, conn, clients);
+ break;
+ }
+ silc_dlist_start(clients);
+ while ((client_entry2 = silc_dlist_get(clients)))
+ if (silc_client_on_channel(channel, client_entry2))
+ count++;
+ if (count > 1) {
+ silc_snprintf(tmp, sizeof(tmp), "%d", silc_dlist_count(clients));
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_MANY_NICKS,
+ tmp, nick);
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_USER_APPEARS,
+ buf, client_entry->nickname);
+ }
+ silc_client_list_free(client, conn, clients);
+ silc_free(nick);
+ }
break;
case SILC_NOTIFY_TYPE_LEAVE:
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);
if (nickrec != NULL)
nicklist_remove(CHANNEL(chanrec), NICK(nickrec));
}
+
+ /* If there is only one client with this same nickname on channel now
+ change it to the base format if it is formatted nickname. */
+ if (channel) {
+ silc_client_nickname_parse(client, conn, client_entry->nickname, &name);
+ clients = silc_client_get_clients_local(client, conn, name, TRUE);
+ if (!clients || silc_dlist_count(clients) != 2) {
+ silc_free(name);
+ silc_client_list_free(client, conn, clients);
+ break;
+ }
+ silc_dlist_start(clients);
+ client_entry2 = silc_dlist_get(clients);
+ if (client_entry2 == client_entry)
+ client_entry2 = silc_dlist_get(clients);
+ if (silc_client_on_channel(channel, client_entry2)) {
+ silc_snprintf(buf, sizeof(buf), "%s", client_entry2->nickname);
+ silc_client_nickname_format(client, conn, client_entry2, TRUE);
+ if (!silc_utf8_strcasecmp(buf, client_entry2->nickname)) {
+ nicklist_rename_unique(SERVER(server), client_entry2, buf,
+ client_entry2, client_entry2->nickname);
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_USER_APPEARS,
+ buf, client_entry2->nickname);
+ }
+ }
+ silc_client_list_free(client, conn, clients);
+ silc_free(name);
+ }
break;
case SILC_NOTIFY_TYPE_SIGNOFF:
client_entry = va_arg(va, SilcClientEntry);
tmp = va_arg(va, char *);
+ channel = va_arg(va, SilcChannelEntry);
-#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) {
- 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 : "",
- tmp ? tmp : "");
- }
+ 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[0] ? buf : "", tmp ? tmp : "");
list1 = nicklist_get_same_unique(SERVER(server), client_entry);
for (list_tmp = list1; list_tmp != NULL; list_tmp =
nicklist_remove(channel, nickrec);
}
+
+ /* If there is only one client with this same nickname on channel now
+ change it to the base format if it is formatted nickname. */
+ if (channel) {
+ silc_client_nickname_parse(client, conn, client_entry->nickname, &name);
+ clients = silc_client_get_clients_local(client, conn, name, TRUE);
+ if (!clients || silc_dlist_count(clients) != 2) {
+ silc_free(name);
+ silc_client_list_free(client, conn, clients);
+ break;
+ }
+ silc_dlist_start(clients);
+ client_entry2 = silc_dlist_get(clients);
+ if (client_entry2 == client_entry)
+ client_entry2 = silc_dlist_get(clients);
+ if (silc_client_on_channel(channel, client_entry2)) {
+ silc_snprintf(buf, sizeof(buf), "%s", client_entry2->nickname);
+ silc_client_nickname_format(client, conn, client_entry2, TRUE);
+ if (!silc_utf8_strcasecmp(buf, client_entry2->nickname)) {
+ nicklist_rename_unique(SERVER(server), client_entry2, buf,
+ client_entry2, client_entry2->nickname);
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_USER_APPEARS,
+ buf, client_entry2->nickname);
+ }
+ }
+ silc_client_list_free(client, conn, clients);
+ silc_free(name);
+ }
break;
case SILC_NOTIFY_TYPE_TOPIC_SET:
SILC_LOG_DEBUG(("Notify: NICK_CHANGE"));
client_entry = va_arg(va, SilcClientEntry);
- client_entry2 = va_arg(va, SilcClientEntry);
+ name = va_arg(va, char *); /* old nickname */
- if (!strcmp(client_entry->nickname, client_entry2->nickname))
+ if (!strcmp(client_entry->nickname, name))
break;
memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf) - 1, "%s@%s",
- client_entry2->username, client_entry2->hostname);
+ client_entry->username, client_entry->hostname);
nicklist_rename_unique(SERVER(server),
- client_entry, client_entry->nickname,
- client_entry2, client_entry2->nickname);
- signal_emit("message nick", 4, server, client_entry2->nickname,
- client_entry->nickname, buf);
+ client_entry, name,
+ client_entry, client_entry->nickname);
+ signal_emit("message nick", 4, server, client_entry->nickname, name, buf);
break;
case SILC_NOTIFY_TYPE_CMODE_CHANGE:
/*
* Server has quit the network.
*/
- int i;
- SilcClientEntry *clients;
- SilcUInt32 clients_count;
+ SilcDList clients;
- SILC_LOG_DEBUG(("Notify: SIGNOFF"));
+ SILC_LOG_DEBUG(("Notify: SERVER_SIGNOFF"));
(void)va_arg(va, void *);
- clients = va_arg(va, SilcClientEntry *);
- clients_count = va_arg(va, SilcUInt32);
+ clients = va_arg(va, SilcDList);
- for (i = 0; i < clients_count; i++) {
+ silc_dlist_start(clients);
+ while ((client_entry = silc_dlist_get(clients))) {
memset(buf, 0, sizeof(buf));
/* Print only if we have the nickname. If this client has just quit
when we were only resolving it, it is possible we don't have the
nickname. */
- if (clients[i]->nickname) {
- if (clients[i]->username)
+ if (client_entry->nickname[0]) {
+ if (client_entry->username[0])
snprintf(buf, sizeof(buf) - 1, "%s@%s",
- clients[i]->username, clients[i]->hostname);
- signal_emit("message quit", 4, server, clients[i]->nickname,
- clients[i]->username ? buf : "",
+ client_entry->username, client_entry->hostname);
+ signal_emit("message quit", 4, server, client_entry->nickname,
+ client_entry->username[0] ? buf : "",
"server signoff");
}
-#if 0
- silc_server_free_ftp(server, clients[i]);
-#endif
+ silc_server_free_ftp(server, client_entry);
- list1 = nicklist_get_same_unique(SERVER(server), clients[i]);
+ list1 = nicklist_get_same_unique(SERVER(server), client_entry);
for (list_tmp = list1; list_tmp != NULL; list_tmp =
list_tmp->next->next) {
CHANNEL_REC *channel = list_tmp->data;
after application has called the command. Just to tell application
that the command really was processed. */
-static bool cmode_list_chpks = FALSE;
+static SilcBool cmode_list_chpks = FALSE;
void silc_command(SilcClient client, SilcClientConnection conn,
SilcBool success, SilcCommand command, SilcStatus status,
char *name = (getkey->id_type == SILC_ID_CLIENT ?
((SilcClientEntry)getkey->entry)->nickname :
((SilcServerEntry)getkey->entry)->server_name);
+ SilcPublicKey public_key = (getkey->id_type == SILC_ID_CLIENT ?
+ ((SilcClientEntry)getkey->entry)->public_key :
+ ((SilcServerEntry)getkey->entry)->public_key);
+ SilcSILCPublicKey silc_pubkey;
+
+ silc_pubkey = silc_pkcs_public_key_get_pkcs(SILC_PKCS_SILC, public_key);
if (success) {
- printformat_module("fe-common/silc", NULL, NULL,
- MSGLEVEL_CRAP, SILCTXT_PUBKEY_VERIFIED, entity, name);
+ if (getkey->id_type == SILC_ID_CLIENT)
+ printformat_module("fe-common/silc", NULL, NULL,
+ MSGLEVEL_CRAP, SILCTXT_PUBKEY_VERIFIED_CLIENT,
+ name,
+ silc_pubkey->identifier.realname ?
+ silc_pubkey->identifier.realname : "",
+ silc_pubkey->identifier.email ?
+ silc_pubkey->identifier.email : "");
+ else
+ printformat_module("fe-common/silc", NULL, NULL,
+ MSGLEVEL_CRAP, SILCTXT_PUBKEY_VERIFIED,
+ entity, name);
} else {
printformat_module("fe-common/silc", NULL, NULL,
MSGLEVEL_CRAP, SILCTXT_PUBKEY_NOTVERIFIED,
switch(command) {
case SILC_COMMAND_WHOIS:
{
- char buf[1024], *nickname, *username, *realname, nick[128 + 1];
+ char buf[1024], *nickname, *username, *realname, *nick;
unsigned char *fingerprint;
SilcUInt32 idle, mode, *user_modes;
SilcDList channels;
silc_client_unref_client(client, conn, client_entry);
}
break;
- } else if (status != SILC_STATUS_OK) {
+ } else if (SILC_STATUS_IS_ERROR(status)) {
silc_say_error("WHOIS: %s", silc_get_status_message(status));
return;
}
user_modes = va_arg(vp, SilcUInt32 *);
attrs = va_arg(vp, SilcDList);
- silc_parse_userfqdn(nickname, nick, sizeof(nick), NULL, 0);
+ silc_client_nickname_parse(client, conn, client_entry->nickname, &nick);
printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
SILCTXT_WHOIS_USERINFO, nickname,
client_entry->username, client_entry->hostname,
nick, client_entry->nickname);
printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
SILCTXT_WHOIS_REALNAME, realname);
+ silc_free(nick);
if (channels && user_modes) {
SilcChannelPayload entry;
int i = 0;
+ memset(buf, 0, sizeof(buf));
silc_dlist_start(channels);
while ((entry = silc_dlist_get(channels))) {
SilcUInt32 name_len;
silc_say_error("%s: %s", tmp,
silc_get_status_message(status));
break;
- } else if (status != SILC_STATUS_OK) {
+ } else if (SILC_STATUS_IS_ERROR(status)) {
silc_say_error("WHOWAS: %s", silc_get_status_message(status));
return;
}
SilcChannelEntry channel;
SilcArgumentPayload invite_list;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
channel = va_arg(vp, SilcChannelEntry);
SilcClientEntry founder = NULL;
NICK_REC *ownnick;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ if (status == SILC_STATUS_ERR_NO_SUCH_SERVER) {
+ char *tmp = va_arg(vp, char *);
+ if (tmp)
+ silc_say_error("JOIN: %s: %s", tmp,
+ silc_get_status_message(status));
+ return;
+ }
+ if (status == SILC_STATUS_ERR_NO_SUCH_CHANNEL) {
+ char *tmp = va_arg(vp, char *);
+ if (tmp)
+ silc_say_error("JOIN: %s: %s", tmp,
+ silc_get_status_message(status));
+ return;
+ }
+ silc_say_error("JOIN: %s", silc_get_status_message(status));
return;
+ }
channel = va_arg(vp, char *);
channel_entry = va_arg(vp, SilcChannelEntry);
/* 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;
}
ownnick = NICK(silc_nicklist_find(chanrec, conn->local_entry));
+ if (!ownnick)
+ break;
nicklist_set_own(CHANNEL(chanrec), ownnick);
signal_emit("channel joined", 1, chanrec);
chanrec->entry = channel_entry;
SilcClientEntry client_entry = va_arg(vp, SilcClientEntry);
GSList *nicks;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("NICK: %s", silc_get_status_message(status));
return;
+ }
nicks = nicklist_get_same(SERVER(server), client_entry->nickname);
if ((nicks != NULL) &&
- (strcmp(SERVER(server)->nick, client_entry->nickname))) {
+ (strcmp(SERVER(server)->nick, client_entry->nickname))) {
char buf[512];
SilcClientEntry collider, old;
old = ((SILC_NICK_REC *)(nicks->next->data))->silc_user->client;
collider = silc_client_get_client_by_id(client, conn, &old->id);
if (collider != client_entry) {
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s@%s",
- collider->username, collider->hostname);
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf) - 1, "%s@%s",
+ collider->username, collider->hostname);
nicklist_rename_unique(SERVER(server),
- old, old->nickname,
- collider, collider->nickname);
+ old, old->nickname,
+ collider, collider->nickname);
silc_print_nick_change(server, collider->nickname,
- client_entry->nickname, buf);
+ client_entry->nickname, buf);
}
silc_client_unref_client(client, conn, collider);
}
char users[20];
char tmp[256], *cp, *dm = NULL;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
(void)va_arg(vp, SilcChannelEntry);
name = va_arg(vp, char *);
- if (!name)
- return;
topic = va_arg(vp, char *);
usercount = va_arg(vp, int);
SilcUInt32 mode;
char *reason;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
mode = va_arg(vp, SilcUInt32);
break;
case SILC_COMMAND_OPER:
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("OPER: %s", silc_get_status_message(status));
return;
+ }
server->umode |= SILC_UMODE_SERVER_OPERATOR;
signal_emit("user mode changed", 2, server, NULL);
break;
case SILC_COMMAND_SILCOPER:
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("SILCOPER: %s", silc_get_status_message(status));
return;
+ }
server->umode |= SILC_UMODE_ROUTER_OPERATOR;
signal_emit("user mode changed", 2, server, NULL);
SilcChannelEntry channel;
SilcChannelUser chu;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("USERS: %s", silc_get_status_message(status));
return;
+ }
channel = va_arg(vp, SilcChannelEntry);
SilcClientEntry e = chu->client;
char stat[5], *mode;
- if (!e->nickname)
+ if (!e->nickname[0])
continue;
memset(stat, 0, sizeof(stat));
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);
SilcChannelEntry channel;
SilcArgumentPayload invite_list;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
channel = va_arg(vp, SilcChannelEntry);
GetkeyContext getkey;
char *name;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("GETKEY: %s", silc_get_status_message(status));
return;
+ }
id_type = va_arg(vp, SilcUInt32);
entry = va_arg(vp, void *);
char *server_name;
char *server_info;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
server_entry = va_arg(vp, SilcServerEntry);
char *topic;
char tmp[256], *cp, *dm = NULL;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
channel = va_arg(vp, SilcChannelEntry);
case SILC_COMMAND_STATS:
{
- SilcUInt32 starttime, uptime, my_clients, my_channels, my_server_ops,
- my_router_ops, cell_clients, cell_channels, cell_servers,
- clients, channels, servers, routers, server_ops, router_ops;
- SilcUInt32 buf_len;
- SilcBufferStruct buf;
- unsigned char *tmp_buf;
+ SilcClientStats *cstats;
char tmp[40];
const char *tmptime;
int days, hours, mins, secs;
- if (status != SILC_STATUS_OK)
+ if (SILC_STATUS_IS_ERROR(status))
return;
- tmp_buf = va_arg(vp, unsigned char *);
- buf_len = va_arg(vp, SilcUInt32);
-
- if (!tmp_buf || !buf_len) {
+ cstats = va_arg(vp, SilcClientStats *);
+ if (!cstats) {
printtext(server, NULL, MSGLEVEL_CRAP, "No statistics available");
return;
}
- /* Get statistics structure */
- silc_buffer_set(&buf, tmp_buf, buf_len);
- silc_buffer_unformat(&buf,
- SILC_STR_UI_INT(&starttime),
- SILC_STR_UI_INT(&uptime),
- SILC_STR_UI_INT(&my_clients),
- SILC_STR_UI_INT(&my_channels),
- SILC_STR_UI_INT(&my_server_ops),
- SILC_STR_UI_INT(&my_router_ops),
- SILC_STR_UI_INT(&cell_clients),
- SILC_STR_UI_INT(&cell_channels),
- SILC_STR_UI_INT(&cell_servers),
- SILC_STR_UI_INT(&clients),
- SILC_STR_UI_INT(&channels),
- SILC_STR_UI_INT(&servers),
- SILC_STR_UI_INT(&routers),
- SILC_STR_UI_INT(&server_ops),
- SILC_STR_UI_INT(&router_ops),
- SILC_STR_END);
-
- tmptime = silc_time_string(starttime);
+ tmptime = silc_time_string(cstats->starttime);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local server start time", tmptime);
- days = uptime / (24 * 60 * 60);
- uptime -= days * (24 * 60 * 60);
- hours = uptime / (60 * 60);
- uptime -= hours * (60 * 60);
- mins = uptime / 60;
- uptime -= mins * 60;
- secs = uptime;
+ days = cstats->uptime / (24 * 60 * 60);
+ cstats->uptime -= days * (24 * 60 * 60);
+ hours = cstats->uptime / (60 * 60);
+ cstats->uptime -= hours * (60 * 60);
+ mins = cstats->uptime / 60;
+ cstats->uptime -= mins * 60;
+ secs = cstats->uptime;
snprintf(tmp, sizeof(tmp) - 1, "%d days %d hours %d mins %d secs",
days, hours, mins, secs);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local server uptime", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)my_clients);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->my_clients);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local server clients", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)my_channels);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->my_channels);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local server channels", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)my_server_ops);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->my_server_ops);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local server operators", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)my_router_ops);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->my_router_ops);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local router operators", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cell_clients);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->cell_clients);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local cell clients", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cell_channels);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->cell_channels);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local cell channels", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cell_servers);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->cell_servers);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Local cell servers", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)clients);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->clients);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total clients", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)channels);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->channels);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total channels", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)servers);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->servers);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total servers", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)routers);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->routers);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total routers", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)server_ops);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->server_ops);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total server operators", tmp);
- snprintf(tmp, sizeof(tmp) - 1, "%d", (int)router_ops);
+ snprintf(tmp, sizeof(tmp) - 1, "%d", (int)cstats->router_ops);
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_STATS,
"Total router operators", tmp);
{
SilcChannelEntry channel_entry;
SilcDList chpks;
+ SilcPublicKey founder_key;
channel_entry = va_arg(vp, SilcChannelEntry);
(void)va_arg(vp, SilcUInt32);
- (void)va_arg(vp, SilcPublicKey);
+ founder_key = va_arg(vp, SilcPublicKey);
chpks = va_arg(vp, SilcDList);
- if (status != SILC_STATUS_OK || !cmode_list_chpks ||
- !channel_entry || !channel_entry->channel_name)
+ if (SILC_STATUS_IS_ERROR(status) || !channel_entry ||
+ !channel_entry->channel_name)
return;
- /* Print the channel public key list */
- if (chpks)
- silc_parse_channel_public_keys(server, channel_entry, chpks);
- else
+ /* If founder was changed successfully, tell it to user */
+ if (founder_key && channel_entry->founder_key &&
+ !silc_pkcs_public_key_compare(founder_key,
+ channel_entry->founder_key)) {
printformat_module("fe-common/silc", server, NULL,
- MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_NO_LIST,
- channel_entry->channel_name);
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_FOUNDER_CHANGED,
+ channel_entry->channel_name);
+ }
+ /* Print the channel public key list */
+ if (cmode_list_chpks) {
+ if (chpks)
+ silc_parse_channel_public_keys(server, channel_entry, chpks);
+ else
+ printformat_module("fe-common/silc", server, NULL,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_NO_LIST,
+ channel_entry->channel_name);
+ }
}
break;
case SILC_COMMAND_LEAVE:
{
- /* we might be cycling, so disable queueing again */
+ if (SILC_STATUS_IS_ERROR(status))
+ return;
+
+ /* We might be cycling, so disable queueing again */
silc_queue_disable(conn);
}
break;
+ case SILC_COMMAND_DETACH:
+ {
+ /* Save the detachment data to file. */
+ char *file;
+ SilcBuffer detach;
+
+ if (SILC_STATUS_IS_ERROR(status))
+ return;
+
+ detach = va_arg(vp, SilcBuffer);
+ file = silc_get_session_filename(server);
+ silc_file_writefile(file, silc_buffer_data(detach),
+ silc_buffer_len(detach));
+ silc_free(file);
+ }
+ break;
+
+ case SILC_COMMAND_KILL:
+ {
+ SilcClientEntry client_entry;
+
+ if (SILC_STATUS_IS_ERROR(status)) {
+ silc_say_error("KILL: %s", silc_get_status_message(status));
+ return;
+ }
+
+ client_entry = va_arg(vp, SilcClientEntry);
+ if (!client_entry || !client_entry->nickname[0])
+ break;
+
+ /* Print this only if the killed client isn't joined on channels.
+ If it is, we receive KILLED notify and we'll print this there. */
+ if (!silc_hash_table_count(client_entry->channels))
+ printformat_module("fe-common/silc", server, NULL,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED,
+ client_entry->nickname,
+ conn->local_entry->nickname, "");
+ }
}
}
char file[256], filename[256], filename2[256], *ipf, *hostf = NULL;
char *fingerprint, *babbleprint, *format;
SilcPublicKey local_pubkey;
+ SilcSILCPublicKey silc_pubkey;
SilcUInt16 port;
const char *hostname, *ip;
unsigned char *pk;
}
/* Encode public key */
- pk = silc_pkcs_public_key_encode(public_key, &pk_len);
+ pk = silc_pkcs_public_key_encode(NULL, public_key, &pk_len);
if (!pk) {
if (completion)
completion(FALSE, context);
return;
}
+ silc_pubkey = silc_pkcs_public_key_get_pkcs(SILC_PKCS_SILC, public_key);
+
pw = getpwuid(getuid());
if (!pw) {
if (completion)
completion(FALSE, context);
+ silc_free(pk);
return;
}
memset(file, 0, sizeof(file));
/* Get remote host information */
- silc_socket_stream_get_info(conn->stream, NULL, &hostname, &ip, &port);
+ silc_socket_stream_get_info(silc_packet_stream_get_stream(conn->stream),
+ NULL, &hostname, &ip, &port);
if (conn_type == SILC_CONN_SERVER ||
conn_type == SILC_CONN_ROUTER) {
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_RECEIVED,verify->entity_name ?
verify->entity_name : entity);
+ if (conn_type == SILC_CONN_CLIENT && name &&
+ silc_pubkey->identifier.realname)
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+ SILCTXT_PUBKEY_RECEIVED_CLIENT, name,
+ silc_pubkey->identifier.realname,
+ silc_pubkey->identifier.email ?
+ silc_pubkey->identifier.email : "");
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
format, 0, verify);
g_free(format);
silc_free(fingerprint);
+ silc_free(babbleprint);
+ silc_free(pk);
return;
} else {
/* The key already exists, verify it. */
SilcUInt32 encpk_len;
/* Load the key file, try for both IP filename and hostname filename */
- if (!silc_pkcs_load_public_key(ipf, &local_pubkey) &&
- (!hostf || (!silc_pkcs_load_public_key(hostf, &local_pubkey)))) {
+ if (!silc_pkcs_load_public_key(ipf, SILC_PKCS_ANY, &local_pubkey) &&
+ (!hostf || (!silc_pkcs_load_public_key(hostf, SILC_PKCS_ANY,
+ &local_pubkey)))) {
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_RECEIVED,verify->entity_name ?
verify->entity_name : entity);
+ if (conn_type == SILC_CONN_CLIENT && name &&
+ silc_pubkey->identifier.realname)
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+ SILCTXT_PUBKEY_RECEIVED_CLIENT, name,
+ silc_pubkey->identifier.realname,
+ silc_pubkey->identifier.email ?
+ silc_pubkey->identifier.email : "");
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
format, 0, verify);
g_free(format);
silc_free(fingerprint);
+ silc_free(babbleprint);
+ silc_free(pk);
return;
}
/* Encode the key data */
- encpk = silc_pkcs_public_key_encode(local_pubkey, &encpk_len);
+ encpk = silc_pkcs_public_key_encode(NULL, local_pubkey, &encpk_len);
if (!encpk) {
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_RECEIVED,verify->entity_name ?
verify->entity_name : entity);
+ if (conn_type == SILC_CONN_CLIENT && name &&
+ silc_pubkey->identifier.realname)
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+ SILCTXT_PUBKEY_RECEIVED_CLIENT, name,
+ silc_pubkey->identifier.realname,
+ silc_pubkey->identifier.email ?
+ silc_pubkey->identifier.email : "");
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
format, 0, verify);
g_free(format);
silc_free(fingerprint);
+ silc_free(babbleprint);
+ silc_free(pk);
return;
}
+ silc_pkcs_public_key_free(local_pubkey);
/* Compare the keys */
if (memcmp(encpk, pk, encpk_len)) {
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_RECEIVED,verify->entity_name ?
verify->entity_name : entity);
+ if (conn_type == SILC_CONN_CLIENT && name &&
+ silc_pubkey->identifier.realname)
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+ SILCTXT_PUBKEY_RECEIVED_CLIENT, name,
+ silc_pubkey->identifier.realname,
+ silc_pubkey->identifier.email ?
+ silc_pubkey->identifier.email : "");
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
format, 0, verify);
g_free(format);
silc_free(fingerprint);
+ silc_free(babbleprint);
silc_free(encpk);
+ silc_free(pk);
return;
}
completion(TRUE, context);
silc_free(encpk);
silc_free(fingerprint);
+ silc_free(babbleprint);
silc_free(verify->filename);
silc_free(verify->entity);
silc_free(verify->entity_name);
silc_free(verify);
+ silc_free(pk);
}
}
typedef struct {
SilcGetAuthMeth completion;
void *context;
-} *InternalGetAuthMethod;
-
-/* Callback called when we've received the authentication method information
- from the server after we've requested it. This will get the authentication
- data from the user if needed. */
+} *GetAuthMethod;
-static void silc_get_auth_method_callback(SilcClient client,
- SilcClientConnection conn,
- SilcAuthMethod auth_meth,
- void *context)
+static void silc_get_auth_ask_passphrase(const unsigned char *passphrase,
+ SilcUInt32 passphrase_len,
+ void *context)
{
- InternalGetAuthMethod internal = (InternalGetAuthMethod)context;
-
- SILC_LOG_DEBUG(("Start"));
-
- switch (auth_meth) {
- case SILC_AUTH_NONE:
- /* No authentication required. */
- (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
- break;
- case SILC_AUTH_PASSWORD:
- {
- /* Check whether we find the password for this server in our
- configuration. If not, then don't provide so library will ask
- it from the user. */
- SERVER_SETUP_REC *setup = server_setup_find_port(conn->remote_host,
- conn->remote_port);
- if (!setup || !setup->password) {
- (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
- break;
- }
-
- (*internal->completion)(TRUE, auth_meth, setup->password,
- strlen(setup->password), internal->context);
- }
- break;
- case SILC_AUTH_PUBLIC_KEY:
- /* Do not get the authentication data now, the library will generate
- it using our default key, if we do not provide it here. */
- /* XXX In the future when we support multiple local keys and multiple
- local certificates we will need to ask from user which one to use. */
- (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
- break;
- }
-
- silc_free(internal);
+ GetAuthMethod a = context;
+ a->completion(passphrase ? SILC_AUTH_PASSWORD : SILC_AUTH_NONE,
+ passphrase, passphrase_len, a->context);
+ silc_free(a);
}
-/* Find authentication method and authentication data by hostname and
- port. The hostname may be IP address as well. The found authentication
- method and authentication data is returned to `auth_meth', `auth_data'
- and `auth_data_len'. The function returns TRUE if authentication method
- is found and FALSE if not. `conn' may be NULL. */
+/* Find authentication data by hostname and port. The hostname may be IP
+ address as well.*/
void silc_get_auth_method(SilcClient client, SilcClientConnection conn,
char *hostname, SilcUInt16 port,
+ SilcAuthMethod auth_meth,
SilcGetAuthMeth completion, void *context)
{
- InternalGetAuthMethod internal;
+ SERVER_SETUP_REC *setup;
SILC_LOG_DEBUG(("Start"));
- /* If we do not have this connection configured by the user in a
- configuration file then resolve the authentication method from the
- server for this session. */
- internal = silc_calloc(1, sizeof(*internal));
- internal->completion = completion;
- internal->context = context;
-
-#if 0
- silc_client_request_authentication_method(client, conn,
- silc_get_auth_method_callback,
- internal);
-#endif
+ if (auth_meth == SILC_AUTH_PUBLIC_KEY) {
+ /* Returning NULL will cause library to use our private key configured
+ for this connection */
+ completion(SILC_AUTH_PUBLIC_KEY, NULL, 0, context);
+ return;
+ }
+
+ /* Check whether we find the password for this server in our
+ configuration. If it's set, always send it server. */
+ setup = server_setup_find_port(hostname, port);
+ if (setup && setup->password) {
+ completion(SILC_AUTH_PASSWORD, setup->password, strlen(setup->password),
+ context);
+ return;
+ }
+
+ /* Didn't find password. If server wants it, ask it from user. */
+ if (auth_meth == SILC_AUTH_PASSWORD) {
+ GetAuthMethod a;
+ a = silc_calloc(1, sizeof(*a));
+ if (a) {
+ a->completion = completion;
+ a->context = context;
+ silc_ask_passphrase(client, conn, silc_get_auth_ask_passphrase, a);
+ return;
+ }
+ }
+
+ /* No authentication */
+ completion(SILC_AUTH_NONE, NULL, 0, context);
}
/* Asks whether the user would like to perform the key agreement protocol.
desired (application may start it later by calling the function
silc_client_perform_key_agreement). */
-bool silc_key_agreement(SilcClient client, SilcClientConnection conn,
+void silc_key_agreement(SilcClient client, SilcClientConnection conn,
SilcClientEntry client_entry, const char *hostname,
- SilcUInt16 port, SilcKeyAgreementCallback *completion,
- void **context)
+ SilcUInt16 protocol, SilcUInt16 port)
{
- char portstr[12];
+ char portstr[12], protostr[5];
SILC_LOG_DEBUG(("Start"));
/* We will just display the info on the screen and return FALSE and user
will have to start the key agreement with a command. */
- if (hostname)
+ if (hostname) {
snprintf(portstr, sizeof(portstr) - 1, "%d", port);
+ snprintf(protostr, sizeof(protostr) - 1, "%s", protocol == 1 ? "UDP" :
+ "TCP");
+ }
if (!hostname)
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
else
printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
SILCTXT_KEY_AGREEMENT_REQUEST_HOST,
- client_entry->nickname, hostname, portstr);
-
- *completion = NULL;
- *context = NULL;
-
- return FALSE;
+ client_entry->nickname, hostname, portstr, protostr);
}
/* Notifies application that file transfer protocol session is being
client_entry->nickname, hostname, portstr);
}
-/* Delivers SILC session detachment data indicated by `detach_data' to the
- application. If application has issued SILC_COMMAND_DETACH command
- the client session in the SILC network is not quit. The client remains
- in the network but is detached. The detachment data may be used later
- to resume the session in the SILC Network. The appliation is
- responsible of saving the `detach_data', to for example in a file.
-
- The detachment data can be given as argument to the functions
- silc_client_connect_to_server, or silc_client_add_connection when
- creating connection to remote server, inside SilcClientConnectionParams
- structure. If it is provided the client library will attempt to resume
- the session in the network. After the connection is created
- successfully, the application is responsible of setting the user
- interface for user into the same state it was before detaching (showing
- same channels, channel modes, etc). It can do this by fetching the
- information (like joined channels) from the client library. */
-
-void
-silc_detach(SilcClient client, SilcClientConnection conn,
- const unsigned char *detach_data, SilcUInt32 detach_data_len)
-{
- SILC_SERVER_REC *server = conn->context;
- char *file;
-
- /* Save the detachment data to file. */
-
- file = silc_get_session_filename(server);
- silc_file_writefile(file, detach_data, detach_data_len);
- silc_free(file);
-}
-
-/* Called to indicate the client library is running. */
-
-static void
-silc_running(SilcClient client, void *application)
-{
- SILC_LOG_DEBUG(("Client library is running"));
-}
-
/* SILC client operations */
SilcClientOperations ops = {
silc_say,
silc_ask_passphrase,
silc_key_agreement,
silc_ftp,
- silc_detach,
- silc_running,
};