Ejemplo n.º 1
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);
		}
	}
Ejemplo n.º 2
0
bool CUser::ResumeFile(unsigned short uPort, unsigned long uFileSize) {
	CSockManager& Manager = CZNC::Get().GetManager();

	for (unsigned int a = 0; a < Manager.size(); a++) {
		if (Manager[a]->GetSockName().Equals("DCC::LISTEN::", false, 13)) {
			CDCCSock* pSock = (CDCCSock*) Manager[a];

			if (pSock->GetLocalPort() == uPort) {
				if (pSock->Seek(uFileSize)) {
					PutModule(pSock->GetModuleName(), "DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString(uFileSize) + "]");
					return true;
				} else {
					return false;
				}
			}
		}
	}

	return false;
}
Ejemplo n.º 3
0
Archivo: dcc.cpp Proyecto: aszrul/znc
    void OnModCTCP(const CString& sMessage) override {
        if (sMessage.StartsWith("DCC RESUME ")) {
            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(
                            t_f("Attempting to resume send from position {1} "
                                "of file [{2}] for [{3}]")(
                                uResumeSize, pSock->GetFileName(),
                                pSock->GetRemoteNick()));
                        PutUser(":*[email protected] PRIVMSG " +
                                GetUser()->GetNick() + " :\001DCC ACCEPT " +
                                sFile + " " + CString(uResumePort) + " " +
                                CString(uResumeSize) + "\001");
                    } else {
                        PutModule(t_f(
                            "Couldn't resume file [{1}] for [{2}]: not sending "
                            "anything.")(sFile, GetUser()->GetNick()));
                    }
                }
            }
        } else if (sMessage.StartsWith("DCC SEND ")) {
            CString sLocalFile =
                CDir::CheckPathPrefix(GetSavePath(), sMessage.Token(2));
            if (sLocalFile.empty()) {
                PutModule(t_f("Bad DCC file: {1}")(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(GetClient()->GetNick(), CUtils::GetIP(uLongIP), uPort,
                    sLocalFile, uFileSize);
        }
    }