Merge pull request #83 from SirzechsLucifer666/iss81
Fix #81 & #82 - Integrate CMake & reorganize file structure & Update Build guide
This commit is contained in:
30 files changed
+131
-125
No files matched your search
+3
-1
@@ -33,4 +33,6 @@
|
||||
|
||||
*.bin
|
||||
temp
|
||||
build
|
||||
build
|
||||
.idea
|
||||
/cmake-build-debug/
|
||||
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
project(nipovpn)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Set the compilation flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -ggdb")
|
||||
|
||||
# Set the preprocessor flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MMD -MP")
|
||||
|
||||
# https://cmake.org/cmake/help/latest/module/FindBoost.html
|
||||
find_package(Boost REQUIRED COMPONENTS system regex)
|
||||
|
||||
# /usr/local/lib/cmake/yaml-cpp/yaml-cpp-config.cmake
|
||||
# declared variables: YAML_CPP_INCLUDE_DIR & YAML_CPP_LIBRARY_DIR
|
||||
find_package(yaml-cpp REQUIRED)
|
||||
|
||||
# https://cmake.org/cmake/help/v3.6/module/FindOpenSSL.html
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(agent)
|
||||
|
||||
|
||||
#add_custom_target(deb
|
||||
# COMMAND ${CMAKE_COMMAND} -E echo "Creating Debian package..."
|
||||
# COMMAND dpkg-deb --build ${DEBIANDIR} ${DEBFILE}
|
||||
# COMMENT "Building Debian package"
|
||||
#)
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# Pre-compiler and Compiler flags
|
||||
CXX_FLAGS := -Wall -Wextra -std=c++20 -ggdb
|
||||
PRE_FLAGS := -MMD -MP
|
||||
|
||||
# Project directory structure
|
||||
BIN := nipovpn/usr/bin
|
||||
SRC := src
|
||||
LIB := lib
|
||||
INC := include
|
||||
DEBIANDIR := nipovpn
|
||||
DEBDIR := files/deb
|
||||
DEBFILE := $(DEBDIR)/nipovpn.deb
|
||||
MAINFILE := $(SRC)/main.cpp
|
||||
|
||||
# Build directories and output
|
||||
TARGET := $(BIN)/nipovpn
|
||||
BUILD := build
|
||||
|
||||
# Library search directories and flags
|
||||
EXT_LIB :=
|
||||
LDFLAGS := -lyaml-cpp -lssl -lcrypto
|
||||
LDPATHS := $(addprefix -L,$(LIB) $(EXT_LIB))
|
||||
|
||||
# Include directories
|
||||
INC_DIRS := $(INC) $(shell find $(SRC) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
# Construct build output and dependency filenames
|
||||
SRCS := $(shell find $(SRC) -name *.cpp)
|
||||
OBJS := $(subst $(SRC)/,$(BUILD)/,$(addsuffix .o,$(basename $(SRCS))))
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Build task
|
||||
build: all
|
||||
|
||||
# Main task
|
||||
all: format $(TARGET)
|
||||
|
||||
# Build package
|
||||
deb: deb
|
||||
|
||||
format:
|
||||
clang-format --style=Google -i src/*
|
||||
|
||||
# Task producing target from built files
|
||||
$(TARGET): $(OBJS)
|
||||
@echo "Building..."
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(OBJS) -o $@ $(LDPATHS) $(LDFLAGS)
|
||||
|
||||
# Compile all cpp files
|
||||
$(BUILD)/%.o: $(SRC)/%.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CXX_FLAGS) $(PRE_FLAGS) $(INC_FLAGS) -c -o $@ $< $(LDPATHS) $(LDFLAGS)
|
||||
|
||||
# Create deb file
|
||||
.PHONY: deb
|
||||
deb:
|
||||
@echo "Creating deb file..."
|
||||
dpkg-deb --build $(DEBIANDIR)/ $(DEBFILE)
|
||||
|
||||
# Clean task
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "Clearing..."
|
||||
rm -rf $(BUILD)
|
||||
rm -rf $(BIN)
|
||||
rm -fr $(DEBFILE)
|
||||
|
||||
# Include all dependencies
|
||||
-include $(DEPS)
|
||||
@@ -11,11 +11,6 @@ NipoVPN is a powerful proxy tool designed to conceal your HTTP requests within f
|
||||
- Boost Library Integration: Utilizes Boost for robust and reliable networking operations.
|
||||
- High Performance: Optimized for speed and efficiency, ensuring minimal impact on request latency.
|
||||
|
||||
## Requirements
|
||||
|
||||
C++20 or higher
|
||||
Boost 1.75.0 or higher
|
||||
|
||||
|
||||
## Usecases
|
||||
|
||||
@@ -37,56 +32,13 @@ Here you can see the logical flow of a single request from first step to get the
|
||||
## Contribution
|
||||
To contribute take a look at [contribution page](https://github.com/MortezaBashsiz/nipovpn/blob/main/CONTRIBUTING.md).
|
||||
|
||||
## Installation
|
||||
## Build
|
||||
|
||||
### Source
|
||||
Build from source for [Linux](guides/BuildLinux.md)
|
||||
|
||||
#### Dependencies
|
||||
This program needs following dependencies
|
||||
```bash
|
||||
libyaml-cpp >= 0.8
|
||||
boost-libs >= 1.75.0
|
||||
```
|
||||
|
||||
#### Clone
|
||||
```bash
|
||||
[~]>$ git@github.com:MortezaBashsiz/nipovpn.git
|
||||
[~]>$ cd nipovpn
|
||||
```
|
||||
|
||||
#### Install Boost Library:
|
||||
Follow the instructions on the [Boost](https://www.boost.org/) to install the Boost library suitable for your system.
|
||||
|
||||
#### Make
|
||||
Make the source code
|
||||
```bash
|
||||
[~/nipovpn]>$ make
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/tcpserver.o src/tcpserver.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/main.o src/main.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/agenthandler.o src/agenthandler.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/config.o src/config.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/tcpclient.o src/tcpclient.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/http.o src/http.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/tcpconnection.o src/tcpconnection.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/log.o src/log.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/serverhandler.o src/serverhandler.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
mkdir -p build/
|
||||
g++ -Wall -Wextra -std=c++20 -ggdb -MMD -MP -Iinclude -Isrc -c -o build/runner.o src/runner.cpp -Llib -lyaml-cpp -lssl -lcrypto
|
||||
Building...
|
||||
mkdir -p nipovpn/usr/bin/
|
||||
g++ build/tcpserver.o build/main.o build/agenthandler.o build/config.o build/tcpclient.o build/http.o build/tcpconnection.o build/log.o build/serverhandler.o build/runner.o -o nipovpn/usr/bin/nipovpn -Llib -lyaml-cpp -lssl -lcrypto
|
||||
[~/nipovpn]>$
|
||||
|
||||
```
|
||||
## Run
|
||||
|
||||
#### Create directories
|
||||
Create the log directory and log file
|
||||
@@ -95,10 +47,9 @@ Create the log directory and log file
|
||||
[~/nipovpn]>$ sudo touch /var/log/nipovpn/nipovpn.log
|
||||
```
|
||||
|
||||
#### Run
|
||||
Run it
|
||||
```bash
|
||||
[~/nipovpn]>$ sudo nipovpn/usr/bin/nipovpn server nipovpn/etc/nipovpn/config.yaml
|
||||
sudo build/core/nipovpn_core server nipovpn/etc/nipovpn/config.yaml
|
||||
2024-08-02_15:30:07 [INFO] Config initialized in server mode
|
||||
2024-08-02_15:30:07 [INFO]
|
||||
Config :
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,40 @@
|
||||
set(CORE_TARGET nipovpn_core)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(CORE_TARGET_HEADERS
|
||||
src/agenthandler.hpp
|
||||
src/config.hpp
|
||||
src/general.hpp
|
||||
src/http.hpp
|
||||
src/log.hpp
|
||||
src/runner.hpp
|
||||
src/serverhandler.hpp
|
||||
src/tcpclient.hpp
|
||||
src/tcpconnection.hpp
|
||||
src/tcpserver.hpp
|
||||
)
|
||||
|
||||
set(CORE_TARGET_SOURCES
|
||||
src/agenthandler.cpp
|
||||
src/config.cpp
|
||||
src/http.cpp
|
||||
src/log.cpp
|
||||
src/runner.cpp
|
||||
src/serverhandler.cpp
|
||||
src/tcpclient.cpp
|
||||
src/tcpconnection.cpp
|
||||
src/tcpserver.cpp
|
||||
)
|
||||
|
||||
|
||||
add_executable(${CORE_TARGET} src/main.cpp ${CORE_TARGET_SOURCES})
|
||||
|
||||
# Add directories
|
||||
target_include_directories(${CORE_TARGET} PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_include_directories(${CORE_TARGET} PUBLIC ${YAML_CPP_INCLUDE_DIR})
|
||||
target_include_directories(${CORE_TARGET} PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
# linking dependencies
|
||||
target_link_libraries(${CORE_TARGET} ${Boost_LIBRARIES})
|
||||
target_link_libraries(${CORE_TARGET} ${YAML_CPP_LIBRARIES})
|
||||
target_link_libraries(${CORE_TARGET} ${OPENSSL_LIBRARIES})
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
## Build on Linux
|
||||
|
||||
### Requirements
|
||||
|
||||
C++20 or higher
|
||||
libyaml-cpp >= 0.8
|
||||
boost-libs >= 1.75.0
|
||||
OpenSSL
|
||||
|
||||
### Dependencies
|
||||
Install the dependencies
|
||||
```bash
|
||||
sudo apt install cmake libssl-dev
|
||||
```
|
||||
#### Install Boost Library:
|
||||
Follow the instructions on the [Boost](https://www.boost.org/) to install the Boost library suitable for your system.
|
||||
or install from repository
|
||||
```bash
|
||||
sudo apt install libboost-all-dev
|
||||
```
|
||||
|
||||
#### Install Yaml-cpp Library:
|
||||
Follow the instructions on the [Yaml-cpp](https://github.com/jbeder/yaml-cpp) to install the library
|
||||
|
||||
### Build with make (Recommended)
|
||||
- git clone git@github.com:MortezaBashsiz/nipovpn.git
|
||||
- cd niopvpn
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
- make -j$(nproc)
|
||||
|
||||
### Build with Ninja
|
||||
- sudo apt install ninja-build
|
||||
- git clone git@github.com:MortezaBashsiz/nipovpn.git
|
||||
- cd niopvpn
|
||||
- cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja -B build
|
||||
- cmake --build build -j$(nproc)
|
||||
|
||||
## Cmake options
|
||||
|
||||
### Build type
|
||||
|
||||
-DCMAKE_BUILD_TYPE=Debug|Release
|
||||
|
||||
#### Clean
|
||||
|
||||
To clean simply remove the build directory
|
||||
|
||||
|
||||
Binary file not shown.
Whitespace-only changes.
Reference in new issue
Block a user