|
@@ -100,6 +100,7 @@
|
|
#include <mutex>
|
|
#include <mutex>
|
|
#include <list>
|
|
#include <list>
|
|
#include <sstream>
|
|
#include <sstream>
|
|
|
|
+#include <iomanip>
|
|
|
|
|
|
#include "geoip-html.h"
|
|
#include "geoip-html.h"
|
|
|
|
|
|
@@ -895,16 +896,16 @@ int main(int argc,char **argv)
|
|
|
|
|
|
threads.push_back(std::thread([s6,s4]() {
|
|
threads.push_back(std::thread([s6,s4]() {
|
|
struct sockaddr_in6 in6;
|
|
struct sockaddr_in6 in6;
|
|
- Packet pkt;
|
|
|
|
- memset(&in6,0,sizeof(in6));
|
|
|
|
|
|
+ Packet *pkt = new Packet();
|
|
for(;;) {
|
|
for(;;) {
|
|
|
|
+ memset(&in6,0,sizeof(in6));
|
|
socklen_t sl = sizeof(in6);
|
|
socklen_t sl = sizeof(in6);
|
|
- const int pl = (int)recvfrom(s6,pkt.unsafeData(),pkt.capacity(),RECVFROM_FLAGS,(struct sockaddr *)&in6,&sl);
|
|
|
|
|
|
+ const int pl = (int)recvfrom(s6,pkt->unsafeData(),pkt->capacity(),RECVFROM_FLAGS,(struct sockaddr *)&in6,&sl);
|
|
if (pl > 0) {
|
|
if (pl > 0) {
|
|
- if (pl >= ZT_PROTO_MIN_FRAGMENT_LENGTH) {
|
|
|
|
|
|
+ if ((pl >= ZT_PROTO_MIN_FRAGMENT_LENGTH)&&(pl <= ZT_PROTO_MAX_PACKET_LENGTH)) {
|
|
try {
|
|
try {
|
|
- pkt.setSize((unsigned int)pl);
|
|
|
|
- handlePacket(s4,s6,reinterpret_cast<const InetAddress *>(&in6),pkt);
|
|
|
|
|
|
+ pkt->setSize((unsigned int)pl);
|
|
|
|
+ handlePacket(s4,s6,reinterpret_cast<const InetAddress *>(&in6),*pkt);
|
|
} catch (std::exception &exc) {
|
|
} catch (std::exception &exc) {
|
|
char ipstr[128];
|
|
char ipstr[128];
|
|
printf("WARNING: unexpected exception handling packet from %s: %s" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in6)->toString(ipstr),exc.what());
|
|
printf("WARNING: unexpected exception handling packet from %s: %s" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in6)->toString(ipstr),exc.what());
|
|
@@ -920,20 +921,21 @@ int main(int argc,char **argv)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ delete pkt;
|
|
}));
|
|
}));
|
|
|
|
|
|
threads.push_back(std::thread([s6,s4]() {
|
|
threads.push_back(std::thread([s6,s4]() {
|
|
struct sockaddr_in in4;
|
|
struct sockaddr_in in4;
|
|
- Packet pkt;
|
|
|
|
- memset(&in4,0,sizeof(in4));
|
|
|
|
|
|
+ Packet *pkt = new Packet();
|
|
for(;;) {
|
|
for(;;) {
|
|
|
|
+ memset(&in4,0,sizeof(in4));
|
|
socklen_t sl = sizeof(in4);
|
|
socklen_t sl = sizeof(in4);
|
|
- const int pl = (int)recvfrom(s4,pkt.unsafeData(),pkt.capacity(),RECVFROM_FLAGS,(struct sockaddr *)&in4,&sl);
|
|
|
|
|
|
+ const int pl = (int)recvfrom(s4,pkt->unsafeData(),pkt->capacity(),RECVFROM_FLAGS,(struct sockaddr *)&in4,&sl);
|
|
if (pl > 0) {
|
|
if (pl > 0) {
|
|
- if (pl >= ZT_PROTO_MIN_FRAGMENT_LENGTH) {
|
|
|
|
|
|
+ if ((pl >= ZT_PROTO_MIN_FRAGMENT_LENGTH)&&(pl <= ZT_PROTO_MAX_PACKET_LENGTH)) {
|
|
try {
|
|
try {
|
|
- pkt.setSize((unsigned int)pl);
|
|
|
|
- handlePacket(s4,s6,reinterpret_cast<const InetAddress *>(&in4),pkt);
|
|
|
|
|
|
+ pkt->setSize((unsigned int)pl);
|
|
|
|
+ handlePacket(s4,s6,reinterpret_cast<const InetAddress *>(&in4),*pkt);
|
|
} catch (std::exception &exc) {
|
|
} catch (std::exception &exc) {
|
|
char ipstr[128];
|
|
char ipstr[128];
|
|
printf("WARNING: unexpected exception handling packet from %s: %s" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in4)->toString(ipstr),exc.what());
|
|
printf("WARNING: unexpected exception handling packet from %s: %s" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in4)->toString(ipstr),exc.what());
|
|
@@ -949,6 +951,7 @@ int main(int argc,char **argv)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ delete pkt;
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
}
|