示例#1
0
文件: fe-dcc.c 项目: svn2github/irssi
static void dcc_connected(DCC_REC *dcc)
{
	char *sender;

	g_return_if_fail(dcc != NULL);

	switch (dcc->type) {
	case DCC_TYPE_CHAT:
		sender = g_strconcat("=", dcc->nick, NULL);
		printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_CONNECTED,
			    dcc->nick, dcc->addrstr, dcc->port);
		if (autocreate_dccquery && query_find(NULL, sender) == NULL)
			irc_query_create(dcc->server, sender, TRUE);
		g_free(sender);
		break;
	case DCC_TYPE_SEND:
		printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_CONNECTED,
			    dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
		break;
	case DCC_TYPE_GET:
		printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_CONNECTED,
			    dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
		break;
	}
}
示例#2
0
文件: FiSH.c 项目: kelek-/FiSH-irssi
void DH1080_received(SERVER_REC * server, char *msg, char *nick, char *address,
		     char *target)
{
	int i;
	char hisPubKey[300], contactName[CONTACT_SIZE] =
	    "", encryptedKey[KEYBUF_SIZE] = "";

	if (ischannel(*target) || ischannel(*nick))
		return;		// no KeyXchange for channels...
	i = strlen(msg);
	if (i < 191 || i > 195)
		return;

	if (strncmp(msg, "DH1080_INIT ", 12) == 0) {
		strcpy(hisPubKey, msg + 12);
		if (strspn(hisPubKey, B64ABC) != strlen(hisPubKey))
			return;

		if (query_find(server, nick) == NULL) {	// query window not found, lets create one
			keyx_query_created = 1;
			irc_query_create(server->tag, nick, TRUE);
			keyx_query_created = 0;
		}

		printtext(server, nick, MSGLEVEL_CRAP,
			  "\002FiSH:\002 Received DH1080 public key from %s, sending mine...",
			  nick);

		DH1080_gen(g_myPrivKey, g_myPubKey);
		irc_send_cmdv((IRC_SERVER_REC *) server, "NOTICE %s :%s %s",
			      nick, "DH1080_FINISH", g_myPubKey);
	} else if (strncmp(msg, "DH1080_FINISH ", 14) == 0)
		strcpy(hisPubKey, msg + 14);
	else
		return;

	if (DH1080_comp(g_myPrivKey, hisPubKey) == 0)
		return;
	signal_stop();

	encrypt_key(hisPubKey, encryptedKey);
	ZeroMemory(hisPubKey, sizeof(hisPubKey));

	if (getIniSectionForContact(server, nick, contactName) == FALSE)
		return;

	if (setIniValue(contactName, "key", encryptedKey, iniPath) == -1) {
		ZeroMemory(encryptedKey, KEYBUF_SIZE);
		printtext(server, nick, MSGLEVEL_CRAP,
			  "\002FiSH ERROR:\002 Unable to write to blow.ini, probably out of space or permission denied.");
		return;
	}

	ZeroMemory(encryptedKey, KEYBUF_SIZE);

	printtext(server, nick, MSGLEVEL_CRAP,
		  "\002FiSH:\002 Key for %s successfully set!", nick);
}
示例#3
0
文件: fe-dcc-chat.c 项目: Adam-/irssi
static void dcc_connected(CHAT_DCC_REC *dcc)
{
	char *sender;

        if (!IS_DCC_CHAT(dcc)) return;

	sender = g_strconcat("=", dcc->id, NULL);
	printformat(dcc->server, NULL, MSGLEVEL_DCC,
		    IRCTXT_DCC_CHAT_CONNECTED,
		    dcc->id, dcc->addrstr, dcc->port);

	if (query_find(NULL, sender) == NULL) {
		int level = settings_get_level("autocreate_query_level");
		int autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0;

		if (!autocreate_dccquery)
			completion_last_message_add(sender);
		else
			irc_query_create(dcc->servertag, sender, TRUE);
	}
	g_free(sender);
}