void encrypt_msg(SERVER_REC * server, char *target, char *msg, char *orig_target) { char bf_dest[800] = "", *plainMsg; char contactName[CONTACT_SIZE] = ""; if (IsNULLorEmpty(msg) || IsNULLorEmpty(target)) return; if (getIniSectionForContact(server, target, contactName) == FALSE) return; if (getContactKey(contactName, NULL) == FALSE) return; plainMsg = isPlainPrefix(msg); if (plainMsg) { signal_continue(4, server, target, plainMsg, orig_target); return; } // generally cut a message to a size of 512 byte, as everything above will never arrive complete anyway if (strlen(msg) > 512) msg[512] = '\0'; if (FiSH_encrypt(server, msg, target, bf_dest) == 1) { // message was encrypted bf_dest[512] = '\0'; signal_continue(4, server, target, bf_dest, orig_target); } }
/* * New command: /me+ <action message> */ void cmd_crypt_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { // New command: /me+ <action message> char bf_dest[1000]=""; const char *target; if (data==NULL || (strlen(data) < 2)) goto action_error; if (item!=NULL) target=window_item_get_target(item); else goto action_error; // generally refuse an action size of more than 512 byte, as everything above will never arrive complete anyway if (strlen(data) >= 512) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /me+ \002error\002: message argument exceeds buffer size!"); return; } if (FiSH_encrypt(server, (char *)data, target, bf_dest)==0) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /me+ \002error\002: Encryption disabled or no key found for %s.", target); return; } bf_dest[512]='\0'; irc_send_cmdv((IRC_SERVER_REC *)server, "PRIVMSG %s :\001ACTION %s\001\n", target, bf_dest); signal_emit("message irc own_action", 3, server, data, target); return; action_error: printtext(server, item!=NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 Usage: /me+ <action message>"); }
/* * New command: /notice+ <nick/#channel> <notice message> */ void cmd_crypt_notice(const char *data, SERVER_REC * server, WI_ITEM_REC * item) { char bf_dest[1000] = "", *msg; const char *target; void *free_arg = NULL; if (data == NULL || (strlen(data) < 3)) goto notice_error; if (!cmd_get_params(data, &free_arg, 1, &target)) goto notice_error; msg = strchr(data, ' '); if (IsNULLorEmpty(target) || IsNULLorEmpty(msg)) goto notice_error; msg++; // point to the notice message // generally refuse a notice size of more than 512 byte, as everything above will never arrive complete anyway if (strlen(msg) >= 512) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /notice+ \002error\002: message argument exceeds buffer size!"); return; } if (FiSH_encrypt(server, msg, target, bf_dest) == 0) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /notice+ \002error\002: Encryption disabled or no key found for %s.", target); return; } bf_dest[512] = '\0'; irc_send_cmdv((IRC_SERVER_REC *) server, "NOTICE %s :%s\n", target, bf_dest); signal_emit("message irc own_notice", 3, server, msg, target); cmd_params_free(free_arg); return; notice_error: if (free_arg) cmd_params_free(free_arg); printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 Usage: /notice+ <nick/#channel> <notice message>"); }
/* * Set encrypted topic for current channel, irssi syntax: /topic+ <your topic> */ void cmd_crypt_topic(const char *data, SERVER_REC * server, WI_ITEM_REC * item) { char bf_dest[1000] = ""; const char *target; if (data == 0 || *data == '\0') goto topic_error; if (item != NULL) target = window_item_get_target(item); else goto topic_error; if (!ischannel(*target)) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 Please change to the channel window where you want to set the topic!"); goto topic_error; } // generally refuse a topic size of more than 512 byte, as everything above will never arrive complete anyway if (strlen(data) >= 512) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /topic+ error: topic length exceeds buffer size!"); goto topic_error; } // encrypt a message (using key for target) if (FiSH_encrypt(server, (char *)data, target, bf_dest) == 0) { printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /topic+ error: Encryption disabled or no key found for %s.", target); goto topic_error; } bf_dest[512] = '\0'; irc_send_cmdv((IRC_SERVER_REC *) server, "TOPIC %s :%s\n", target, bf_dest); return; topic_error: printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002FiSH:\002 Usage: /topic+ <your new topic>"); }