Exemple #1
0
    virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage) {
        if (sMessage.Equals("DCC ", false, 4)) {
            CString sType = sMessage.Token(1);
            CString sFile = sMessage.Token(2);
            unsigned long uLongIP = sMessage.Token(3).ToULong();
            unsigned short uPort = sMessage.Token(4).ToUShort();
            unsigned long uFileSize = sMessage.Token(5).ToULong();
            CString sIP = GetLocalDCCIP();

            if (!UseClientIP()) {
                uLongIP = CUtils::GetLongIP(m_pClient->GetRemoteIP());
            }

            if (sType.Equals("CHAT")) {
                unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, "", true, this, "");
                if (uBNCPort) {
                    PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001");
                }
            } else if (sType.Equals("SEND")) {
                // DCC SEND readme.txt 403120438 5550 1104
                unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, sFile, false, this, "");
                if (uBNCPort) {
                    PutIRC("PRIVMSG " + sTarget + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001");
                }
            } else if (sType.Equals("RESUME")) {
                // PRIVMSG user :DCC RESUME "znc.o" 58810 151552
                unsigned short uResumePort = sMessage.Token(3).ToUShort();

                set<CSocket*>::const_iterator it;
                for (it = BeginSockets(); it != EndSockets(); ++it) {
                    CDCCBounce* pSock = (CDCCBounce*) *it;

                    if (pSock->GetLocalPort() == uResumePort) {
                        PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
                    }
                }
            } else if (sType.Equals("ACCEPT")) {
                // Need to lookup the connection by port, filter the port, and forward to the user

                set<CSocket*>::const_iterator it;
                for (it = BeginSockets(); it != EndSockets(); ++it) {
                    CDCCBounce* pSock = (CDCCBounce*) *it;
                    if (pSock->GetUserPort() == sMessage.Token(3).ToUShort()) {
                        PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
                    }
                }
            }

            return HALTCORE;
        }

        return CONTINUE;
    }
Exemple #2
0
    virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage) {
        if (sMessage.Equals("DCC ", false, 4) && m_pUser->IsUserAttached()) {
            // DCC CHAT chat 2453612361 44592
            CString sType = sMessage.Token(1);
            CString sFile = sMessage.Token(2);
            unsigned long uLongIP = sMessage.Token(3).ToULong();
            unsigned short uPort = sMessage.Token(4).ToUShort();
            unsigned long uFileSize = sMessage.Token(5).ToULong();

            if (sType.Equals("CHAT")) {
                CNick FromNick(Nick.GetNickMask());
                unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, this, CUtils::GetIP(uLongIP));
                if (uBNCPort) {
                    CString sIP = GetLocalDCCIP();
                    m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pUser->GetNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001");
                }
            } else if (sType.Equals("SEND")) {
                // DCC SEND readme.txt 403120438 5550 1104
                unsigned short uBNCPort = CDCCBounce::DCCRequest(Nick.GetNick(), uLongIP, uPort, sFile, false, this, CUtils::GetIP(uLongIP));
                if (uBNCPort) {
                    CString sIP = GetLocalDCCIP();
                    m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pUser->GetNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001");
                }
            } else if (sType.Equals("RESUME")) {
                // Need to lookup the connection by port, filter the port, and forward to the user
                unsigned short uResumePort = sMessage.Token(3).ToUShort();

                set<CSocket*>::const_iterator it;
                for (it = BeginSockets(); it != EndSockets(); ++it) {
                    CDCCBounce* pSock = (CDCCBounce*) *it;

                    if (pSock->GetLocalPort() == uResumePort) {
                        m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pClient->GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
                    }
                }
            } else if (sType.Equals("ACCEPT")) {
                // Need to lookup the connection by port, filter the port, and forward to the user
                set<CSocket*>::const_iterator it;
                for (it = BeginSockets(); it != EndSockets(); ++it) {
                    CDCCBounce* pSock = (CDCCBounce*) *it;

                    if (pSock->GetUserPort() == sMessage.Token(3).ToUShort()) {
                        m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pClient->GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
                    }
                }
            }

            return HALTCORE;
        }

        return CONTINUE;
    }
Exemple #3
0
	virtual void OnModCTCP(const CString& sMessage) {
		if (sMessage.Equals("DCC RESUME ", false, 11)) {
			CString sFile = sMessage.Token(2);
			unsigned short uResumePort = sMessage.Token(3).ToUShort();
			unsigned long uResumeSize = sMessage.Token(4).ToULong();

			set<CSocket*>::const_iterator it;
			for (it = BeginSockets(); it != EndSockets(); ++it) {
				CDCCSock* pSock = (CDCCSock*) *it;

				if (pSock->GetLocalPort() == uResumePort) {
					if (pSock->Seek(uResumeSize)) {
						PutModule("DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString(uResumeSize) + "]");
						PutUser(":*[email protected] PRIVMSG " + m_pUser->GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001");
					} else {
						PutModule("DCC -> [" + m_pUser->GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
					}
				}

			}
		} else if (sMessage.Equals("DCC SEND ", false, 9)) {
			CString sLocalFile = CDir::CheckPathPrefix(GetSavePath(), sMessage.Token(2));
			if (sLocalFile.empty()) {
				PutModule("Bad DCC file: " + sMessage.Token(2));
			}
			unsigned long uLongIP = sMessage.Token(3).ToULong();
			unsigned short uPort = sMessage.Token(4).ToUShort();
			unsigned long uFileSize = sMessage.Token(5).ToULong();
			GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize);
		}
	}
Exemple #4
0
EXTERN_C		/* GCC in C++ mode mangles the name, otherwise */
#endif
BOOL APIENTRY
DllMain(HANDLE hModule,		/* DLL module handle */
	DWORD fdwReason,	/* reason called */
	LPVOID lpvReserved)	/* reserved */
{ 
    switch (fdwReason) {
	/* The DLL is attaching to a process due to process
	 * initialization or a call to LoadLibrary.
	 */
    case DLL_PROCESS_ATTACH:
/* #define DEFAULT_BINMODE */
#ifdef DEFAULT_BINMODE
	setmode( fileno( stdin  ), O_BINARY );
	setmode( fileno( stdout ), O_BINARY );
	setmode( fileno( stderr ), O_BINARY );
	_fmode = O_BINARY;
#endif
	DisableThreadLibraryCalls((HMODULE)hModule);
	w32_perldll_handle = hModule;
	set_w32_module_name();
	break;

	/* The DLL is detaching from a process due to
	 * process termination or call to FreeLibrary.
	 */
    case DLL_PROCESS_DETACH:
        /* As long as we use TerminateProcess()/TerminateThread() etc. for mimicing kill()
           anything here had better be harmless if:
            A. Not called at all.
            B. Called after memory allocation for Heap has been forcibly removed by OS.
            PerlIO_cleanup() was done here but fails (B).
         */     
	EndSockets();
#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
	if (PL_curinterp)
	    FREE_THREAD_KEY;
#endif
	break;

	/* The attached process creates a new thread. */
    case DLL_THREAD_ATTACH:
	break;

	/* The thread of the attached process terminates. */
    case DLL_THREAD_DETACH:
	break;

    default:
	break;
    }
    return TRUE;
}
Exemple #5
0
    void ListDCCsCommand(const CString& sLine) {
        CTable Table;
        Table.AddColumn("Type");
        Table.AddColumn("State");
        Table.AddColumn("Speed");
        Table.AddColumn("Nick");
        Table.AddColumn("IP");
        Table.AddColumn("File");

        set<CSocket*>::const_iterator it;
        for (it = BeginSockets(); it != EndSockets(); ++it) {
            CDCCBounce* pSock = (CDCCBounce*) *it;
            CString sSockName = pSock->GetSockName();

            if (!(pSock->IsRemote())) {
                Table.AddRow();
                Table.SetCell("Nick", pSock->GetRemoteNick());
                Table.SetCell("IP", pSock->GetRemoteIP());

                if (pSock->IsChat()) {
                    Table.SetCell("Type", "Chat");
                } else {
                    Table.SetCell("Type", "Xfer");
                    Table.SetCell("File", pSock->GetFileName());
                }

                CString sState = "Waiting";
                if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) {
                    sState = "Halfway";
                    if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) {
                        sState = "Connected";
                    }
                }
                Table.SetCell("State", sState);
            }
        }

        if (PutModule(Table) == 0) {
            PutModule("You have no active DCCs.");
        }
    }
Exemple #6
0
	void ListTransfersCommand(const CString& sLine) {
		CTable Table;
		Table.AddColumn("Type");
		Table.AddColumn("State");
		Table.AddColumn("Speed");
		Table.AddColumn("Nick");
		Table.AddColumn("IP");
		Table.AddColumn("File");

		set<CSocket*>::const_iterator it;
		for (it = BeginSockets(); it != EndSockets(); ++it) {
			CDCCSock* pSock = (CDCCSock*) *it;

			Table.AddRow();
			Table.SetCell("Nick", pSock->GetRemoteNick());
			Table.SetCell("IP", pSock->GetRemoteIP());
			Table.SetCell("File", pSock->GetFileName());

			if (pSock->IsSend()) {
				Table.SetCell("Type", "Sending");
			} else {
				Table.SetCell("Type", "Getting");
			}

			if (pSock->GetType() == Csock::LISTENER) {
				Table.SetCell("State", "Waiting");
			} else {
				Table.SetCell("State", CString::ToPercent(pSock->GetProgress()));
				Table.SetCell("Speed", CString((int)(pSock->GetAvgRead() / 1024.0)) + " KiB/s");
			}
		}

		if (PutModule(Table) == 0) {
			PutModule("You have no active DCC transfers.");
		}
	}