mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-03-04 21:34:55 +00:00
Eliminate some more dead code. We may do path trust, but not like that.
This commit is contained in:
parent
883c84bdb9
commit
a994573a43
@ -424,15 +424,6 @@ enum ZT_VirtualNetworkConfigOperation
|
|||||||
ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY = 4
|
ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Local interface trust levels
|
|
||||||
*/
|
|
||||||
enum ZT_LocalInterfaceAddressTrust {
|
|
||||||
ZT_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL = 0,
|
|
||||||
ZT_LOCAL_INTERFACE_ADDRESS_TRUST_PRIVACY = 10,
|
|
||||||
ZT_LOCAL_INTERFACE_ADDRESS_TRUST_ULTIMATE = 20
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What trust hierarchy role does this peer have?
|
* What trust hierarchy role does this peer have?
|
||||||
*/
|
*/
|
||||||
@ -1337,11 +1328,6 @@ void ZT_Node_freeQueryResult(ZT_Node *node,void *qr);
|
|||||||
/**
|
/**
|
||||||
* Add a local interface address
|
* Add a local interface address
|
||||||
*
|
*
|
||||||
* Local interface addresses may be added if you want remote peers
|
|
||||||
* with whom you have a trust relatinship (e.g. common network membership)
|
|
||||||
* to receive information about these endpoints as potential endpoints for
|
|
||||||
* direct communication.
|
|
||||||
*
|
|
||||||
* Take care that these are never ZeroTier interface addresses, otherwise
|
* Take care that these are never ZeroTier interface addresses, otherwise
|
||||||
* strange things might happen or they simply won't work.
|
* strange things might happen or they simply won't work.
|
||||||
*
|
*
|
||||||
@ -1356,10 +1342,9 @@ void ZT_Node_freeQueryResult(ZT_Node *node,void *qr);
|
|||||||
* reject bad, empty, and unusable addresses.
|
* reject bad, empty, and unusable addresses.
|
||||||
*
|
*
|
||||||
* @param addr Local interface address
|
* @param addr Local interface address
|
||||||
* @param trust How much do you trust the local network under this interface?
|
|
||||||
* @return Boolean: non-zero if address was accepted and added
|
* @return Boolean: non-zero if address was accepted and added
|
||||||
*/
|
*/
|
||||||
int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr,enum ZT_LocalInterfaceAddressTrust trust);
|
int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear local interface addresses
|
* Clear local interface addresses
|
||||||
|
@ -499,7 +499,7 @@ void Node::freeQueryResult(void *qr)
|
|||||||
::free(qr);
|
::free(qr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::addLocalInterfaceAddress(const struct sockaddr_storage *addr,ZT_LocalInterfaceAddressTrust trust)
|
int Node::addLocalInterfaceAddress(const struct sockaddr_storage *addr)
|
||||||
{
|
{
|
||||||
if (Path::isAddressValidForPath(*(reinterpret_cast<const InetAddress *>(addr)))) {
|
if (Path::isAddressValidForPath(*(reinterpret_cast<const InetAddress *>(addr)))) {
|
||||||
Mutex::Lock _l(_directPaths_m);
|
Mutex::Lock _l(_directPaths_m);
|
||||||
@ -900,10 +900,10 @@ void ZT_Node_freeQueryResult(ZT_Node *node,void *qr)
|
|||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr,enum ZT_LocalInterfaceAddressTrust trust)
|
int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return reinterpret_cast<ZeroTier::Node *>(node)->addLocalInterfaceAddress(addr,trust);
|
return reinterpret_cast<ZeroTier::Node *>(node)->addLocalInterfaceAddress(addr);
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
ZT_VirtualNetworkConfig *networkConfig(uint64_t nwid) const;
|
ZT_VirtualNetworkConfig *networkConfig(uint64_t nwid) const;
|
||||||
ZT_VirtualNetworkList *networks() const;
|
ZT_VirtualNetworkList *networks() const;
|
||||||
void freeQueryResult(void *qr);
|
void freeQueryResult(void *qr);
|
||||||
int addLocalInterfaceAddress(const struct sockaddr_storage *addr,ZT_LocalInterfaceAddressTrust trust);
|
int addLocalInterfaceAddress(const struct sockaddr_storage *addr);
|
||||||
void clearLocalInterfaceAddresses();
|
void clearLocalInterfaceAddresses();
|
||||||
void setNetconfMaster(void *networkControllerInstance);
|
void setNetconfMaster(void *networkControllerInstance);
|
||||||
ZT_ResultCode circuitTestBegin(ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *));
|
ZT_ResultCode circuitTestBegin(ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *));
|
||||||
|
@ -79,18 +79,16 @@ public:
|
|||||||
_addr(),
|
_addr(),
|
||||||
_localAddress(),
|
_localAddress(),
|
||||||
_ipScope(InetAddress::IP_SCOPE_NONE),
|
_ipScope(InetAddress::IP_SCOPE_NONE),
|
||||||
_trust(TRUST_NORMAL),
|
|
||||||
_flags(0)
|
_flags(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Path(const InetAddress &localAddress,const InetAddress &addr,Trust trust) :
|
Path(const InetAddress &localAddress,const InetAddress &addr) :
|
||||||
_lastSend(0),
|
_lastSend(0),
|
||||||
_lastReceived(0),
|
_lastReceived(0),
|
||||||
_addr(addr),
|
_addr(addr),
|
||||||
_localAddress(localAddress),
|
_localAddress(localAddress),
|
||||||
_ipScope(addr.ipScope()),
|
_ipScope(addr.ipScope()),
|
||||||
_trust(trust),
|
|
||||||
_flags(0)
|
_flags(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -187,11 +185,6 @@ public:
|
|||||||
return ( ((int)_ipScope * 2) + ((_addr.ss_family == AF_INET6) ? 1 : 0) );
|
return ( ((int)_ipScope * 2) + ((_addr.ss_family == AF_INET6) ? 1 : 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Path trust level
|
|
||||||
*/
|
|
||||||
inline Trust trust() const throw() { return _trust; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if path is considered reliable (no NAT keepalives etc. are needed)
|
* @return True if path is considered reliable (no NAT keepalives etc. are needed)
|
||||||
*/
|
*/
|
||||||
@ -243,12 +236,11 @@ public:
|
|||||||
template<unsigned int C>
|
template<unsigned int C>
|
||||||
inline void serialize(Buffer<C> &b) const
|
inline void serialize(Buffer<C> &b) const
|
||||||
{
|
{
|
||||||
b.append((uint8_t)0); // version
|
b.append((uint8_t)1); // version
|
||||||
b.append((uint64_t)_lastSend);
|
b.append((uint64_t)_lastSend);
|
||||||
b.append((uint64_t)_lastReceived);
|
b.append((uint64_t)_lastReceived);
|
||||||
_addr.serialize(b);
|
_addr.serialize(b);
|
||||||
_localAddress.serialize(b);
|
_localAddress.serialize(b);
|
||||||
b.append((uint8_t)_trust);
|
|
||||||
b.append((uint16_t)_flags);
|
b.append((uint16_t)_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,14 +248,13 @@ public:
|
|||||||
inline unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
|
inline unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
|
||||||
{
|
{
|
||||||
unsigned int p = startAt;
|
unsigned int p = startAt;
|
||||||
if (b[p++] != 0)
|
if (b[p++] != 1)
|
||||||
throw std::invalid_argument("invalid serialized Path");
|
throw std::invalid_argument("invalid serialized Path");
|
||||||
_lastSend = b.template at<uint64_t>(p); p += 8;
|
_lastSend = b.template at<uint64_t>(p); p += 8;
|
||||||
_lastReceived = b.template at<uint64_t>(p); p += 8;
|
_lastReceived = b.template at<uint64_t>(p); p += 8;
|
||||||
p += _addr.deserialize(b,p);
|
p += _addr.deserialize(b,p);
|
||||||
p += _localAddress.deserialize(b,p);
|
p += _localAddress.deserialize(b,p);
|
||||||
_ipScope = _addr.ipScope();
|
_ipScope = _addr.ipScope();
|
||||||
_trust = (Path::Trust)b[p++];
|
|
||||||
_flags = b.template at<uint16_t>(p); p += 2;
|
_flags = b.template at<uint16_t>(p); p += 2;
|
||||||
return (p - startAt);
|
return (p - startAt);
|
||||||
}
|
}
|
||||||
@ -274,7 +265,6 @@ private:
|
|||||||
InetAddress _addr;
|
InetAddress _addr;
|
||||||
InetAddress _localAddress;
|
InetAddress _localAddress;
|
||||||
InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often
|
InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often
|
||||||
Trust _trust;
|
|
||||||
uint16_t _flags;
|
uint16_t _flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ void Peer::received(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slot) {
|
if (slot) {
|
||||||
*slot = Path(localAddr,remoteAddr,Path::TRUST_NORMAL);
|
*slot = Path(localAddr,remoteAddr);
|
||||||
slot->received(now);
|
slot->received(now);
|
||||||
_numPaths = np;
|
_numPaths = np;
|
||||||
pathIsConfirmed = true;
|
pathIsConfirmed = true;
|
||||||
|
@ -731,7 +731,7 @@ public:
|
|||||||
#ifdef ZT_USE_MINIUPNPC
|
#ifdef ZT_USE_MINIUPNPC
|
||||||
std::vector<InetAddress> upnpAddresses(_upnpClient->get());
|
std::vector<InetAddress> upnpAddresses(_upnpClient->get());
|
||||||
for(std::vector<InetAddress>::const_iterator ext(upnpAddresses.begin());ext!=upnpAddresses.end();++ext)
|
for(std::vector<InetAddress>::const_iterator ext(upnpAddresses.begin());ext!=upnpAddresses.end();++ext)
|
||||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)),ZT_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL);
|
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ifaddrs *ifatbl = (struct ifaddrs *)0;
|
struct ifaddrs *ifatbl = (struct ifaddrs *)0;
|
||||||
@ -749,7 +749,7 @@ public:
|
|||||||
if (!isZT) {
|
if (!isZT) {
|
||||||
InetAddress ip(ifa->ifa_addr);
|
InetAddress ip(ifa->ifa_addr);
|
||||||
ip.setPort(_port);
|
ip.setPort(_port);
|
||||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&ip),ZT_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL);
|
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&ip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifa = ifa->ifa_next;
|
ifa = ifa->ifa_next;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user