mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-07 13:31:45 -07:00
Add TCP channel support for supernode list, make Peer pick the first path if all paths are equally dead.
This commit is contained in:
parent
73c1d43f2f
commit
daaec84c6b
7 changed files with 46 additions and 38 deletions
|
@ -48,6 +48,9 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
// Uncomment to intentionally break UDP in order to test TCP fallback
|
||||
#define ZT_BREAK_UDP
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
UdpSocket::~UdpSocket()
|
||||
|
@ -66,6 +69,9 @@ bool UdpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen)
|
|||
|
||||
bool UdpSocket::sendWithHopLimit(const InetAddress &to,const void *msg,unsigned int msglen,int hopLimit)
|
||||
{
|
||||
#ifdef ZT_BREAK_UDP
|
||||
return true;
|
||||
#else
|
||||
if (hopLimit <= 0)
|
||||
hopLimit = 255;
|
||||
if (to.isV6()) {
|
||||
|
@ -87,6 +93,7 @@ bool UdpSocket::sendWithHopLimit(const InetAddress &to,const void *msg,unsigned
|
|||
return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool UdpSocket::notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManager *sm)
|
||||
|
@ -97,7 +104,9 @@ bool UdpSocket::notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManag
|
|||
int n = (int)recvfrom(_sock,(char *)(buf.data()),ZT_SOCKET_MAX_MESSAGE_LEN,0,from.saddr(),&salen);
|
||||
if (n > 0) {
|
||||
buf.setSize((unsigned int)n);
|
||||
#ifndef ZT_BREAK_UDP
|
||||
sm->handleReceivedPacket(self,from,buf);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue