mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-20 17:52:46 +00:00
Send initial CIRCUIT_TEST packet.
This commit is contained in:
parent
d3f29d09e8
commit
3593fb3462
@ -988,7 +988,7 @@ bool IncomingPacket::_doCIRCUIT_TEST(const RuntimeEnvironment *RR,const SharedPt
|
||||
SharedPtr<Network> nw(RR->node->network(originatorCredentialNetworkId));
|
||||
if (nw) {
|
||||
originatorCredentialNetworkConfig = nw->config2();
|
||||
if ( (originatorCredentialNetworkConfig) && (originatorCredentialNetworkConfig->isPublic()||((originatorCredentialNetworkConfig->com())&&(previousHopCom)&&(originatorCredentialNetworkConfig->com().agreesWith(previousHopCom)))) ) {
|
||||
if ( (originatorCredentialNetworkConfig) && ((originatorCredentialNetworkConfig->isPublic())||(peer->address() == originatorAddress)||((originatorCredentialNetworkConfig->com())&&(previousHopCom)&&(originatorCredentialNetworkConfig->com().agreesWith(previousHopCom)))) ) {
|
||||
TRACE("CIRCUIT_TEST %.16llx received from hop %s(%s) and originator %s with valid network ID credential %.16llx (verified from originator and next hop)",testId,source().toString().c_str(),_remoteAddress.toString().c_str(),originatorAddress.toString().c_str(),originatorCredentialNetworkId);
|
||||
} else {
|
||||
TRACE("dropped CIRCUIT_TEST from %s(%s): originator %s specified network ID %.16llx as credential, and previous hop %s did not supply a valid COM",source().toString().c_str(),_remoteAddress.toString().c_str(),originatorAddress.toString().c_str(),originatorCredentialNetworkId,peer->address().toString().c_str());
|
||||
|
@ -466,12 +466,48 @@ void Node::setNetconfMaster(void *networkControllerInstance)
|
||||
|
||||
ZT_ResultCode Node::circuitTestBegin(ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *))
|
||||
{
|
||||
if (test->hopCount > 0) {
|
||||
try {
|
||||
Packet outp(Address(),RR->identity.address(),Packet::VERB_CIRCUIT_TEST);
|
||||
RR->identity.address().appendTo(outp);
|
||||
outp.append((uint16_t)((test->reportAtEveryHop != 0) ? 0x03 : 0x02));
|
||||
outp.append((uint64_t)test->timestamp);
|
||||
outp.append((uint64_t)test->testId);
|
||||
outp.append((uint16_t)0); // originator credential length, updated later
|
||||
if (test->credentialNetworkId) {
|
||||
outp.append((uint8_t)0x01);
|
||||
outp.append((uint64_t)test->credentialNetworkId);
|
||||
outp.setAt<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 23,(uint16_t)9);
|
||||
}
|
||||
outp.append((uint16_t)0);
|
||||
C25519::Signature sig(RR->identity.sign(reinterpret_cast<const char *>(outp.data()) + ZT_PACKET_IDX_PAYLOAD,outp.size() - ZT_PACKET_IDX_PAYLOAD));
|
||||
outp.append((uint16_t)sig.size());
|
||||
outp.append(sig.data,sig.size());
|
||||
outp.append((uint16_t)0); // originator doesn't need an extra credential, since it's the originator
|
||||
for(unsigned int h=1;h<test->hopCount;++h) {
|
||||
outp.append((uint8_t)0);
|
||||
outp.append((uint8_t)(test->hops[h].breadth & 0xff));
|
||||
for(unsigned int a=0;a<test->hops[h].breadth;++a)
|
||||
Address(test->hops[h].addresses[a]).appendTo(outp);
|
||||
}
|
||||
|
||||
for(unsigned int a=0;a<test->hops[0].breadth;++a) {
|
||||
outp.newInitializationVector();
|
||||
outp.setDestination(Address(test->hops[0].addresses[a]));
|
||||
RR->sw->send(outp,true,test->credentialNetworkId);
|
||||
}
|
||||
} catch ( ... ) {
|
||||
return ZT_RESULT_FATAL_ERROR_INTERNAL; // probably indicates FIFO too big for packet
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
test->_internalPtr = reinterpret_cast<void *>(reportCallback);
|
||||
Mutex::Lock _l(_circuitTests_m);
|
||||
if (std::find(_circuitTests.begin(),_circuitTests.end(),test) == _circuitTests.end())
|
||||
_circuitTests.push_back(test);
|
||||
}
|
||||
|
||||
return ZT_RESULT_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user