make format

pull/5/head
Jeff Becker 6 years ago
parent 64d12086c9
commit 7d9bffdf9c
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -24,8 +24,8 @@ handle_signal(int sig)
#include "buffer.hpp"
#include "crypto.hpp"
#include "fs.hpp"
#include "router.hpp"
#include "net.hpp"
#include "router.hpp"
bool
printNode(struct llarp_nodedb_iter *iter)
@ -41,13 +41,15 @@ printNode(struct llarp_nodedb_iter *iter)
// fwd declr
struct check_online_request;
void HandleDHTLocate(llarp_router_lookup_job *job)
void
HandleDHTLocate(llarp_router_lookup_job *job)
{
llarp::Info("DHT result: ", job->found ? "found" : "not found");
// save to nodedb?
}
bool aiLister(struct llarp_ai_list_iter *request, struct llarp_ai *addr)
bool
aiLister(struct llarp_ai_list_iter *request, struct llarp_ai *addr)
{
static size_t count = 0;
count++;
@ -168,7 +170,8 @@ main(int argc, char *argv[])
return 0;
}
printf("parsed options\n");
if(!genMode && !updMode && !listMode && !importMode && !exportMode && !locateMode && !localMode)
if(!genMode && !updMode && !listMode && !importMode && !exportMode
&& !locateMode && !localMode)
{
llarp::Error("I don't know what to do, no generate or update parameter\n");
return 0;

@ -316,7 +316,7 @@ the validity of the proof of work is that given
h = HS(BE(w))
h has log_e(y) prefix of 0x00
h has log_e(y) prefixed bytes being 0x00
this proof of work requirement is subject to change

@ -57,7 +57,8 @@ struct check_online_request;
/// check_online_request hook definition
typedef void (*check_online_request_hook_func)(struct check_online_request *);
struct check_online_request {
struct check_online_request
{
struct llarp_main *ptr;
struct llarp_router_lookup_job *job;
bool online;

@ -32,7 +32,8 @@ namespace llarp
Put(const T& i)
{
std::unique_lock< std::mutex > lock(m_QueueMutex);
//llarp::Info("CoDelQueue::Put - adding item, queue now has ", m_Queue.size(), " items at ", getTime(*item));
// llarp::Info("CoDelQueue::Put - adding item, queue now has ",
// m_Queue.size(), " items at ", getTime(*item));
PutTime()(i);
m_Queue.push(i);
if(firstPut == 0)
@ -56,7 +57,8 @@ namespace llarp
lowest = std::min(dlt, lowest);
if(m_Queue.size() == 1)
{
//llarp::Info("CoDelQueue::Process - single item: lowest ", lowest, " dropMs: ", dropMs);
// llarp::Info("CoDelQueue::Process - single item: lowest ", lowest,
// " dropMs: ", dropMs);
if(lowest > dropMs)
{
// drop

@ -2,8 +2,8 @@
#include <signal.h>
#include <llarp.hpp>
#include "logger.hpp"
#include "router.hpp"
#include "math.h"
#include "router.hpp"
#if(__FreeBSD__)
#include <pthread_np.h>
@ -59,12 +59,12 @@ namespace llarp
{
ctx->worker = llarp_init_threadpool(workers, "llarp-worker");
}
} else
if (!strcmp(key, "contact-file"))
}
else if(!strcmp(key, "contact-file"))
{
strncpy(ctx->conatctFile, val, fmin(255, strlen(val)));
} else
if(!strcmp(key, "net-threads"))
}
else if(!strcmp(key, "net-threads"))
{
ctx->num_nethreads = atoi(val);
if(ctx->num_nethreads <= 0)
@ -173,7 +173,8 @@ namespace llarp
int
Context::Run()
{
// just check to make sure it's not already set up (either this or we add a bool and/or add another function)
// just check to make sure it's not already set up (either this or we add a
// bool and/or add another function)
if(!this->router)
{
// set up all requirements
@ -202,8 +203,7 @@ namespace llarp
pthread_set_name_np(netio_threads.back().native_handle(),
"llarp-netio");
#else
pthread_setname_np(netio_threads.back().native_handle(),
"llarp-netio");
pthread_setname_np(netio_threads.back().native_handle(), "llarp-netio");
#endif
}
llarp::Info("running mainloop");
@ -383,16 +383,21 @@ llarp_main_getLocalRC(struct llarp_main *ptr)
return rc;
}
void llarp_main_checkOnline(void *u, uint64_t orig, uint64_t left) {
void
llarp_main_checkOnline(void *u, uint64_t orig, uint64_t left)
{
// llarp::Info("checkOnline - check ", left);
if(left)
return;
struct check_online_request *request = static_cast<struct check_online_request *>(u);
struct check_online_request *request =
static_cast< struct check_online_request * >(u);
// llarp::Debug("checkOnline - running");
//llarp::Info("checkOnline - DHT nodes ", request->ptr->ctx->router->dht->impl.nodes->nodes.size());
// llarp::Info("checkOnline - DHT nodes ",
// request->ptr->ctx->router->dht->impl.nodes->nodes.size());
request->online = false;
request->nodes = request->ptr->ctx->router->dht->impl.nodes->nodes.size();
if (request->ptr->ctx->router->dht->impl.nodes->nodes.size()) {
if(request->ptr->ctx->router->dht->impl.nodes->nodes.size())
{
// llarp::Info("checkOnline - Going to say we're online");
request->online = true;
}
@ -401,9 +406,13 @@ void llarp_main_checkOnline(void *u, uint64_t orig, uint64_t left) {
llarp_main_queryDHT(request);
}
void llarp_main_queryDHT_online(struct check_online_request *request) {
//Info("llarp_main_queryDHT_online: ", request->online ? "online" : "offline");
if (request->online && !request->first) {
void
llarp_main_queryDHT_online(struct check_online_request *request)
{
// Info("llarp_main_queryDHT_online: ", request->online ? "online" :
// "offline");
if(request->online && !request->first)
{
request->first = true;
llarp::Info("llarp_main_queryDHT_online - We're online");
llarp::Info("llarp_main_queryDHT_online - Querying DHT");
@ -411,7 +420,8 @@ void llarp_main_queryDHT_online(struct check_online_request *request) {
}
}
void llarp_main_queryDHT(struct check_online_request *request)
void
llarp_main_queryDHT(struct check_online_request *request)
{
// llarp::Info("llarp_main_queryDHT - setting up timer");
request->hook = &llarp_main_queryDHT_online;

@ -657,7 +657,9 @@ namespace iwp
llarp::Debug("iwp_link::frame_state::process Got frag");
return got_frag(hdr, sz - 6);
default:
llarp::Warn("iwp_link::frame_state::process - unknown header message type: ", (int)hdr.msgtype());
llarp::Warn(
"iwp_link::frame_state::process - unknown header message type: ",
(int)hdr.msgtype());
return false;
}
}
@ -938,7 +940,10 @@ namespace iwp
case eLIMSent:
case eEstablished:
// session is started
llarp::Debug("session recv - ", state==eSessionStartSent?"startsent":"", state==eLIMSent?"limset":"", state==eEstablished?"established":"");
llarp::Debug("session recv - ",
state == eSessionStartSent ? "startsent" : "",
state == eLIMSent ? "limset" : "",
state == eEstablished ? "established" : "");
decrypt_frame(buf, sz);
break;
@ -1391,13 +1396,15 @@ namespace iwp
void
EnterState(State st)
{
llarp::Debug("EnterState - entering state: ", st, state==eLIMSent?"eLIMSent":"", state==eSessionStartSent?"eSessionStartSent":"");
llarp::Debug("EnterState - entering state: ", st,
state == eLIMSent ? "eLIMSent" : "",
state == eSessionStartSent ? "eSessionStartSent" : "");
frame.alive();
state = st;
if(state == eSessionStartSent || state == eIntroAckSent)
{
//llarp::Info("EnterState - ", state==eLIMSent?"eLIMSent":"", state==eSessionStartSent?"eSessionStartSent":"");
//PumpCodelInbound();
// llarp::Info("EnterState - ", state==eLIMSent?"eLIMSent":"",
// state==eSessionStartSent?"eSessionStartSent":""); PumpCodelInbound();
// PumpCodelOutbound();
PumpCryptoOutbound();
// StartInboundCodel();
@ -1922,19 +1929,24 @@ namespace iwp
// both sides agreeed to session invalidation
// terminate our session when all of our frames from the crypto workers
// are done
llarp::Warn("Tick - ", addr, " invaldiated session with ", frames, " frames left");
llarp::Warn("Tick - ", addr, " invaldiated session with ", frames,
" frames left");
return !working;
}
// send keepalive if we are established or a session is made
if(state == eEstablished || state == eLIMSent) {
llarp::Debug("Tick - sending keepalive because state=", state == eEstablished ? "eEstablished" : "", state == eLIMSent ? "eLIMSent" : "");
if(state == eEstablished || state == eLIMSent)
{
llarp::Debug("Tick - sending keepalive because state=",
state == eEstablished ? "eEstablished" : "",
state == eLIMSent ? "eLIMSent" : "");
send_keepalive(this);
}
// pump frame state
if(state == eEstablished)
{
//llarp::Debug("Tick - pumping and retransmitting because we're eEstablished");
// llarp::Debug("Tick - pumping and retransmitting because we're
// eEstablished");
frame.retransmit();
pump();
PumpCryptoOutbound();

@ -1,2 +1 @@
#include "logger.h"

@ -18,5 +18,4 @@ cSetLogLevel(LogLevel lvl)
{
llarp::SetLogLevel((llarp::LogLevel)lvl);
}
}

@ -204,15 +204,16 @@ namespace llarp
return !(*this == other);
}
bool isPrivate()
bool
isPrivate()
{
in_addr_t addr = this->addr4()->s_addr;
unsigned byte = ntohl(addr);
unsigned byte1 = byte >> 24 & 0xff;
unsigned byte2 = byte >> 16 & 0xff;
return (byte1 == 10 || (byte1 == 192 && byte2 == 168) || (byte1 == 172 && (byte2 & 0xf0) == 16));
return (byte1 == 10 || (byte1 == 192 && byte2 == 168)
|| (byte1 == 172 && (byte2 & 0xf0) == 16));
}
};
struct addrhash

@ -99,8 +99,8 @@ llarp_router::SendToOrQueue(const llarp::RouterID &remote,
// this would never be true, as everything is in memory
// but we'll keep around if we ever need to swap them out of memory
// but it's best to keep the paradigm that everythign is in memory at this point in development
// as it will reduce complexity
// but it's best to keep the paradigm that everythign is in memory at this
// point in development as it will reduce complexity
/*
// try requesting the rc from the disk
llarp_async_load_rc *job = new llarp_async_load_rc;
@ -604,7 +604,8 @@ llarp_router::Run()
{
if(publicAddr)
{
llarp::Info("public address:port ", publicAddr);;
llarp::Info("public address:port ", publicAddr);
;
}
}
@ -849,7 +850,8 @@ llarp_router_try_connect(struct llarp_router *router, struct llarp_rc *remote,
llarp::HexEncode< llarp::PubKey, decltype(ftmp) >(remote->pubkey, ftmp);
// do we already have a pending job for this remote?
if(router->HasPendingConnectJob(remote->pubkey)) {
if(router->HasPendingConnectJob(remote->pubkey))
{
llarp::Debug("We have pending connect jobs to ", hexname);
return false;
}
@ -1159,7 +1161,8 @@ namespace llarp
llarp::Error("link ", key, " failed to initialize. Link state", link);
}
}
llarp::Error("link ", key, " failed to configure. (Note: We don't support * yet)");
llarp::Error("link ", key,
" failed to configure. (Note: We don't support * yet)");
}
else if(StrEq(section, "connect"))
{
@ -1186,7 +1189,8 @@ namespace llarp
if(StrEq(key, "public-address"))
{
llarp::Info("public ip ", val, " size ", strlen(val));
if (strlen(val) < 17) {
if(strlen(val) < 17)
{
// assume IPv4
inet_pton(AF_INET, val, &self->ip4addr.sin_addr);
// struct sockaddr dest;
@ -1197,7 +1201,6 @@ namespace llarp
self->publicOverride = true;
}
// llarp::Addr a(val);
}
if(StrEq(key, "public-port"))
{

Loading…
Cancel
Save