This commit is contained in:
Suraxius committed 2021-01-19 21:27:08 +01:00
1 parent 7ff88f5b1a
commit d2d4a21f94
12 files changed
+29 -23

No files matched your search

+5
View File
@@ -1,6 +1,11 @@
# DistriNS # DistriNS
A Distributed approach to Authoritative DNS A Distributed approach to Authoritative DNS
## Useful Commands
```
inotifywait -m -q -r -e close_write --format %f ../src/ | grep --line-buffered "\.[h,c]pp$" | while IFS= read -r file; do make && src/core/Plains; done
```
PLAINS - Peering Local Authoratative Integrated Name Server PLAINS - Peering Local Authoratative Integrated Name Server
## Coding Style ## Coding Style
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Plains { namespace Plains {
namespace API { namespace API {
Server::Server(EventBus& eventBus) : eventBus(eventBus) { Server::Server(EventBus& eventBus) : eventBus_(eventBus) {
//Constructor //Constructor
} }
+1 -1
View File
@@ -8,7 +8,7 @@ namespace API {
using Core::EventBus; using Core::EventBus;
class Server { class Server {
const EventBus& eventBus; const EventBus& eventBus_;
public: public:
Server(EventBus& eventBus); Server(EventBus& eventBus);
+5 -5
View File
@@ -8,12 +8,12 @@ namespace Core {
using std::string; using std::string;
ConfigManager::ConfigManager(Logger& logger, vector<string>& parameters) : ConfigManager::ConfigManager(Logger& logger, vector<string>& parameters) :
logger(logger), logger_(logger),
parameters(parameters) parameters_(parameters)
{ {
// move this to a function that can return an error code? // move this to a function that can return an error code?
if ( parameters.size() == 0 ) return; if ( parameters.size() == 0 ) return;
logger.debug.ln("Interpreting Paremters..."); logger_.debug.ln("Interpreting Paremters...");
/* /*
for (unsigned i = 0; i < (numParameters-1); ++i) { for (unsigned i = 0; i < (numParameters-1); ++i) {
@@ -21,8 +21,8 @@ ConfigManager::ConfigManager(Logger& logger, vector<string>& parameters) :
string v = string(parameters[i+1]); string v = string(parameters[i+1]);
// Check if this parameter is an argument or an argument value: // Check if this parameter is an argument or an argument value:
if ( p.compare(0,1,"-") == 0 ) { if ( p.compare(0,1,"-") == 0 ) {
logger.debug("Interpreting parameter " << p); logger_.debug("Interpreting parameter " << p);
if ( ! p.compare("--initial-peer") ) logger.debug("Peer " << v << " set"); if ( ! p.compare("--initial-peer") ) logger_.debug("Peer " << v << " set");
} }
} }
*/ */
+2 -2
View File
@@ -4,10 +4,10 @@
namespace Plains { namespace Plains {
namespace Core { namespace Core {
EventBus::EventBus(Logger& logger) : logger(logger) {}; EventBus::EventBus(Logger& logger) : logger_(logger) {};
void EventBus::test() { void EventBus::test() {
logger.debug << "Testing from within EventBus!" << Logger::commit; logger_.debug << "Testing from within EventBus!" << Logger::commit;
} }
+2 -2
View File
@@ -14,9 +14,9 @@ using std::string;
class Record : public Resource class Record : public Resource
{ {
public: public:
const uint16_t id; const uint16_t id_;
string serialize(); string serialize();
Record(const uint16_t id) : id(id) {} Record(const uint16_t id) : id_(id) {}
}; };
class ARecord : public Record { ARecord(); }; class ARecord : public Record { ARecord(); };
+2 -2
View File
@@ -16,8 +16,8 @@ class ConfigManager
ConfigManager(Logger& logger, vector<string>& parameters); ConfigManager(Logger& logger, vector<string>& parameters);
private: private:
Logger& logger; Logger& logger_;
const vector<string>& parameters; const vector<string>& parameters_;
}; };
}} }}
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Core {
class EventBus { class EventBus {
private: private:
Logger& logger; Logger& logger_;
public: public:
EventBus(Logger& logger); EventBus(Logger& logger);
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Plains { namespace Plains {
namespace DHCP { namespace DHCP {
Server::Server(EventBus& eventBus) : eventBus(eventBus) { Server::Server(EventBus& eventBus) : eventBus_(eventBus) {
//Constructor //Constructor
} }
+1 -1
View File
@@ -8,7 +8,7 @@ namespace DHCP {
using Core::EventBus; using Core::EventBus;
class Server { class Server {
const EventBus& eventBus; const EventBus& eventBus_;
public: public:
Server(EventBus& eventBus); Server(EventBus& eventBus);
+4 -4
View File
@@ -40,8 +40,8 @@ static char* intToHex(unsigned byteCount, int c) {
} }
Server::Server(Logger& logger, EventBus& eventBus) Server::Server(Logger& logger, EventBus& eventBus)
: logger(logger), : logger_(logger),
eventBus(eventBus) eventBus_(eventBus)
{ {
logger.debug << "Testing some stuff..." << Logger::commit; logger.debug << "Testing some stuff..." << Logger::commit;
logger.debug << "Message header overall size: " << sizeof(Message::Header) << Logger::commit; logger.debug << "Message header overall size: " << sizeof(Message::Header) << Logger::commit;
@@ -76,7 +76,7 @@ Server::Server(Logger& logger, EventBus& eventBus)
myfile.close(); myfile.close();
//Testing over //Testing over
socket_ = new udp::socket(io_context, udp::endpoint(udp::v4(), 8853)); socket_ = new udp::socket(io_context_, udp::endpoint(udp::v4(), 8853));
} }
Server::~Server() { Server::~Server() {
@@ -84,7 +84,7 @@ Server::~Server() {
} }
void Server::run() { void Server::run() {
io_context.run(); io_context_.run();
do_receive(); do_receive();
} }
+4 -3
View File
@@ -15,12 +15,13 @@ using Core::Logger;
class Server class Server
{ {
private: private:
EventBus& eventBus; EventBus& eventBus_;
Logger& logger; Logger& logger_;
asio::io_context io_context; asio::io_context io_context_;
asio::ip::udp::socket* socket_; asio::ip::udp::socket* socket_;
asio::ip::udp::endpoint sender_endpoint_; asio::ip::udp::endpoint sender_endpoint_;
char data_[1024]; char data_[1024];
void do_receive(); void do_receive();
void do_send(std::size_t length); void do_send(std::size_t length);