mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-31 22:40:48 +00:00
indent fix
This commit is contained in:
parent
fe3a84a422
commit
09fc9e4d0c
@ -1330,42 +1330,42 @@ public:
|
|||||||
froms = _udp[0].v4s;
|
froms = _udp[0].v4s;
|
||||||
|
|
||||||
#ifdef ZT_TCP_FALLBACK_RELAY
|
#ifdef ZT_TCP_FALLBACK_RELAY
|
||||||
// TCP fallback tunnel support, currently IPv4 only
|
// TCP fallback tunnel support, currently IPv4 only
|
||||||
if ((len >= 16)&&(reinterpret_cast<const InetAddress *>(addr)->ipScope() == InetAddress::IP_SCOPE_GLOBAL)) {
|
if ((len >= 16)&&(reinterpret_cast<const InetAddress *>(addr)->ipScope() == InetAddress::IP_SCOPE_GLOBAL)) {
|
||||||
// Engage TCP tunnel fallback if we haven't received anything valid from a global
|
// Engage TCP tunnel fallback if we haven't received anything valid from a global
|
||||||
// IP address in ZT_TCP_FALLBACK_AFTER milliseconds. If we do start getting
|
// IP address in ZT_TCP_FALLBACK_AFTER milliseconds. If we do start getting
|
||||||
// valid direct traffic we'll stop using it and close the socket after a while.
|
// valid direct traffic we'll stop using it and close the socket after a while.
|
||||||
const uint64_t now = OSUtils::now();
|
const uint64_t now = OSUtils::now();
|
||||||
if (((now - _lastDirectReceiveFromGlobal) > ZT_TCP_FALLBACK_AFTER)&&((now - _lastRestart) > ZT_TCP_FALLBACK_AFTER)) {
|
if (((now - _lastDirectReceiveFromGlobal) > ZT_TCP_FALLBACK_AFTER)&&((now - _lastRestart) > ZT_TCP_FALLBACK_AFTER)) {
|
||||||
if (_tcpFallbackTunnel) {
|
if (_tcpFallbackTunnel) {
|
||||||
Mutex::Lock _l(_tcpFallbackTunnel->writeBuf_m);
|
Mutex::Lock _l(_tcpFallbackTunnel->writeBuf_m);
|
||||||
if (!_tcpFallbackTunnel->writeBuf.length())
|
if (!_tcpFallbackTunnel->writeBuf.length())
|
||||||
_phy.setNotifyWritable(_tcpFallbackTunnel->sock,true);
|
_phy.setNotifyWritable(_tcpFallbackTunnel->sock,true);
|
||||||
unsigned long mlen = len + 7;
|
unsigned long mlen = len + 7;
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)0x17);
|
_tcpFallbackTunnel->writeBuf.push_back((char)0x17);
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)0x03);
|
_tcpFallbackTunnel->writeBuf.push_back((char)0x03);
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)0x03); // fake TLS 1.2 header
|
_tcpFallbackTunnel->writeBuf.push_back((char)0x03); // fake TLS 1.2 header
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)((mlen >> 8) & 0xff));
|
_tcpFallbackTunnel->writeBuf.push_back((char)((mlen >> 8) & 0xff));
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)(mlen & 0xff));
|
_tcpFallbackTunnel->writeBuf.push_back((char)(mlen & 0xff));
|
||||||
_tcpFallbackTunnel->writeBuf.push_back((char)4); // IPv4
|
_tcpFallbackTunnel->writeBuf.push_back((char)4); // IPv4
|
||||||
_tcpFallbackTunnel->writeBuf.append(reinterpret_cast<const char *>(reinterpret_cast<const void *>(&(reinterpret_cast<const struct sockaddr_in *>(addr)->sin_addr.s_addr))),4);
|
_tcpFallbackTunnel->writeBuf.append(reinterpret_cast<const char *>(reinterpret_cast<const void *>(&(reinterpret_cast<const struct sockaddr_in *>(addr)->sin_addr.s_addr))),4);
|
||||||
_tcpFallbackTunnel->writeBuf.append(reinterpret_cast<const char *>(reinterpret_cast<const void *>(&(reinterpret_cast<const struct sockaddr_in *>(addr)->sin_port))),2);
|
_tcpFallbackTunnel->writeBuf.append(reinterpret_cast<const char *>(reinterpret_cast<const void *>(&(reinterpret_cast<const struct sockaddr_in *>(addr)->sin_port))),2);
|
||||||
_tcpFallbackTunnel->writeBuf.append((const char *)data,len);
|
_tcpFallbackTunnel->writeBuf.append((const char *)data,len);
|
||||||
} else if (((now - _lastSendToGlobalV4) < ZT_TCP_FALLBACK_AFTER)&&((now - _lastSendToGlobalV4) > (ZT_PING_CHECK_INVERVAL / 2))) {
|
} else if (((now - _lastSendToGlobalV4) < ZT_TCP_FALLBACK_AFTER)&&((now - _lastSendToGlobalV4) > (ZT_PING_CHECK_INVERVAL / 2))) {
|
||||||
std::vector<InetAddress> tunnelIps(_tcpFallbackResolver.get());
|
std::vector<InetAddress> tunnelIps(_tcpFallbackResolver.get());
|
||||||
if (tunnelIps.empty()) {
|
if (tunnelIps.empty()) {
|
||||||
if (!_tcpFallbackResolver.running())
|
if (!_tcpFallbackResolver.running())
|
||||||
_tcpFallbackResolver.resolveNow();
|
_tcpFallbackResolver.resolveNow();
|
||||||
} else {
|
} else {
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
InetAddress addr(tunnelIps[(unsigned long)now % tunnelIps.size()]);
|
InetAddress addr(tunnelIps[(unsigned long)now % tunnelIps.size()]);
|
||||||
addr.setPort(ZT_TCP_FALLBACK_RELAY_PORT);
|
addr.setPort(ZT_TCP_FALLBACK_RELAY_PORT);
|
||||||
_phy.tcpConnect(reinterpret_cast<const struct sockaddr *>(&addr),connected);
|
_phy.tcpConnect(reinterpret_cast<const struct sockaddr *>(&addr),connected);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lastSendToGlobalV4 = now;
|
|
||||||
}
|
}
|
||||||
|
_lastSendToGlobalV4 = now;
|
||||||
|
}
|
||||||
#endif // ZT_TCP_FALLBACK_RELAY
|
#endif // ZT_TCP_FALLBACK_RELAY
|
||||||
} else if (addr->ss_family == AF_INET6) {
|
} else if (addr->ss_family == AF_INET6) {
|
||||||
if (reinterpret_cast<const struct sockaddr_in6 *>(localAddr)->sin6_port != 0) {
|
if (reinterpret_cast<const struct sockaddr_in6 *>(localAddr)->sin6_port != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user