diff --git a/CMakeLists.txt b/CMakeLists.txt index 663352e..e75bd73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,8 @@ include_directories( "include/" SYSTEM OPENDHT_INCLUDE_DIRS) -#set(SRCS) +set(SRCS + src/Node.cpp) set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors -pedantic-errors -fno-elide-constructors") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") diff --git a/include/neocomm/NeoComm.hpp b/include/neocomm/NeoComm.hpp new file mode 100644 index 0000000..55dcf33 --- /dev/null +++ b/include/neocomm/NeoComm.hpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "Node.hpp" diff --git a/include/neocomm/Node.hpp b/include/neocomm/Node.hpp new file mode 100644 index 0000000..5d53f16 --- /dev/null +++ b/include/neocomm/Node.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include + +#ifndef DEFAULT_PORT +# define DEFAULT_PORT 4323 +#endif + +namespace neocomm { + class Node { + public: + Node(); + virtual ~Node(); + void bind(const short &port = DEFAULT_PORT); + const std::string getStatus() const; + private: + dht::DhtRunner node; + dht::NetId status; + }; +} diff --git a/src/Node.cpp b/src/Node.cpp new file mode 100644 index 0000000..42b8279 --- /dev/null +++ b/src/Node.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "neocomm/Node.hpp" + +#include + +neocomm::Node::Node() : status(0) { } + +void neocomm::Node::bind(const short &port) { + node.run(port, dht::crypto::generateIdentity(), true, status); +} + +neocomm::Node::~Node() { + node.join(); +}