Remove old files.
Gonna make this library in a C compatible way.
This commit is contained in:
		@@ -38,8 +38,7 @@ include_directories(
 | 
			
		||||
	"include/"
 | 
			
		||||
	SYSTEM OPENDHT_INCLUDE_DIRS)
 | 
			
		||||
 | 
			
		||||
set(SRCS
 | 
			
		||||
	src/Node.cpp)
 | 
			
		||||
set(SRCS)
 | 
			
		||||
 | 
			
		||||
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")
 | 
			
		||||
@@ -54,6 +53,10 @@ else()
 | 
			
		||||
	add_definitions("-DDEBUG")
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(WIN32)
 | 
			
		||||
    add_definitions("-DWOE32")
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_SHARED_LIB)
 | 
			
		||||
	add_library(${TARGET_NAME} SHARED ${SRCS})
 | 
			
		||||
else()
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 * Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 *
 | 
			
		||||
 * 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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "Node.hpp"
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 * Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 *
 | 
			
		||||
 * 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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <opendht.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#ifndef DEFAULT_PORT
 | 
			
		||||
#	define DEFAULT_PORT 4323
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace neocomm {
 | 
			
		||||
	/**
 | 
			
		||||
	 * @brief A node meant to connect to the neocomm network.
 | 
			
		||||
	 */
 | 
			
		||||
	class Node {
 | 
			
		||||
	public:
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Initialize local node.
 | 
			
		||||
		 */
 | 
			
		||||
		Node();
 | 
			
		||||
		virtual ~Node();
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Bind the node to a port.
 | 
			
		||||
		 *
 | 
			
		||||
		 * @param port Local port to bind to.
 | 
			
		||||
		 */
 | 
			
		||||
		void bind(const short &port = DEFAULT_PORT);
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Connect to a network via specified host.
 | 
			
		||||
		 *
 | 
			
		||||
		 * @param host Hostname of network node.
 | 
			
		||||
		 * @param port Connection port/service.
 | 
			
		||||
		 */
 | 
			
		||||
		void connect(const std::string &host, const short &port);
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Load a file of nodes which have been used before.
 | 
			
		||||
		 *
 | 
			
		||||
		 * @param path Path to the node export file.
 | 
			
		||||
		 */
 | 
			
		||||
		void connect(const std::string &path);
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Export the current list of nodes into a file.
 | 
			
		||||
		 *
 | 
			
		||||
		 * @param path Path to the file in which to save the node list.
 | 
			
		||||
		 */
 | 
			
		||||
		void exportNodeList(const std::string &path);
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * @brief Retrieve the current status of the connection.
 | 
			
		||||
		 *
 | 
			
		||||
		 * @return String describing connection status.
 | 
			
		||||
		 */
 | 
			
		||||
		//inline const std::string getStatus();
 | 
			
		||||
	private:
 | 
			
		||||
		dht::DhtRunner node;
 | 
			
		||||
		dht::NetId status;
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								src/Node.cpp
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								src/Node.cpp
									
									
									
									
									
								
							@@ -1,33 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 * Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
 | 
			
		||||
 *
 | 
			
		||||
 * 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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "neocomm/Node.hpp"
 | 
			
		||||
 | 
			
		||||
neocomm::Node::Node() : status(0) { }
 | 
			
		||||
 | 
			
		||||
void neocomm::Node::bind(const short &port) {
 | 
			
		||||
	node.run(port, dht::crypto::generateIdentity(), true, status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void neocomm::Node::connect(const std::string &host, const short &port) {
 | 
			
		||||
	node.bootstrap(host.c_str(), std::to_string(port).c_str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
neocomm::Node::~Node() {
 | 
			
		||||
	node.join();
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user