Пример #1
0
Файл: dcc.cpp Проект: aszrul/znc
    bool GetFile(const CString& sRemoteNick, const CString& sRemoteIP,
                 unsigned short uRemotePort, const CString& sFileName,
                 unsigned long uFileSize) {
        if (CFile::Exists(sFileName)) {
            PutModule(t_f("Receiving [{1}] from [{2}]: File already exists.")(
                sFileName, sRemoteNick));
            return false;
        }

        CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sRemoteIP,
                                       uRemotePort, sFileName, uFileSize);

        if (!pSock->OpenFile()) {
            delete pSock;
            return false;
        }

        CZNC::Get().GetManager().Connect(sRemoteIP, uRemotePort,
                                         "DCC::GET::" + sRemoteNick, 60, false,
                                         GetUser()->GetLocalDCCIP(), pSock);

        PutModule(
            t_f("Attempting to connect to [{1} {2}] in order to download [{3}] "
                "from [{4}].")(sRemoteIP, uRemotePort, sFileName, sRemoteNick));
        return true;
    }
Пример #2
0
Файл: dcc.cpp Проект: aszrul/znc
    bool SendFile(const CString& sRemoteNick, const CString& sFileName) {
        CString sFullPath = CDir::ChangeDir(GetSavePath(), sFileName,
                                            CZNC::Get().GetHomePath());
        CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sFullPath);

        CFile* pFile = pSock->OpenFile(false);

        if (!pFile) {
            delete pSock;
            return false;
        }

        CString sLocalDCCIP = GetUser()->GetLocalDCCIP();
        unsigned short uPort = CZNC::Get().GetManager().ListenRand(
            "DCC::LISTEN::" + sRemoteNick, sLocalDCCIP, false, SOMAXCONN, pSock,
            120);

        if (GetUser()->GetNick().Equals(sRemoteNick)) {
            PutUser(":*[email protected] PRIVMSG " + sRemoteNick +
                    " :\001DCC SEND " + pFile->GetShortName() + " " +
                    CString(CUtils::GetLongIP(sLocalDCCIP)) + " " +
                    CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
        } else {
            PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " +
                   pFile->GetShortName() + " " +
                   CString(CUtils::GetLongIP(sLocalDCCIP)) + " " +
                   CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
        }

        PutModule(t_f("Attempting to send [{1}] to [{2}].")(
            pFile->GetShortName(), sRemoteNick));
        return true;
    }
Пример #3
0
Файл: dcc.cpp Проект: johnfb/znc
	bool GetFile(const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sFileName, unsigned long uFileSize) {
		if (CFile::Exists(sFileName)) {
			PutModule("DCC <- [" + sRemoteNick + "][" + sFileName + "] - File already exists.");
			return false;
		}

		CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sRemoteIP, uRemotePort, sFileName, uFileSize);

		if (!pSock->OpenFile()) {
			delete pSock;
			return false;
		}

		CZNC::Get().GetManager().Connect(sRemoteIP, uRemotePort, "DCC::GET::" + sRemoteNick, 60, false, m_pUser->GetLocalDCCIP(), pSock);

		PutModule("DCC <- [" + sRemoteNick + "][" + sFileName + "] - Attempting to connect to [" + sRemoteIP + "]");
		return true;
	}
Пример #4
0
bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const CString& sModuleName) {
	CString sFullPath = CDir::ChangeDir(GetDLPath(), sFileName, CZNC::Get().GetHomePath());
	CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sFullPath, sModuleName);

	CFile* pFile = pSock->OpenFile(false);

	if (!pFile) {
		delete pSock;
		return false;
	}

	unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, GetLocalDCCIP(), false, SOMAXCONN, pSock, 120);

	if (GetNick().Equals(sRemoteNick)) {
		PutUser(":" + GetStatusPrefix() + "[email protected] PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " "
				+ CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
	} else {
		PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " "
			    + CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
	}

	PutModule(sModuleName, "DCC -> [" + sRemoteNick + "][" + pFile->GetShortName() + "] - Attempting Send.");
	return true;
}