예제 #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);
		}
	}
예제 #2
0
파일: User.cpp 프로젝트: bpcampbe/znc
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;
}
예제 #3
0
파일: dcc.cpp 프로젝트: 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);
        }
    }
예제 #4
0
파일: dcc.cpp 프로젝트: aszrul/znc
    void ListTransfersCommand(const CString& sLine) {
        CTable Table;
        Table.AddColumn(t_s("Type", "list"));
        Table.AddColumn(t_s("State", "list"));
        Table.AddColumn(t_s("Speed", "list"));
        Table.AddColumn(t_s("Nick", "list"));
        Table.AddColumn(t_s("IP", "list"));
        Table.AddColumn(t_s("File", "list"));

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

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

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

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

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