diff --git a/.gitignore b/.gitignore index 4eab10a..cad48be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ +doc/ *.swp .vscode diff --git a/Doxyfile b/Doxyfile index 89806c9..097b4f9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = DistriNS +PROJECT_NAME = Plains # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and diff --git a/README.md b/README.md index 548ad8a..0160fe7 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ inotifywait -m -q -r -e close_write --format %f ../src/ | grep --line-buffered " #### Header Files - LargeCamelCase.hpp +# TODOs +## Resolver +- DNSSec +- Dane Support + + ## Useful Links ### DNS Protocol diff --git a/src/core/dns/Record.cpp b/src/core/dns/Record.cpp index 68c9eb6..42f3241 100644 --- a/src/core/dns/Record.cpp +++ b/src/core/dns/Record.cpp @@ -1,12 +1,18 @@ #include "Record.hpp" + namespace Plains { namespace Core { namespace DNS { -string Record::serialize() { - return "Nothing implemented"; +Record::Record(const uint16_t id) : _id(id) { + _os = ostream(_sb); + _os << "NOT IMPLEMENTED"; + } + +ostream& Record::operator>>(Serializable& record) { + return _os; } ARecord::ARecord() : Record(1) {} diff --git a/src/core/dns/include/Record.hpp b/src/core/dns/include/Record.hpp index b47c700..557a640 100644 --- a/src/core/dns/include/Record.hpp +++ b/src/core/dns/include/Record.hpp @@ -1,22 +1,28 @@ #ifndef RECORD_HPP #define RECORD_HPP #include -#include #include "Resource.hpp" +#include +#include namespace Plains { namespace Core { namespace DNS { -using std::string; +using std::ostream; +using std::stringbuf; // Provides an abstract class for dns records that may be stored in the database class Record : public Resource { public: const uint16_t _id; - string serialize(); - Record(const uint16_t id) : _id(id) {} + ostream& operator>>(Serializable& object); + Record(const uint16_t id); + + private: + stringbuf _sb; + ostream* _os; }; class ARecord : public Record { ARecord(); }; diff --git a/src/core/include/Core.hpp b/src/core/include/Core.hpp index ca0f5e4..3350ae1 100644 --- a/src/core/include/Core.hpp +++ b/src/core/include/Core.hpp @@ -4,5 +4,6 @@ #include "Logger.hpp" #include "ConfigManager.hpp" #include "Exception.hpp" +#include "Serializable.hpp" //Include further classes here #endif diff --git a/src/core/include/Resource.hpp b/src/core/include/Resource.hpp index 1bfc7f6..2dc90ca 100644 --- a/src/core/include/Resource.hpp +++ b/src/core/include/Resource.hpp @@ -1,19 +1,15 @@ #ifndef RESOURCE_HPP #define RESOURCE_HPP -#include -#include "Serialize.hpp" +#include "Serializable.hpp" namespace Plains { namespace Core { -using std::string; - // Provides an abstract class for resources that may be stored in the ledger -class Resource : public Serialize -{ - public: - virtual string serialize() const = 0; -}; +class Resource : public Serializable {}; + + + }} diff --git a/src/core/include/Serializable.hpp b/src/core/include/Serializable.hpp new file mode 100644 index 0000000..85d7b46 --- /dev/null +++ b/src/core/include/Serializable.hpp @@ -0,0 +1,21 @@ +#ifndef SERIALIZABLE_HPP +#define SERIALIZABLE_HPP +#include +#include + +namespace Plains { +namespace Core { + + +using std::ostream; + +class Serializable { + public: + // Serialize + virtual ostream& operator>>(Serializable& object); + // Deserialize + //virtual Serializable& operator<<(ostream& os); +}; + +}} +#endif diff --git a/src/core/include/Serialize.hpp b/src/core/include/Serialize.hpp deleted file mode 100644 index 3b0eb1d..0000000 --- a/src/core/include/Serialize.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef SERIALIZE_HPP -#define SERIALIZE_HPP -#include - -namespace Plains { -namespace Core { - - -using std::string; - -class Serialize { - public: - virtual string serialize() const = 0; -}; - -}} -#endif diff --git a/src/core/main.cpp b/src/core/main.cpp index ec24cbd..61f88df 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -25,7 +25,7 @@ Resolver::Server* globalResolver; int main(int args, char **argv) { Logger logger(Logger::DEBUG); - logger.info.ln ("Starting PLAINS..."); + logger.info.ln ("Starting Plains..."); vector arguments; for ( unsigned index = 0; index < args; ++index ) { @@ -75,7 +75,7 @@ int main(int args, char **argv) { // End of Testcode eventBus.run(); - logger.info.ln ("PLAINS successfully started."); + logger.info.ln ("Plains successfully started."); } catch (Exception& e) { logger.fatal << "Uncaught Exception: " << e.what() << Logger::commit; @@ -115,6 +115,6 @@ void shutdown() { globalUIServer->~Server(); globalEventBus->~EventBus(); globalConfigManager->~ConfigManager(); - globalLogger->info.ln ("PLAINS shut down."); + globalLogger->info.ln ("Plains shut down."); globalLogger->~Logger(); } diff --git a/src/resolver/Server.cpp b/src/resolver/Server.cpp index 2c79065..0fa2207 100644 --- a/src/resolver/Server.cpp +++ b/src/resolver/Server.cpp @@ -28,13 +28,11 @@ Server::Server(Logger& logger, EventBus& eventBus) _eventBus(eventBus) { _logger.debug.ln ("Starting Resolver..."); - //throw Exception("Testi"); _logger.warn << "Testing some stuff..." << Logger::commit; _logger.warn << "Message header overall size: " << sizeof(Message::Header) << Logger::commit; //_logger.debug << "Message::QR:RESPONSE Enum:" << Message::QR::RESPONSE << endl; /* - std::cerr << std::hex << 0xABCDEF std::fstream myfile; std::streampos beg,end; @@ -125,8 +123,9 @@ void Server::run() { //std::cout << "size: " << udpReadStatus << std::endl; for(int i=0; i(buffer[i]); + std::cout << std::setw(2) << static_cast(buffer[i]) << " "; } + std::cout << std::endl << std::endl; if ( sendto(udpServerSocket, msg, strlen(msg), 0, (struct sockaddr*)&clientAddress, clientAddressLength) < 0 ) { close(udpServerSocket); diff --git a/src/ui/Server.cpp b/src/ui/Server.cpp index 1a2912e..8bf4dff 100644 --- a/src/ui/Server.cpp +++ b/src/ui/Server.cpp @@ -40,8 +40,8 @@ Server::~Server() { } void Server::run() { - _logger.info.ln ("UI Running Webserver on Port 8080"); - _server->listen("0.0.0.0", 8080); + _logger.info.ln ("UI available at http://localhost:3030"); + _server->listen("127.0.0.1", 3030); } diff --git a/static/ui/index.htm b/static/ui/index.htm index 2f06b24..ef4ffd8 100644 --- a/static/ui/index.htm +++ b/static/ui/index.htm @@ -1,7 +1,7 @@ - PLAINS Control Panel + Plains Control Panel @@ -53,7 +53,7 @@