Permalink
Browse files

Migrate dcc bouncing to its own module

  • Loading branch information...
Kyle Fuller
Kyle Fuller committed Apr 2, 2011
1 parent 0b360c0 commit 8f508cb4a5142e65301daee19789a459605992a5
Showing with 482 additions and 529 deletions.
  1. +6 −91 Client.cpp
  2. +0 −42 ClientCommand.cpp
  3. +0 −213 DCCBounce.cpp
  4. +0 −77 DCCBounce.h
  5. +0 −48 IRCSock.cpp
  6. +1 −1 Makefile.in
  7. +20 −15 User.cpp
  8. +0 −10 User.h
  9. +0 −16 modules/admin.cpp
  10. +455 −0 modules/bouncedcc.cpp
  11. +0 −2 modules/modperl/modperl.i
  12. +0 −2 modules/modpython/modpython.i
  13. +0 −12 modules/webadmin.cpp
View
@@ -8,7 +8,6 @@
#include "Client.h"
#include "Chan.h"
-#include "DCCBounce.h"
#include "FileUtils.h"
#include "IRCSock.h"
#include "User.h"
@@ -315,14 +314,6 @@ void CClient::ReadLine(const CString& sData) {
return;
}
- // No idea what this is supposed to do, but it doesn't seem to
- // make sense. Comment this out and wait for complaints.
-#if 0
- if (sMsg.WildCmp("DCC * (*)")) {
- sMsg = "DCC " + sLine.Token(3) + " (" + ((GetIRCSock()) ? GetIRCSock()->GetLocalIP() : GetLocalIP()) + ")";
- }
-#endif
-
if (sMsg.WildCmp("\001*\001")) {
CString sCTCP = sMsg;
sCTCP.LeftChomp();
@@ -377,95 +368,19 @@ void CClient::ReadLine(const CString& sData) {
sCTCP.LeftChomp();
sCTCP.RightChomp();
- if (sCTCP.Equals("DCC ", false, 4) && m_pUser->BounceDCCs()) {
- CString sType = sCTCP.Token(1);
- CString sFile = sCTCP.Token(2);
- unsigned long uLongIP = sCTCP.Token(3).ToULong();
- unsigned short uPort = sCTCP.Token(4).ToUShort();
- unsigned long uFileSize = sCTCP.Token(5).ToULong();
- CString sIP = m_pUser->GetLocalDCCIP();
-
- if (!m_pUser->UseClientIP()) {
- uLongIP = CUtils::GetLongIP(GetRemoteIP());
- }
-
- if (sType.Equals("CHAT")) {
- if (!sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
- unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, "", true, m_pUser, "");
- 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
-
- if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
- if (sTarget.Equals("status")) {
- CString sPath = m_pUser->GetDLPath();
- if (!CFile::Exists(sPath)) {
- PutStatus("Could not create [" + sPath + "] directory.");
- return;
- } else if (!CFile::IsDir(sPath)) {
- PutStatus("Error: [" + sPath + "] is not a directory.");
- return;
- }
-
- CString sAbsolutePath = CDir::CheckPathPrefix(sPath, sFile);
-
- if (sAbsolutePath.empty()) {
- PutStatus("Illegal path.");
- return;
- }
-
- m_pUser->GetFile(GetNick(), CUtils::GetIP(uLongIP), uPort, sAbsolutePath, uFileSize);
- }
- } else {
- unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, sFile, false, m_pUser, "");
- 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
+ if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
+ if (sCTCP.Equals("DCC RESUME ", false, 11)) {
+ CString sFile = sCTCP.Token(2);
unsigned short uResumePort = sCTCP.Token(3).ToUShort();
unsigned long uResumeSize = sCTCP.Token(4).ToULong();
- // Need to lookup the connection by port, filter the port, and forward to the user
- CString sStatusPrefix = m_pUser->GetStatusPrefix();
- if (sTarget.Equals(sStatusPrefix, false, sStatusPrefix.length())) {
- if (m_pUser->ResumeFile(uResumePort, uResumeSize)) {
- PutClient(":" + sTarget + "!znc@znc.in PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001");
- } else {
- PutStatus("DCC -> [" + GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
- }
+ if (m_pUser->ResumeFile(uResumePort, uResumeSize)) {
+ PutClient(":" + sTarget + "!znc@znc.in PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001");
} else {
- CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(uResumePort);
- if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) {
- PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001");
- }
- }
- } else if (sType.Equals("ACCEPT")) {
- CString sStatusPrefix = m_pUser->GetStatusPrefix();
- if (!sTarget.Equals(sStatusPrefix, false, sStatusPrefix.length())) {
- // Need to lookup the connection by port, filter the port, and forward to the user
- CSockManager& Manager = CZNC::Get().GetManager();
-
- for (unsigned int a = 0; a < Manager.size(); a++) {
- CDCCBounce* pSock = (CDCCBounce*) Manager[a];
-
- if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) {
- if (pSock->GetUserPort() == sCTCP.Token(3).ToUShort()) {
- PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001");
- }
- }
- }
+ PutStatus("DCC -> [" + GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
}
}
- return;
- }
-
- if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
if (sTarget.Equals("status")) {
StatusCTCP(sCTCP);
} else {
View
@@ -8,7 +8,6 @@
#include "Client.h"
#include "Chan.h"
-#include "DCCBounce.h"
#include "DCCSock.h"
#include "FileUtils.h"
#include "IRCSock.h"
@@ -522,14 +521,6 @@ void CClient::UserCommand(CString& sLine) {
CString sSockName = Manager[a]->GetSockName();
if (sSockName.TrimPrefix("DCC::")) {
- if (sSockName.Equals("XFER::REMOTE::", false, 14)) {
- continue;
- }
-
- if (sSockName.Equals("CHAT::REMOTE::", false, 14)) {
- continue;
- }
-
if (sSockName.Equals("SEND", false, 4)) {
CDCCSock* pSock = (CDCCSock*) Manager[a];
@@ -559,39 +550,6 @@ void CClient::UserCommand(CString& sLine) {
Table.SetCell("Nick", pSock->GetRemoteNick());
Table.SetCell("IP", pSock->GetRemoteIP());
Table.SetCell("File", pSock->GetFileName());
- } else if (sSockName.Equals("XFER::LOCAL", false, 11)) {
- CDCCBounce* pSock = (CDCCBounce*) Manager[a];
-
- CString sState = "Waiting";
- if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) {
- sState = "Halfway";
- if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) {
- sState = "Connected";
- }
- }
-
- Table.AddRow();
- Table.SetCell("Type", "Xfer");
- Table.SetCell("State", sState);
- Table.SetCell("Nick", pSock->GetRemoteNick());
- Table.SetCell("IP", pSock->GetRemoteIP());
- Table.SetCell("File", pSock->GetFileName());
- } else if (sSockName.Equals("CHAT::LOCAL", false, 11)) {
- CDCCBounce* pSock = (CDCCBounce*) Manager[a];
-
- CString sState = "Waiting";
- if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) {
- sState = "Halfway";
- if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) {
- sState = "Connected";
- }
- }
-
- Table.AddRow();
- Table.SetCell("Type", "Chat");
- Table.SetCell("State", sState);
- Table.SetCell("Nick", pSock->GetRemoteNick());
- Table.SetCell("IP", pSock->GetRemoteIP());
}
}
}
Oops, something went wrong.

0 comments on commit 8f508cb

Please sign in to comment.