Skip to content
Permalink
Browse files

Report non-ESTABLISHED sessions to a rumormill so these nodes will be…

… pinged
  • Loading branch information...
cjdelisle committed Jan 29, 2015
1 parent adc3132 commit 507223dac10690f562b91d8ec84ce2f7a41df5ad
Showing with 22 additions and 6 deletions.
  1. +2 −1 admin/angel/Core.c
  2. +15 −3 net/Ducttape.c
  3. +2 −1 net/Ducttape.h
  4. +2 −0 net/Ducttape_pvt.h
  5. +1 −1 test/TestFramework.c
@@ -426,7 +426,8 @@ void Core_init(struct Allocator* alloc,
alloc,
logger,
ipTun,
rand);
rand,
rumorMill);

struct SwitchPinger* sp =
SwitchPinger_new(&dt->switchPingerIf, eventBase, rand, logger, &addr, alloc);
@@ -35,6 +35,7 @@
#include "util/Checksum.h"
#include "util/version/Version.h"
#include "util/Assert.h"
#include "util/events/Timeout.h"
#include "tunnel/IpTunnel.h"
#include "util/events/Time.h"
#include "util/Defined.h"
@@ -1239,13 +1240,20 @@ static uint8_t incomingFromPinger(struct Message* message, struct Interface* ifa
static void checkStateOfSessions(void* vducttape)
{
struct Ducttape_pvt* ctx = Identity_check((struct Ducttape_pvt*) vducttape);
if (!ctx->sessionMill) { return; }
struct Allocator* alloc = Allocator_child(ctx->alloc);
struct SessionManager_HandleList* handles = SessionManager_getHandleList(ctx->sm, alloc);
for (int i = 0; i < handles->count; i++) {
for (int i = 0; i < (int)handles->count; i++) {
struct SessionManager_Session* sess =
SessionManager_sessionForHandle(handles->handles[i], ctx->sm);
if (sess->cryptoAuthState == CryptoAuth_ESTABLISHED) { continue; }

if (!sess->knownSwitchLabel) { continue; }
uint8_t* hpk = CryptoAuth_getHerPublicKey(sess->internal);
if (Bits_isZero(hpk, 32)) { continue; }
struct Address addr = { .path = sess->knownSwitchLabel };
Bits_memcpyConst(addr.key, hpk, 32);
Address_getPrefix(&addr);
RumorMill_addNode(ctx->sessionMill, &addr);
}
}

@@ -1257,14 +1265,16 @@ struct Ducttape* Ducttape_register(uint8_t privateKey[32],
struct Allocator* allocator,
struct Log* logger,
struct IpTunnel* ipTun,
struct Random* rand)
struct Random* rand,
struct RumorMill* sessionMill)
{
struct Ducttape_pvt* context = Allocator_calloc(allocator, sizeof(struct Ducttape_pvt), 1);
context->registry = registry;
context->router = router;
context->logger = logger;
context->eventBase = eventBase;
context->alloc = allocator;
context->sessionMill = sessionMill;
Bits_memcpyConst(&context->pub.magicInterface, (&(struct Interface) {
.sendMessage = magicInterfaceSendMessage,
.allocator = allocator
@@ -1316,6 +1326,8 @@ struct Ducttape* Ducttape_register(uint8_t privateKey[32],
.senderContext = context
}), sizeof(struct Interface));

Timeout_setInterval(checkStateOfSessions, context, 10000, eventBase, allocator);

return &context->pub;
}

@@ -42,7 +42,8 @@ struct Ducttape* Ducttape_register(uint8_t privateKey[32],
struct Allocator* allocator,
struct Log* logger,
struct IpTunnel* ipTun,
struct Random* rand);
struct Random* rand,
struct RumorMill* sessionMill);

/**
* Set the interface which the user will use to communicate with the network.
@@ -70,6 +70,8 @@ struct Ducttape_pvt

struct EventBase* eventBase;

struct RumorMill* sessionMill;

struct Log* logger;

/** For tunneling IPv4 and ICANN IPv6 packets. */
@@ -146,7 +146,7 @@ struct TestFramework* TestFramework_setUp(char* privateKey,

struct Ducttape* dt =
Ducttape_register((uint8_t*)privateKey, registry, router,
switchCore, base, allocator, logger, ipTun, rand);
switchCore, base, allocator, logger, ipTun, rand, rumorMill);

struct SwitchPinger* sp =
SwitchPinger_new(&dt->switchPingerIf, base, rand, logger, myAddress, allocator);

0 comments on commit 507223d

Please sign in to comment.
You can’t perform that action at this time.