mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
A few more refinements to TCP code, ready to integrate with "desperation" stuff and test.
This commit is contained in:
parent
a9a3705877
commit
288d73a4ad
1 changed files with 27 additions and 24 deletions
|
@ -439,10 +439,10 @@ public:
|
||||||
InetAddress from;
|
InetAddress from;
|
||||||
|
|
||||||
unsigned long plen = mlen; // payload length, modified if there's an IP header
|
unsigned long plen = mlen; // payload length, modified if there's an IP header
|
||||||
data += 5;
|
data += 5; // skip forward past pseudo-TLS junk and mlen
|
||||||
if (mlen == 4) {
|
if (plen == 4) {
|
||||||
// Hello message, which isn't sent by proxy and would be ignored by client
|
// Hello message, which isn't sent by proxy and would be ignored by client
|
||||||
} else if (mlen) {
|
} else if (plen) {
|
||||||
// Messages should contain IPv4 or IPv6 source IP address data
|
// Messages should contain IPv4 or IPv6 source IP address data
|
||||||
switch(data[0]) {
|
switch(data[0]) {
|
||||||
case 4: // IPv4
|
case 4: // IPv4
|
||||||
|
@ -450,6 +450,9 @@ public:
|
||||||
from.set((const void *)(data + 1),4,((((unsigned int)data[5]) & 0xff) << 8) | (((unsigned int)data[6]) & 0xff));
|
from.set((const void *)(data + 1),4,((((unsigned int)data[5]) & 0xff) << 8) | (((unsigned int)data[6]) & 0xff));
|
||||||
data += 7; // type + 4 byte IP + 2 byte port
|
data += 7; // type + 4 byte IP + 2 byte port
|
||||||
plen -= 7;
|
plen -= 7;
|
||||||
|
} else {
|
||||||
|
_phy.close(sock);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6: // IPv6
|
case 6: // IPv6
|
||||||
|
@ -457,19 +460,19 @@ public:
|
||||||
from.set((const void *)(data + 1),16,((((unsigned int)data[17]) & 0xff) << 8) | (((unsigned int)data[18]) & 0xff));
|
from.set((const void *)(data + 1),16,((((unsigned int)data[17]) & 0xff) << 8) | (((unsigned int)data[18]) & 0xff));
|
||||||
data += 19; // type + 16 byte IP + 2 byte port
|
data += 19; // type + 16 byte IP + 2 byte port
|
||||||
plen -= 19;
|
plen -= 19;
|
||||||
|
} else {
|
||||||
|
_phy.close(sock);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0: // none/omitted
|
case 0: // none/omitted
|
||||||
|
++data;
|
||||||
|
--plen;
|
||||||
break;
|
break;
|
||||||
default: // invalid
|
default: // invalid address type
|
||||||
_phy.close(sock);
|
_phy.close(sock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!from) { // missing IP header
|
|
||||||
_phy.close(sock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZT1_ResultCode rc = _node->processWirePacket(
|
ZT1_ResultCode rc = _node->processWirePacket(
|
||||||
OSUtils::now(),
|
OSUtils::now(),
|
||||||
|
@ -488,7 +491,7 @@ public:
|
||||||
_phy.close(sock);
|
_phy.close(sock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (tc->body.length() > (mlen + 5))
|
if (tc->body.length() > (mlen + 5))
|
||||||
tc->body = tc->body.substr(mlen + 5);
|
tc->body = tc->body.substr(mlen + 5);
|
||||||
else tc->body = "";
|
else tc->body = "";
|
||||||
|
|
Loading…
Add table
Reference in a new issue