#define MODULE_NAME "rfish" #include #include #include #include #include #include #include "rfish.h" void cmd_crypt_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { const char *target; int target_type = SEND_TARGET_NICK; if (data == NULL || (strlen(data) < 2)) goto action_error; if (item != NULL) target = window_item_get_target(item); else goto action_error; target_type = server_ischannel(server, target) ? SEND_TARGET_CHANNEL : SEND_TARGET_NICK; const uint8_t key[] = "chaveULTRAgulosa"; uintptr_t key_len = sizeof(key) - 1; uintptr_t input_len = strlen(data); const uint8_t *input_buffer = (const uint8_t *)malloc(input_len); if (!input_buffer) { printtext(server, target, MSGLEVEL_CRAP, "Memory allocation failed!"); return; } memcpy((void *)input_buffer, (const void *)data, input_len); char *encrypted = encrypt_cbc(key, key_len, input_buffer, input_len); if (encrypted) { signal_emit("server sendmsg", 4, server, target, encrypted); signal_emit(target_type == SEND_TARGET_CHANNEL ? "message own_public" : "message own_private", 4, server, encrypted, target, target); free(encrypted); } else { printtext(server, target, MSGLEVEL_CRAP, "Encryption failed!"); } free((void *)input_buffer); return; action_error: printtext(server, item != NULL ? window_item_get_target(item) : NULL, MSGLEVEL_CRAP, "\002rFiSH:\002 Usage: /rf "); } void rfish_init(void) { command_bind("rf", NULL, (SIGNAL_FUNC) cmd_crypt_action); module_register("rfish", "core"); } void rfish_deinit(void) { command_unbind("rf", (SIGNAL_FUNC) cmd_crypt_action); } #ifdef IRSSI_ABI_VERSION void rfish_abicheck(int *version) { *version = IRSSI_ABI_VERSION; } #endif