start working on onion routing parts

pull/1/head
Jeff Becker 6 years ago
parent ebbce7554c
commit a947806b57
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -0,0 +1,24 @@
{
"configurations": [
{
"name": "Linux",
"browse": {
"path": [
"${workspaceFolder}/llarp",
"${workspaceFolder}/daemon",
"${workspaceFolder}/include"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

@ -0,0 +1,2 @@
{
}

14
.vscode/tasks.json vendored

@ -6,12 +6,14 @@
{
"label": "build",
"type": "shell",
"command": "make"
},
{
"label": "rebuild",
"type": "shell",
"command": "make clean all"
"command": "make",
"group": "build",
"osx": {
"command": "make CXX=g++-8 CC=gcc-8"
},
"problemMatcher": [
"$gcc"
]
}
]
}

@ -95,7 +95,9 @@ set(LIB_SRC
llarp/mem.cpp
llarp/net.cpp
llarp/nodedb.cpp
llarp/relay_ack.cpp
llarp/relay_commit.cpp
llarp/relay_up_down.cpp
llarp/router_contact.cpp
llarp/router.cpp
llarp/router_identity.c

@ -0,0 +1,15 @@
#ifndef LLARP_MESSAGES_HPP
#define LLARP_MESSAGES_HPP
/**
include shortcut for all link and routing messages
*/
#include <llarp/messages/dht_immediate.hpp>
#include <llarp/messages/discard.hpp>
#include <llarp/messages/link_intro.hpp>
#include <llarp/messages/relay.hpp>
#include <llarp/messages/relay_ack.hpp>
#include <llarp/messages/relay_commit.hpp>
#endif

@ -0,0 +1,38 @@
#ifndef LLARP_MESSAGES_RELAY_HPP
#define LLARP_MESSAGES_RELAY_HPP
#include <llarp/link_message.hpp>
namespace llarp
{
struct RelayUpstreamMessage : public ILinkMessage
{
RelayUpstreamMessage(const RouterID& from);
~RelayUpstreamMessage();
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
bool
BEncode(llarp_buffer_t* buf) const;
bool
HandleMessage(llarp_router* router) const;
};
struct RelayDownstreamMessage : public ILinkMessage
{
RelayDownstreamMessage(const RouterID& from);
~RelayDownstreamMessage();
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
bool
BEncode(llarp_buffer_t* buf) const;
bool
HandleMessage(llarp_router* router) const;
};
}
#endif

@ -0,0 +1,24 @@
#ifndef LLARP_MESSAGES_RELAY_ACK_HPP
#define LLARP_MESSAGES_RELAY_ACK_HPP
#include <llarp/link_message.hpp>
namespace llarp
{
struct LR_AckMessage : public ILinkMessage
{
LR_AckMessage(const RouterID& from);
~LR_AckMessage();
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
bool
BEncode(llarp_buffer_t* buf) const;
bool
HandleMessage(llarp_router* router) const;
};
}
#endif

@ -1,9 +1,5 @@
#include <llarp/router_contact.h>
#include <llarp/link_message.hpp>
#include <llarp/messages/dht_immediate.hpp>
#include <llarp/messages/discard.hpp>
#include <llarp/messages/link_intro.hpp>
#include <llarp/messages/relay_commit.hpp>
#include <llarp/messages.hpp>
#include "buffer.hpp"
#include "logger.hpp"
#include "router.hpp"
@ -52,15 +48,25 @@ namespace llarp
llarp::Warn(__FILE__, "bad mesage type size: ", strbuf.sz);
return false;
}
// create the message to parse based off message type
switch(*strbuf.cur)
{
case 'i':
handler->msg = new LinkIntroMessage(
handler->from->get_remote_router(handler->from));
break;
case 'd':
handler->msg = new RelayDownstreamMessage(handler->GetCurrentFrom());
break;
case 'u':
handler->msg = new RelayUpstreamMessage(handler->GetCurrentFrom());
break;
case 'm':
handler->msg = new DHTImmeidateMessage(handler->GetCurrentFrom());
break;
case 'a':
handler->msg = new LR_AckMessage(handler->GetCurrentFrom());
break;
case 'c':
handler->msg = new LR_CommitMessage(handler->GetCurrentFrom());
break;

@ -53,15 +53,16 @@ llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr)
if(af == AF_INET)
sl = sizeof(sockaddr_in);
#ifdef AF_LINK
//printf("AF_INET[%d]\n", AF_INET); // FBSD 2
//printf("AF_INET6[%d]\n", AF_INET6); // FBSD 28
//printf("AF_LINK[%d]\n", AF_LINK); // FBSD 18
if(af == AF_LINK) {
// printf("AF_INET[%d]\n", AF_INET); // FBSD 2
// printf("AF_INET6[%d]\n", AF_INET6); // FBSD 28
// printf("AF_LINK[%d]\n", AF_LINK); // FBSD 18
if(af == AF_LINK)
{
printf("We dont support AF_LINK yet\n");
}
#endif
#ifdef AF_PACKET
//printf("AF_PACKET[%d]\n", AF_PACKET); // FBSD dne
// printf("AF_PACKET[%d]\n", AF_PACKET); // FBSD dne
if(af == AF_PACKET)
sl = sizeof(sockaddr_ll);
#endif
@ -72,10 +73,11 @@ llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr)
{
if(i->ifa_addr)
{
//llarp::Info(__FILE__, "scanning ", i->ifa_name, " af: ", std::to_string(i->ifa_addr->sa_family));
// llarp::Info(__FILE__, "scanning ", i->ifa_name, " af: ",
// std::to_string(i->ifa_addr->sa_family));
if(llarp::StrEq(i->ifa_name, ifname) && i->ifa_addr->sa_family == af)
{
//llarp::Info(__FILE__, "found ", ifname, " af: ", af);
// llarp::Info(__FILE__, "found ", ifname, " af: ", af);
memcpy(addr, i->ifa_addr, sl);
if(af == AF_INET6)
{

@ -0,0 +1,28 @@
#include <llarp/messages/relay_ack.hpp>
namespace llarp
{
LR_AckMessage::LR_AckMessage(const RouterID & from) : ILinkMessage(from)
{
}
LR_AckMessage::~LR_AckMessage()
{
}
bool LR_AckMessage::BEncode(llarp_buffer_t * buf) const
{
return false;
}
bool LR_AckMessage::DecodeKey(llarp_buffer_t key, llarp_buffer_t * buf)
{
return false;
}
bool LR_AckMessage::HandleMessage(llarp_router * router) const
{
return false;
}
}

@ -0,0 +1,59 @@
#include <llarp/messages/relay.hpp>
namespace llarp
{
RelayUpstreamMessage::RelayUpstreamMessage(const RouterID &from)
: ILinkMessage(from)
{
}
RelayUpstreamMessage::~RelayUpstreamMessage()
{
}
bool
RelayUpstreamMessage::BEncode(llarp_buffer_t *buf) const
{
// TODO: implement me
return false;
}
bool
RelayUpstreamMessage::DecodeKey(llarp_buffer_t key, llarp_buffer_t *buf)
{
return false;
}
bool
RelayUpstreamMessage::HandleMessage(llarp_router *router) const
{
return false;
}
RelayDownstreamMessage::RelayDownstreamMessage(const RouterID &from)
: ILinkMessage(from)
{
}
RelayDownstreamMessage::~RelayDownstreamMessage()
{
}
bool
RelayDownstreamMessage::BEncode(llarp_buffer_t *buf) const
{
// TODO: implement me
return false;
}
bool
RelayDownstreamMessage::DecodeKey(llarp_buffer_t key, llarp_buffer_t *buf)
{
return false;
}
bool
RelayDownstreamMessage::HandleMessage(llarp_router *router) const
{
return false;
}
}
Loading…
Cancel
Save