• R/O
  • HTTP
  • SSH
  • HTTPS

PeerCastIM: Commit


Commit MetaInfo

Revision9789c358a97aa8215e227aa3a7f45afcecdc1674 (tree)
Time2009-05-23 22:51:47
Authoreru <eru01@user...>
Commitereru

Log Message

IM0034

Change Summary

Incremental Difference

--- a/PeerCast.root/PeerCast/core/common/pcp.cpp
+++ b/PeerCast.root/PeerCast/core/common/pcp.cpp
@@ -25,6 +25,7 @@
2525 #define DEBUG_NEW new(__FILE__, __LINE__)
2626 #define new DEBUG_NEW
2727 #endif
28+#include <ctime>
2829
2930 // ------------------------------------------
3031 void PCPStream::init(GnuID &rid)
@@ -802,6 +803,22 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
802803 char tmp[64];
803804 bcs.chanID.toStr(tmp);
804805
806+ // Broadcast flood
807+ if (servMgr->lastPCPFromID.isSame(fromID)
808+ && time(NULL) - servMgr->lastPCPBcstTime < 3)
809+ {
810+ memcpy(servMgr->lastPCPFromID.id, fromID.id, 16);
811+ servMgr->lastPCPBcstTime = time(NULL);
812+ LOG_DEBUG("PCP bcst reject: group=%d, hops=%d, ver=%d(%c%c%04d), from=%s, dest=%s ttl=%d",
813+ bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,bcs.ttl);
814+
815+ return r;
816+ }
817+ memcpy(servMgr->lastPCPFromID.id, fromID.id, 16);
818+ servMgr->lastPCPBcstTime = time(NULL);
819+
820+ servMgr->lastPCPFromID.toStr(destStr);
821+
805822 // LOG_DEBUG(tmp);
806823
807824 if (ver_ex_number){
--- a/PeerCast.root/PeerCast/core/common/pcp.h
+++ b/PeerCast.root/PeerCast/core/common/pcp.h
@@ -267,7 +267,6 @@ public:
267267 //int error;
268268 GnuIDList routeList;
269269 GnuID remoteID;
270-
271270 };
272271
273272 #endif
--- a/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -449,6 +449,10 @@ public:
449449 bcstClap = 0x00000001
450450 };
451451
452+ // PCP broadcast flood
453+ GnuID lastPCPFromID;
454+ time_t lastPCPBcstTime;
455+
452456 private:
453457 FW_STATE firewalled;
454458 };
--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // PP
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 33;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0033)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0033)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 34;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0034)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0034)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp
@@ -25,6 +25,7 @@
2525 #define DEBUG_NEW new(__FILE__, __LINE__)
2626 #define new DEBUG_NEW
2727 #endif
28+#include <ctime>
2829
2930 // ------------------------------------------
3031 void PCPStream::init(GnuID &rid)
@@ -802,6 +803,22 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
802803 char tmp[64];
803804 bcs.chanID.toStr(tmp);
804805
806+ // Broadcast flood
807+ if (servMgr->lastPCPFromID.isSame(fromID)
808+ && time(NULL) - servMgr->lastPCPBcstTime < 3)
809+ {
810+ memcpy(servMgr->lastPCPFromID.id, fromID.id, 16);
811+ servMgr->lastPCPBcstTime = time(NULL);
812+ LOG_DEBUG("PCP bcst reject: group=%d, hops=%d, ver=%d(%c%c%04d), from=%s, dest=%s ttl=%d",
813+ bcs.group,bcs.numHops,ver,ver_ex_prefix[0],ver_ex_prefix[1],ver_ex_number,fromStr,destStr,bcs.ttl);
814+
815+ return r;
816+ }
817+ memcpy(servMgr->lastPCPFromID.id, fromID.id, 16);
818+ servMgr->lastPCPBcstTime = time(NULL);
819+
820+ servMgr->lastPCPFromID.toStr(destStr);
821+
805822 // LOG_DEBUG(tmp);
806823
807824 if (ver_ex_number){
--- a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.h
@@ -267,7 +267,6 @@ public:
267267 //int error;
268268 GnuIDList routeList;
269269 GnuID remoteID;
270-
271270 };
272271
273272 #endif
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -449,6 +449,10 @@ public:
449449 bcstClap = 0x00000001
450450 };
451451
452+ // PCP broadcast flood
453+ GnuID lastPCPFromID;
454+ time_t lastPCPBcstTime;
455+
452456 private:
453457 FW_STATE firewalled;
454458 };
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // PP
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 33;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0033)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0033)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 34;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0034)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0034)";
5050 #endif
5151
5252 // ------------------------------------------------
Show on old repository browser