Compare commits
70
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0da1c55d8 | ||
|
|
3363a7a5d2 | ||
|
|
4cdc66bdf1 | ||
|
|
2540b3a504 | ||
|
|
cb87555503 | ||
|
|
20bb0d2b9d | ||
|
|
31b7bb96a8 | ||
|
|
9abc319202 | ||
|
|
6c21edfc40 | ||
|
|
6493d88258 | ||
|
|
ed10d097f1 | ||
|
|
14ead78ff8 | ||
|
|
b1a18e243c | ||
|
|
24390b6562 | ||
|
|
ec4a68fdb6 | ||
|
|
bae6afa35b | ||
|
|
36315032d9 | ||
|
|
96758b6322 | ||
|
|
9b5b275275 | ||
|
|
76a9e4acb0 | ||
|
|
3b3d2f4d88 | ||
|
|
9af39a5715 | ||
|
|
2f043a6f83 | ||
|
|
d94075e5c3 | ||
|
|
9f1a7c8637 | ||
|
|
2add09ea33 | ||
|
|
8beee5d127 | ||
|
|
84bb675b9c | ||
|
|
67c43de80d | ||
|
|
ab4580920f | ||
|
|
c0942c4015 | ||
|
|
228aff5d63 | ||
|
|
5647fd2f69 | ||
|
|
92a290cca7 | ||
|
|
108b9729c7 | ||
|
|
7baaf6aefb | ||
|
|
4793a3f0e3 | ||
|
|
c8cd4066d7 | ||
|
|
33a4dbd0b8 | ||
|
|
01d8b36ca0 | ||
|
|
cd7b985da1 | ||
|
|
80c631f66b | ||
|
|
8a1fcde280 | ||
|
|
51feb98dc3 | ||
|
|
560b5d93cc | ||
|
|
97ee705eec | ||
|
|
8d1ecfc2dc | ||
|
|
b402144e9e | ||
|
|
e7c8cb51cc | ||
|
|
51fd1d47cc | ||
|
|
251b0202e8 | ||
|
|
10e4481376 | ||
|
|
47b56af86e | ||
|
|
1c8d2d610b | ||
|
|
86f2b750a8 | ||
|
|
0e4c1bf00d | ||
|
|
1452c1bd82 | ||
|
|
09d5e25509 | ||
|
|
73f9cb01c1 | ||
|
|
88bf0953e3 | ||
|
|
83fbb7adf2 | ||
|
|
7ac2fb293f | ||
|
|
f70ef566d7 | ||
|
|
064fe1614a | ||
|
|
323380afa5 | ||
|
|
f2b63aacb9 | ||
|
|
d968046d8b | ||
|
|
a9d290c788 | ||
|
|
268dcfb207 | ||
|
|
f3bd05787b |
No files matched your search
@@ -0,0 +1,157 @@
|
||||
name: Build Android Binary - dev
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- 'core/**'
|
||||
- 'CMakeLists.txt'
|
||||
- 'core/CMakeLists.txt'
|
||||
- '.github/workflows/android-dev.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.2.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
git \
|
||||
curl \
|
||||
zip \
|
||||
unzip \
|
||||
tar \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
libtool
|
||||
|
||||
- name: Setup Android NDK r29
|
||||
uses: nttld/setup-ndk@v1
|
||||
with:
|
||||
ndk-version: r29
|
||||
add-to-path: true
|
||||
|
||||
- name: Show Android NDK information
|
||||
run: |
|
||||
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME"
|
||||
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT"
|
||||
ls -lah "$ANDROID_NDK_HOME"
|
||||
|
||||
- name: Setup vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
|
||||
"$HOME/vcpkg/bootstrap-vcpkg.sh"
|
||||
|
||||
echo "VCPKG_ROOT=$HOME/vcpkg" >> "$GITHUB_ENV"
|
||||
echo "$HOME/vcpkg" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Android dependencies
|
||||
run: |
|
||||
"$VCPKG_ROOT/vcpkg" install \
|
||||
boost:arm64-android \
|
||||
openssl:arm64-android \
|
||||
yaml-cpp:arm64-android
|
||||
|
||||
- name: Configure Android arm64-v8a build
|
||||
run: |
|
||||
rm -rf build-android-arm64
|
||||
|
||||
cmake -S . -B build-android-arm64 \
|
||||
-G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
|
||||
-DVCPKG_TARGET_TRIPLET=arm64-android \
|
||||
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=android-23 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-z,max-page-size=16384" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"
|
||||
|
||||
- name: Build Android arm64-v8a binary
|
||||
run: |
|
||||
cmake --build build-android-arm64 -j"$(nproc)"
|
||||
|
||||
- name: Collect Android binary and libraries
|
||||
run: |
|
||||
mkdir -p out/android/arm64-v8a
|
||||
|
||||
if [ ! -f build-android-arm64/core/nipovpn ]; then
|
||||
echo "Android binary not found:"
|
||||
find build-android-arm64 -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp build-android-arm64/core/nipovpn out/android/arm64-v8a/libnipovpn_exec.so
|
||||
chmod 755 out/android/arm64-v8a/libnipovpn_exec.so
|
||||
|
||||
find "$VCPKG_ROOT/installed/arm64-android" -type f -name "*.so*" -exec cp -v {} out/android/arm64-v8a/ \; || true
|
||||
|
||||
ls -lah out/android/arm64-v8a/
|
||||
|
||||
- name: Check 16 KB ELF alignment
|
||||
run: |
|
||||
READELF="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf"
|
||||
|
||||
for file in out/android/arm64-v8a/*.so*; do
|
||||
echo "Checking $file"
|
||||
"$READELF" -l "$file" | grep -A3 LOAD || true
|
||||
|
||||
if "$READELF" -l "$file" | awk '/LOAD/ && $NF != "0x4000" { bad=1 } END { exit bad }'; then
|
||||
echo "OK: $file is 16 KB aligned"
|
||||
else
|
||||
echo "ERROR: $file is not 16 KB aligned"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Android artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-dev-android-arm64-v8a
|
||||
path: out/android/arm64-v8a/
|
||||
|
||||
release-android:
|
||||
needs:
|
||||
- build-android
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Download Android artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn-dev-android-arm64-v8a
|
||||
path: ./android-artifact
|
||||
|
||||
- name: Show downloaded Android artifact
|
||||
run: |
|
||||
ls -lah android-artifact
|
||||
|
||||
- name: Create Android GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: dev-android-v${{ env.PACKAGE_VERSION }}
|
||||
name: dev Android Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
android-artifact/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,157 @@
|
||||
name: Build Android Binary - main
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- 'core/**'
|
||||
- 'CMakeLists.txt'
|
||||
- 'core/CMakeLists.txt'
|
||||
- '.github/workflows/android-main.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.53
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
git \
|
||||
curl \
|
||||
zip \
|
||||
unzip \
|
||||
tar \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
libtool
|
||||
|
||||
- name: Setup Android NDK r29
|
||||
uses: nttld/setup-ndk@v1
|
||||
with:
|
||||
ndk-version: r29
|
||||
add-to-path: true
|
||||
|
||||
- name: Show Android NDK information
|
||||
run: |
|
||||
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME"
|
||||
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT"
|
||||
ls -lah "$ANDROID_NDK_HOME"
|
||||
|
||||
- name: Setup vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
|
||||
"$HOME/vcpkg/bootstrap-vcpkg.sh"
|
||||
|
||||
echo "VCPKG_ROOT=$HOME/vcpkg" >> "$GITHUB_ENV"
|
||||
echo "$HOME/vcpkg" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Android dependencies
|
||||
run: |
|
||||
"$VCPKG_ROOT/vcpkg" install \
|
||||
boost:arm64-android \
|
||||
openssl:arm64-android \
|
||||
yaml-cpp:arm64-android
|
||||
|
||||
- name: Configure Android arm64-v8a build
|
||||
run: |
|
||||
rm -rf build-android-arm64
|
||||
|
||||
cmake -S . -B build-android-arm64 \
|
||||
-G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
|
||||
-DVCPKG_TARGET_TRIPLET=arm64-android \
|
||||
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=android-23 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-z,max-page-size=16384" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"
|
||||
|
||||
- name: Build Android arm64-v8a binary
|
||||
run: |
|
||||
cmake --build build-android-arm64 -j"$(nproc)"
|
||||
|
||||
- name: Collect Android binary and libraries
|
||||
run: |
|
||||
mkdir -p out/android/arm64-v8a
|
||||
|
||||
if [ ! -f build-android-arm64/core/nipovpn ]; then
|
||||
echo "Android binary not found:"
|
||||
find build-android-arm64 -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp build-android-arm64/core/nipovpn out/android/arm64-v8a/libnipovpn_exec.so
|
||||
chmod 755 out/android/arm64-v8a/libnipovpn_exec.so
|
||||
|
||||
find "$VCPKG_ROOT/installed/arm64-android" -type f -name "*.so*" -exec cp -v {} out/android/arm64-v8a/ \; || true
|
||||
|
||||
ls -lah out/android/arm64-v8a/
|
||||
|
||||
- name: Check 16 KB ELF alignment
|
||||
run: |
|
||||
READELF="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf"
|
||||
|
||||
for file in out/android/arm64-v8a/*.so*; do
|
||||
echo "Checking $file"
|
||||
"$READELF" -l "$file" | grep -A3 LOAD || true
|
||||
|
||||
if "$READELF" -l "$file" | awk '/LOAD/ && $NF != "0x4000" { bad=1 } END { exit bad }'; then
|
||||
echo "OK: $file is 16 KB aligned"
|
||||
else
|
||||
echo "ERROR: $file is not 16 KB aligned"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Android artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-main-android-arm64-v8a
|
||||
path: out/android/arm64-v8a/
|
||||
|
||||
release-android:
|
||||
needs:
|
||||
- build-android
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Download Android artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn-main-android-arm64-v8a
|
||||
path: ./android-artifact
|
||||
|
||||
- name: Show downloaded Android artifact
|
||||
run: |
|
||||
ls -lah android-artifact
|
||||
|
||||
- name: Create Android GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: android-v${{ env.PACKAGE_VERSION }}
|
||||
name: Android Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
android-artifact/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,157 @@
|
||||
name: Build Android Binary - MORI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- mori
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- 'core/**'
|
||||
- 'CMakeLists.txt'
|
||||
- 'core/CMakeLists.txt'
|
||||
- '.github/workflows/android-mori.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.1.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
git \
|
||||
curl \
|
||||
zip \
|
||||
unzip \
|
||||
tar \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
libtool
|
||||
|
||||
- name: Setup Android NDK r29
|
||||
uses: nttld/setup-ndk@v1
|
||||
with:
|
||||
ndk-version: r29
|
||||
add-to-path: true
|
||||
|
||||
- name: Show Android NDK information
|
||||
run: |
|
||||
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME"
|
||||
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT"
|
||||
ls -lah "$ANDROID_NDK_HOME"
|
||||
|
||||
- name: Setup vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
|
||||
"$HOME/vcpkg/bootstrap-vcpkg.sh"
|
||||
|
||||
echo "VCPKG_ROOT=$HOME/vcpkg" >> "$GITHUB_ENV"
|
||||
echo "$HOME/vcpkg" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Android dependencies
|
||||
run: |
|
||||
"$VCPKG_ROOT/vcpkg" install \
|
||||
boost:arm64-android \
|
||||
openssl:arm64-android \
|
||||
yaml-cpp:arm64-android
|
||||
|
||||
- name: Configure Android arm64-v8a build
|
||||
run: |
|
||||
rm -rf build-android-arm64
|
||||
|
||||
cmake -S . -B build-android-arm64 \
|
||||
-G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
|
||||
-DVCPKG_TARGET_TRIPLET=arm64-android \
|
||||
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=android-23 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-z,max-page-size=16384" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"
|
||||
|
||||
- name: Build Android arm64-v8a binary
|
||||
run: |
|
||||
cmake --build build-android-arm64 -j"$(nproc)"
|
||||
|
||||
- name: Collect Android binary and libraries
|
||||
run: |
|
||||
mkdir -p out/android/arm64-v8a
|
||||
|
||||
if [ ! -f build-android-arm64/core/nipovpn ]; then
|
||||
echo "Android binary not found:"
|
||||
find build-android-arm64 -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp build-android-arm64/core/nipovpn out/android/arm64-v8a/libnipovpn_exec.so
|
||||
chmod 755 out/android/arm64-v8a/libnipovpn_exec.so
|
||||
|
||||
find "$VCPKG_ROOT/installed/arm64-android" -type f -name "*.so*" -exec cp -v {} out/android/arm64-v8a/ \; || true
|
||||
|
||||
ls -lah out/android/arm64-v8a/
|
||||
|
||||
- name: Check 16 KB ELF alignment
|
||||
run: |
|
||||
READELF="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf"
|
||||
|
||||
for file in out/android/arm64-v8a/*.so*; do
|
||||
echo "Checking $file"
|
||||
"$READELF" -l "$file" | grep -A3 LOAD || true
|
||||
|
||||
if "$READELF" -l "$file" | awk '/LOAD/ && $NF != "0x4000" { bad=1 } END { exit bad }'; then
|
||||
echo "OK: $file is 16 KB aligned"
|
||||
else
|
||||
echo "ERROR: $file is not 16 KB aligned"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Android artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-mori-android-arm64-v8a
|
||||
path: out/android/arm64-v8a/
|
||||
|
||||
release-android:
|
||||
needs:
|
||||
- build-android
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Download Android artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn-mori-android-arm64-v8a
|
||||
path: ./android-artifact
|
||||
|
||||
- name: Show downloaded Android artifact
|
||||
run: |
|
||||
ls -lah android-artifact
|
||||
|
||||
- name: Create Android GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: mori-android-v${{ env.PACKAGE_VERSION }}
|
||||
name: Mori Android Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
android-artifact/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -1,75 +0,0 @@
|
||||
name: Build and Release Debian Package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- mori/cf
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- '.github/workflows/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dpkg-dev build-essential lintian fakeroot devscripts cmake libssl-dev libboost-all-dev libyaml-cpp-dev
|
||||
|
||||
- name: Build the package
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
make -j$(nproc)
|
||||
cd ..
|
||||
mkdir -p nipovpn/usr/bin/
|
||||
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
|
||||
dpkg-deb --build nipovpn/ build/nipovpn_cf_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
- name: Upload the Debian nipovpn as an artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
path: build/nipovpn_cf_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
- name: Show nipovpn information
|
||||
run: |
|
||||
dpkg -I build/nipovpn_cf_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
path: ./
|
||||
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
with:
|
||||
tag_name: 'v.10.1.1.${{ github.run_number }}'
|
||||
release_name: Staging v.10.1.1.${{ github.run_number }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
|
||||
- name: Upload Debian Package to Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./nipovpn_cf_v1-1-${{ github.run_number }}.deb
|
||||
asset_name: nipovpn_cf_v1-1-${{ github.run_number }}.deb
|
||||
asset_content_type: application/octet-stream
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Build and Release Debian Package
|
||||
name: Build and Release Package - dev
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,70 +6,294 @@ on:
|
||||
- dev
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- '.github/workflows/**'
|
||||
- 'core/**'
|
||||
- 'nipovpn/**'
|
||||
- '.github/workflows/debian-dev.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.2.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
package_arch: amd64
|
||||
- arch: arm64
|
||||
package_arch: arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up dependencies
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dpkg-dev build-essential lintian fakeroot devscripts cmake libssl-dev libboost-all-dev libyaml-cpp-dev
|
||||
sudo apt-get install -y \
|
||||
dpkg-dev \
|
||||
build-essential \
|
||||
lintian \
|
||||
fakeroot \
|
||||
devscripts \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
- name: Build the package
|
||||
- name: Build binary
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
make -j$(nproc)
|
||||
cd ..
|
||||
mkdir -p nipovpn/usr/bin/
|
||||
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
|
||||
dpkg-deb --build nipovpn/ build/nipovpn_staging_v1-1-${{ github.run_number }}.deb
|
||||
rm -rf build
|
||||
|
||||
- name: Upload the Debian nipovpn as an artifact
|
||||
if [ "${{ matrix.arch }}" = "arm64" ]; then
|
||||
docker run --rm --platform linux/arm64 \
|
||||
-v "$PWD:/src" \
|
||||
-w /src \
|
||||
ubuntu:24.04 \
|
||||
bash -c '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
'
|
||||
|
||||
sudo chown -R $USER:$USER build
|
||||
else
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
fi
|
||||
|
||||
- name: Build Debian package
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_dev_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
|
||||
rm -rf package-root
|
||||
cp -a nipovpn package-root
|
||||
|
||||
mkdir -p package-root/usr/bin
|
||||
cp build/core/nipovpn package-root/usr/bin/nipovpn
|
||||
chmod 755 package-root/usr/bin/nipovpn
|
||||
|
||||
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" package-root/DEBIAN/control
|
||||
sed -i -E "s/^Architecture[[:space:]]*:.*/Architecture: ${{ matrix.package_arch }}/" package-root/DEBIAN/control
|
||||
|
||||
sed -i -e '$a\' package-root/DEBIAN/control
|
||||
|
||||
echo "Final control file:"
|
||||
cat package-root/DEBIAN/control
|
||||
|
||||
grep "^Version: ${PACKAGE_VERSION}$" package-root/DEBIAN/control
|
||||
grep "^Architecture: ${{ matrix.package_arch }}$" package-root/DEBIAN/control
|
||||
|
||||
mkdir -p build
|
||||
dpkg-deb --build package-root "build/${PACKAGE_FILE}"
|
||||
|
||||
ls -lah build/
|
||||
|
||||
- name: Show Debian package information
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_dev_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
dpkg -I "build/${PACKAGE_FILE}"
|
||||
dpkg -c "build/${PACKAGE_FILE}"
|
||||
|
||||
- name: Upload Debian package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
path: build/nipovpn_staging_v1-1-${{ github.run_number }}.deb
|
||||
name: nipovpn-dev-deb-${{ matrix.arch }}
|
||||
path: build/nipovpn_dev_${{ env.PACKAGE_VERSION }}_${{ matrix.arch }}.deb
|
||||
|
||||
- name: Show nipovpn information
|
||||
build-termux:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: nipovpn-src
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
dpkg -I build/nipovpn_staging_v1-1-${{ github.run_number }}.deb
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
git \
|
||||
wget \
|
||||
unzip \
|
||||
curl \
|
||||
python3 \
|
||||
python3-pip \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
autopoint \
|
||||
bison \
|
||||
flex \
|
||||
gettext \
|
||||
gperf \
|
||||
help2man \
|
||||
lzip \
|
||||
libarchive-tools \
|
||||
rsync \
|
||||
texinfo \
|
||||
jq
|
||||
|
||||
- name: Install Android NDK r29
|
||||
run: |
|
||||
mkdir -p "$HOME/lib"
|
||||
cd "$HOME/lib"
|
||||
|
||||
wget -q https://dl.google.com/android/repository/android-ndk-r29-linux.zip
|
||||
unzip -q android-ndk-r29-linux.zip
|
||||
|
||||
EXTRACTED_DIR="$(find "$HOME/lib" -maxdepth 1 -type d -name 'android-ndk-r29*' | head -n 1)"
|
||||
|
||||
if [ -z "$EXTRACTED_DIR" ]; then
|
||||
echo "Android NDK r29 directory not found"
|
||||
ls -lah "$HOME/lib"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -sfn "$EXTRACTED_DIR" "$HOME/lib/android-ndk-r29"
|
||||
|
||||
echo "NDK=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
echo "ANDROID_NDK_ROOT=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
|
||||
ls -ld "$HOME/lib/android-ndk-r29"
|
||||
|
||||
- name: Clone termux-packages
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/termux/termux-packages.git
|
||||
|
||||
- name: Create Termux package recipe
|
||||
run: |
|
||||
mkdir -p termux-packages/packages/nipovpn
|
||||
|
||||
cat > termux-packages/packages/nipovpn/build.sh <<'EOF'
|
||||
TERMUX_PKG_HOMEPAGE=https://github.com/MortezaBashsiz/nipovpn
|
||||
TERMUX_PKG_DESCRIPTION="Powerful and secure HTTP/S proxy"
|
||||
TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_MAINTAINER="Morteza Bashsiz"
|
||||
TERMUX_PKG_VERSION=@PACKAGE_VERSION@
|
||||
TERMUX_PKG_SRCURL=file://@GITHUB_WORKSPACE@/nipovpn-src
|
||||
TERMUX_PKG_SHA256=SKIP_CHECKSUM
|
||||
TERMUX_PKG_DEPENDS="openssl, boost, libyaml-cpp"
|
||||
TERMUX_PKG_BUILD_IN_SRC=false
|
||||
|
||||
termux_step_configure() {
|
||||
cmake -S "$TERMUX_PKG_SRCDIR" \
|
||||
-B "$TERMUX_PKG_BUILDDIR" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX="$TERMUX_PREFIX"
|
||||
}
|
||||
|
||||
termux_step_make() {
|
||||
cmake --build "$TERMUX_PKG_BUILDDIR" -j "$(nproc)"
|
||||
}
|
||||
|
||||
termux_step_make_install() {
|
||||
install -Dm755 \
|
||||
"$TERMUX_PKG_BUILDDIR/core/nipovpn" \
|
||||
"$TERMUX_PREFIX/bin/nipovpn"
|
||||
|
||||
if [ -d "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn" ]; then
|
||||
mkdir -p "$TERMUX_PREFIX/etc/nipovpn"
|
||||
cp -a "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn/." \
|
||||
"$TERMUX_PREFIX/etc/nipovpn/"
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
sed -i "s|@PACKAGE_VERSION@|${PACKAGE_VERSION}|g" termux-packages/packages/nipovpn/build.sh
|
||||
sed -i "s|@GITHUB_WORKSPACE@|${GITHUB_WORKSPACE}|g" termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
cat termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
- name: Prepare Termux build data dir
|
||||
run: |
|
||||
sudo mkdir -p /data
|
||||
sudo chown -R $USER:$USER /data
|
||||
|
||||
- name: Build Termux aarch64 package
|
||||
working-directory: termux-packages
|
||||
run: |
|
||||
./build-package.sh -I -a aarch64 nipovpn
|
||||
|
||||
- name: Collect Termux package
|
||||
run: |
|
||||
mkdir -p out
|
||||
|
||||
TERMUX_DEB="$(find termux-packages/output -type f -name '*.deb' | head -n 1)"
|
||||
|
||||
if [ -z "$TERMUX_DEB" ]; then
|
||||
echo "No Termux .deb package found"
|
||||
find termux-packages/output -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$TERMUX_DEB" "out/nipovpn_dev_${PACKAGE_VERSION}_termux_aarch64.deb"
|
||||
|
||||
ls -lah out/
|
||||
|
||||
- name: Upload Termux package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-dev-termux-aarch64
|
||||
path: out/nipovpn_dev_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
|
||||
release:
|
||||
needs: build
|
||||
needs:
|
||||
- build
|
||||
- build-termux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download build artifact
|
||||
- name: Download package artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
pattern: nipovpn-dev-*
|
||||
merge-multiple: true
|
||||
path: ./
|
||||
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
with:
|
||||
tag_name: 'v.0.1.1.${{ github.run_number }}'
|
||||
release_name: Staging v.0.1.1.${{ github.run_number }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
- name: Show downloaded files
|
||||
run: |
|
||||
ls -lah
|
||||
|
||||
- name: Upload Debian Package to Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
- name: Create dev GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./nipovpn_staging_v1-1-${{ github.run_number }}.deb
|
||||
asset_name: nipovpn_staging_v1-1-${{ github.run_number }}.deb
|
||||
asset_content_type: application/octet-stream
|
||||
tag_name: dev-v${{ env.PACKAGE_VERSION }}
|
||||
name: dev Version v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
nipovpn_dev_${{ env.PACKAGE_VERSION }}_amd64.deb
|
||||
nipovpn_dev_${{ env.PACKAGE_VERSION }}_arm64.deb
|
||||
nipovpn_dev_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,299 @@
|
||||
name: Build and Release Package - Main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- 'core/**'
|
||||
- 'nipovpn/**'
|
||||
- '.github/workflows/debian-main.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.53
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
package_arch: amd64
|
||||
- arch: arm64
|
||||
package_arch: arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
dpkg-dev \
|
||||
build-essential \
|
||||
lintian \
|
||||
fakeroot \
|
||||
devscripts \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
rm -rf build
|
||||
|
||||
if [ "${{ matrix.arch }}" = "arm64" ]; then
|
||||
docker run --rm --platform linux/arm64 \
|
||||
-v "$PWD:/src" \
|
||||
-w /src \
|
||||
ubuntu:24.04 \
|
||||
bash -c '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
'
|
||||
|
||||
sudo chown -R $USER:$USER build
|
||||
else
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
fi
|
||||
|
||||
- name: Build Debian package
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
|
||||
rm -rf package-root
|
||||
cp -a nipovpn package-root
|
||||
|
||||
mkdir -p package-root/usr/bin
|
||||
cp build/core/nipovpn package-root/usr/bin/nipovpn
|
||||
chmod 755 package-root/usr/bin/nipovpn
|
||||
|
||||
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" package-root/DEBIAN/control
|
||||
sed -i -E "s/^Architecture[[:space:]]*:.*/Architecture: ${{ matrix.package_arch }}/" package-root/DEBIAN/control
|
||||
|
||||
sed -i -e '$a\' package-root/DEBIAN/control
|
||||
|
||||
echo "Final control file:"
|
||||
cat package-root/DEBIAN/control
|
||||
|
||||
grep "^Version: ${PACKAGE_VERSION}$" package-root/DEBIAN/control
|
||||
grep "^Architecture: ${{ matrix.package_arch }}$" package-root/DEBIAN/control
|
||||
|
||||
mkdir -p build
|
||||
dpkg-deb --build package-root "build/${PACKAGE_FILE}"
|
||||
|
||||
ls -lah build/
|
||||
|
||||
- name: Show Debian package information
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
dpkg -I "build/${PACKAGE_FILE}"
|
||||
dpkg -c "build/${PACKAGE_FILE}"
|
||||
|
||||
- name: Upload Debian package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-deb-${{ matrix.arch }}
|
||||
path: build/nipovpn_${{ env.PACKAGE_VERSION }}_${{ matrix.arch }}.deb
|
||||
|
||||
build-termux:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: nipovpn-src
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
git \
|
||||
wget \
|
||||
unzip \
|
||||
curl \
|
||||
python3 \
|
||||
python3-pip \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
autopoint \
|
||||
bison \
|
||||
flex \
|
||||
gettext \
|
||||
gperf \
|
||||
help2man \
|
||||
lzip \
|
||||
libarchive-tools \
|
||||
rsync \
|
||||
texinfo \
|
||||
jq
|
||||
|
||||
- name: Install Android NDK r29
|
||||
run: |
|
||||
mkdir -p "$HOME/lib"
|
||||
cd "$HOME/lib"
|
||||
|
||||
wget -q https://dl.google.com/android/repository/android-ndk-r29-linux.zip
|
||||
unzip -q android-ndk-r29-linux.zip
|
||||
|
||||
EXTRACTED_DIR="$(find "$HOME/lib" -maxdepth 1 -type d -name 'android-ndk-r29*' | head -n 1)"
|
||||
|
||||
if [ -z "$EXTRACTED_DIR" ]; then
|
||||
echo "Android NDK r29 directory not found"
|
||||
ls -lah "$HOME/lib"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -sfn "$EXTRACTED_DIR" "$HOME/lib/android-ndk-r29"
|
||||
|
||||
echo "NDK=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
echo "ANDROID_NDK_ROOT=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
|
||||
ls -ld "$HOME/lib/android-ndk-r29"
|
||||
|
||||
- name: Clone termux-packages
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/termux/termux-packages.git
|
||||
|
||||
- name: Create Termux package recipe
|
||||
run: |
|
||||
mkdir -p termux-packages/packages/nipovpn
|
||||
|
||||
cat > termux-packages/packages/nipovpn/build.sh <<'EOF'
|
||||
TERMUX_PKG_HOMEPAGE=https://github.com/MortezaBashsiz/nipovpn
|
||||
TERMUX_PKG_DESCRIPTION="Powerful and secure HTTP/S proxy"
|
||||
TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_MAINTAINER="Morteza Bashsiz"
|
||||
TERMUX_PKG_VERSION=@PACKAGE_VERSION@
|
||||
TERMUX_PKG_SRCURL=file://@GITHUB_WORKSPACE@/nipovpn-src
|
||||
TERMUX_PKG_SHA256=SKIP_CHECKSUM
|
||||
TERMUX_PKG_DEPENDS="openssl, boost, libyaml-cpp"
|
||||
TERMUX_PKG_BUILD_IN_SRC=false
|
||||
|
||||
termux_step_configure() {
|
||||
cmake -S "$TERMUX_PKG_SRCDIR" \
|
||||
-B "$TERMUX_PKG_BUILDDIR" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX="$TERMUX_PREFIX"
|
||||
}
|
||||
|
||||
termux_step_make() {
|
||||
cmake --build "$TERMUX_PKG_BUILDDIR" -j "$(nproc)"
|
||||
}
|
||||
|
||||
termux_step_make_install() {
|
||||
install -Dm755 \
|
||||
"$TERMUX_PKG_BUILDDIR/core/nipovpn" \
|
||||
"$TERMUX_PREFIX/bin/nipovpn"
|
||||
|
||||
if [ -d "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn" ]; then
|
||||
mkdir -p "$TERMUX_PREFIX/etc/nipovpn"
|
||||
cp -a "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn/." \
|
||||
"$TERMUX_PREFIX/etc/nipovpn/"
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
sed -i "s|@PACKAGE_VERSION@|${PACKAGE_VERSION}|g" termux-packages/packages/nipovpn/build.sh
|
||||
sed -i "s|@GITHUB_WORKSPACE@|${GITHUB_WORKSPACE}|g" termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
cat termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
- name: Prepare Termux build data dir
|
||||
run: |
|
||||
sudo mkdir -p /data
|
||||
sudo chown -R $USER:$USER /data
|
||||
|
||||
- name: Build Termux aarch64 package
|
||||
working-directory: termux-packages
|
||||
run: |
|
||||
./build-package.sh -I -a aarch64 nipovpn
|
||||
|
||||
- name: Collect Termux package
|
||||
run: |
|
||||
mkdir -p out
|
||||
|
||||
TERMUX_DEB="$(find termux-packages/output -type f -name '*.deb' | head -n 1)"
|
||||
|
||||
if [ -z "$TERMUX_DEB" ]; then
|
||||
echo "No Termux .deb package found"
|
||||
find termux-packages/output -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$TERMUX_DEB" "out/nipovpn_${PACKAGE_VERSION}_termux_aarch64.deb"
|
||||
|
||||
ls -lah out/
|
||||
|
||||
- name: Upload Termux package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-termux-aarch64
|
||||
path: out/nipovpn_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
|
||||
release:
|
||||
needs:
|
||||
- build
|
||||
- build-termux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download package artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: nipovpn-*
|
||||
merge-multiple: true
|
||||
path: ./
|
||||
|
||||
- name: Show downloaded files
|
||||
run: |
|
||||
ls -lah
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ env.PACKAGE_VERSION }}
|
||||
name: Version v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
nipovpn_${{ env.PACKAGE_VERSION }}_amd64.deb
|
||||
nipovpn_${{ env.PACKAGE_VERSION }}_arm64.deb
|
||||
nipovpn_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,299 @@
|
||||
name: Build and Release Package - MORI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- mori
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
- 'core/**'
|
||||
- 'nipovpn/**'
|
||||
- '.github/workflows/debian-mori.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.1.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
package_arch: amd64
|
||||
- arch: arm64
|
||||
package_arch: arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
dpkg-dev \
|
||||
build-essential \
|
||||
lintian \
|
||||
fakeroot \
|
||||
devscripts \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
rm -rf build
|
||||
|
||||
if [ "${{ matrix.arch }}" = "arm64" ]; then
|
||||
docker run --rm --platform linux/arm64 \
|
||||
-v "$PWD:/src" \
|
||||
-w /src \
|
||||
ubuntu:24.04 \
|
||||
bash -c '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
libssl-dev \
|
||||
libboost-all-dev \
|
||||
libyaml-cpp-dev
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
'
|
||||
|
||||
sudo chown -R $USER:$USER build
|
||||
else
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j$(nproc)
|
||||
fi
|
||||
|
||||
- name: Build Debian package
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_mori_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
|
||||
rm -rf package-root
|
||||
cp -a nipovpn package-root
|
||||
|
||||
mkdir -p package-root/usr/bin
|
||||
cp build/core/nipovpn package-root/usr/bin/nipovpn
|
||||
chmod 755 package-root/usr/bin/nipovpn
|
||||
|
||||
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" package-root/DEBIAN/control
|
||||
sed -i -E "s/^Architecture[[:space:]]*:.*/Architecture: ${{ matrix.package_arch }}/" package-root/DEBIAN/control
|
||||
|
||||
sed -i -e '$a\' package-root/DEBIAN/control
|
||||
|
||||
echo "Final control file:"
|
||||
cat package-root/DEBIAN/control
|
||||
|
||||
grep "^Version: ${PACKAGE_VERSION}$" package-root/DEBIAN/control
|
||||
grep "^Architecture: ${{ matrix.package_arch }}$" package-root/DEBIAN/control
|
||||
|
||||
mkdir -p build
|
||||
dpkg-deb --build package-root "build/${PACKAGE_FILE}"
|
||||
|
||||
ls -lah build/
|
||||
|
||||
- name: Show Debian package information
|
||||
run: |
|
||||
PACKAGE_FILE="nipovpn_mori_${PACKAGE_VERSION}_${{ matrix.arch }}.deb"
|
||||
dpkg -I "build/${PACKAGE_FILE}"
|
||||
dpkg -c "build/${PACKAGE_FILE}"
|
||||
|
||||
- name: Upload Debian package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-mori-deb-${{ matrix.arch }}
|
||||
path: build/nipovpn_mori_${{ env.PACKAGE_VERSION }}_${{ matrix.arch }}.deb
|
||||
|
||||
build-termux:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: nipovpn-src
|
||||
|
||||
- name: Install host dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
git \
|
||||
wget \
|
||||
unzip \
|
||||
curl \
|
||||
python3 \
|
||||
python3-pip \
|
||||
build-essential \
|
||||
cmake \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
autopoint \
|
||||
bison \
|
||||
flex \
|
||||
gettext \
|
||||
gperf \
|
||||
help2man \
|
||||
lzip \
|
||||
libarchive-tools \
|
||||
rsync \
|
||||
texinfo \
|
||||
jq
|
||||
|
||||
- name: Install Android NDK r29
|
||||
run: |
|
||||
mkdir -p "$HOME/lib"
|
||||
cd "$HOME/lib"
|
||||
|
||||
wget -q https://dl.google.com/android/repository/android-ndk-r29-linux.zip
|
||||
unzip -q android-ndk-r29-linux.zip
|
||||
|
||||
EXTRACTED_DIR="$(find "$HOME/lib" -maxdepth 1 -type d -name 'android-ndk-r29*' | head -n 1)"
|
||||
|
||||
if [ -z "$EXTRACTED_DIR" ]; then
|
||||
echo "Android NDK r29 directory not found"
|
||||
ls -lah "$HOME/lib"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -sfn "$EXTRACTED_DIR" "$HOME/lib/android-ndk-r29"
|
||||
|
||||
echo "NDK=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
echo "ANDROID_NDK_ROOT=$HOME/lib/android-ndk-r29" >> "$GITHUB_ENV"
|
||||
|
||||
ls -ld "$HOME/lib/android-ndk-r29"
|
||||
|
||||
- name: Clone termux-packages
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/termux/termux-packages.git
|
||||
|
||||
- name: Create Termux package recipe
|
||||
run: |
|
||||
mkdir -p termux-packages/packages/nipovpn
|
||||
|
||||
cat > termux-packages/packages/nipovpn/build.sh <<'EOF'
|
||||
TERMUX_PKG_HOMEPAGE=https://github.com/MortezaBashsiz/nipovpn
|
||||
TERMUX_PKG_DESCRIPTION="Powerful and secure HTTP/S proxy"
|
||||
TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_MAINTAINER="Morteza Bashsiz"
|
||||
TERMUX_PKG_VERSION=@PACKAGE_VERSION@
|
||||
TERMUX_PKG_SRCURL=file://@GITHUB_WORKSPACE@/nipovpn-src
|
||||
TERMUX_PKG_SHA256=SKIP_CHECKSUM
|
||||
TERMUX_PKG_DEPENDS="openssl, boost, libyaml-cpp"
|
||||
TERMUX_PKG_BUILD_IN_SRC=false
|
||||
|
||||
termux_step_configure() {
|
||||
cmake -S "$TERMUX_PKG_SRCDIR" \
|
||||
-B "$TERMUX_PKG_BUILDDIR" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX="$TERMUX_PREFIX"
|
||||
}
|
||||
|
||||
termux_step_make() {
|
||||
cmake --build "$TERMUX_PKG_BUILDDIR" -j "$(nproc)"
|
||||
}
|
||||
|
||||
termux_step_make_install() {
|
||||
install -Dm755 \
|
||||
"$TERMUX_PKG_BUILDDIR/core/nipovpn" \
|
||||
"$TERMUX_PREFIX/bin/nipovpn"
|
||||
|
||||
if [ -d "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn" ]; then
|
||||
mkdir -p "$TERMUX_PREFIX/etc/nipovpn"
|
||||
cp -a "$TERMUX_PKG_SRCDIR/nipovpn/etc/nipovpn/." \
|
||||
"$TERMUX_PREFIX/etc/nipovpn/"
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
sed -i "s|@PACKAGE_VERSION@|${PACKAGE_VERSION}|g" termux-packages/packages/nipovpn/build.sh
|
||||
sed -i "s|@GITHUB_WORKSPACE@|${GITHUB_WORKSPACE}|g" termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
cat termux-packages/packages/nipovpn/build.sh
|
||||
|
||||
- name: Prepare Termux build data dir
|
||||
run: |
|
||||
sudo mkdir -p /data
|
||||
sudo chown -R $USER:$USER /data
|
||||
|
||||
- name: Build Termux aarch64 package
|
||||
working-directory: termux-packages
|
||||
run: |
|
||||
./build-package.sh -I -a aarch64 nipovpn
|
||||
|
||||
- name: Collect Termux package
|
||||
run: |
|
||||
mkdir -p out
|
||||
|
||||
TERMUX_DEB="$(find termux-packages/output -type f -name '*.deb' | head -n 1)"
|
||||
|
||||
if [ -z "$TERMUX_DEB" ]; then
|
||||
echo "No Termux .deb package found"
|
||||
find termux-packages/output -type f || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$TERMUX_DEB" "out/nipovpn_mori_${PACKAGE_VERSION}_termux_aarch64.deb"
|
||||
|
||||
ls -lah out/
|
||||
|
||||
- name: Upload Termux package artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-mori-termux-aarch64
|
||||
path: out/nipovpn_mori_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
|
||||
release:
|
||||
needs:
|
||||
- build
|
||||
- build-termux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download package artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: nipovpn-mori-*
|
||||
merge-multiple: true
|
||||
path: ./
|
||||
|
||||
- name: Show downloaded files
|
||||
run: |
|
||||
ls -lah
|
||||
|
||||
- name: Create Mori GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: mori-v${{ env.PACKAGE_VERSION }}
|
||||
name: Mori Version v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: |
|
||||
nipovpn_mori_${{ env.PACKAGE_VERSION }}_amd64.deb
|
||||
nipovpn_mori_${{ env.PACKAGE_VERSION }}_arm64.deb
|
||||
nipovpn_mori_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -1,75 +0,0 @@
|
||||
name: Build and Release Debian Package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'core/src/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dpkg-dev build-essential lintian fakeroot devscripts cmake libssl-dev libboost-all-dev libyaml-cpp-dev
|
||||
|
||||
- name: Build the package
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
make -j$(nproc)
|
||||
cd ..
|
||||
mkdir -p nipovpn/usr/bin/
|
||||
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
|
||||
dpkg-deb --build nipovpn/ build/nipovpn_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
- name: Upload the Debian nipovpn as an artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
path: build/nipovpn_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
- name: Show nipovpn information
|
||||
run: |
|
||||
dpkg -I build/nipovpn_v1-1-${{ github.run_number }}.deb
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nipovpn
|
||||
path: ./
|
||||
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
with:
|
||||
tag_name: 'v1.1.${{ github.run_number }}'
|
||||
release_name: Version v1.1.${{ github.run_number }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload Debian Package to Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./nipovpn_v1-1-${{ github.run_number }}.deb
|
||||
asset_name: nipovpn_v1-1-${{ github.run_number }}.deb
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
name: Build Windows Binary - dev
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- 'core/**'
|
||||
- 'server/**'
|
||||
- 'agent/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/windows-dev.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.2.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW64
|
||||
update: true
|
||||
install: >-
|
||||
git
|
||||
mingw-w64-x86_64-gcc
|
||||
mingw-w64-x86_64-cmake
|
||||
mingw-w64-x86_64-ninja
|
||||
mingw-w64-x86_64-boost
|
||||
mingw-w64-x86_64-openssl
|
||||
mingw-w64-x86_64-yaml-cpp
|
||||
mingw-w64-x86_64-zip
|
||||
|
||||
- name: Build nipovpn.exe
|
||||
run: |
|
||||
rm -rf build dist
|
||||
mkdir -p build dist
|
||||
|
||||
cmake -S . -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
cmake --build build -j$(nproc)
|
||||
|
||||
cp build/core/nipovpn.exe dist/
|
||||
|
||||
- name: Copy required DLL files
|
||||
run: |
|
||||
cd dist
|
||||
|
||||
for dll in $(ldd nipovpn.exe | grep 'mingw64' | awk '{print $3}'); do
|
||||
cp "$dll" .
|
||||
done
|
||||
|
||||
ls -lah
|
||||
|
||||
- name: Add config files
|
||||
run: |
|
||||
mkdir -p dist/etc/nipovpn
|
||||
|
||||
if [ -d nipovpn/etc/nipovpn ]; then
|
||||
cp -a nipovpn/etc/nipovpn/. dist/etc/nipovpn/
|
||||
fi
|
||||
|
||||
- name: Create ZIP package
|
||||
run: |
|
||||
cd dist
|
||||
zip -r ../nipovpn_dev_${PACKAGE_VERSION}_windows_x86_64.zip .
|
||||
|
||||
- name: Upload Windows artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-dev-windows-x86_64
|
||||
path: nipovpn_dev_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
|
||||
- name: Create dev Windows Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: dev-windows-v${{ env.PACKAGE_VERSION }}
|
||||
name: dev Windows Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: nipovpn_dev_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,97 @@
|
||||
name: Build Windows Binary - main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'core/**'
|
||||
- 'server/**'
|
||||
- 'agent/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/windows-main.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.53
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW64
|
||||
update: true
|
||||
install: >-
|
||||
git
|
||||
mingw-w64-x86_64-gcc
|
||||
mingw-w64-x86_64-cmake
|
||||
mingw-w64-x86_64-ninja
|
||||
mingw-w64-x86_64-boost
|
||||
mingw-w64-x86_64-openssl
|
||||
mingw-w64-x86_64-yaml-cpp
|
||||
mingw-w64-x86_64-zip
|
||||
|
||||
- name: Build nipovpn.exe
|
||||
run: |
|
||||
rm -rf build dist
|
||||
mkdir -p build dist
|
||||
|
||||
cmake -S . -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
cmake --build build -j$(nproc)
|
||||
|
||||
cp build/core/nipovpn.exe dist/
|
||||
|
||||
- name: Copy required DLL files
|
||||
run: |
|
||||
cd dist
|
||||
|
||||
for dll in $(ldd nipovpn.exe | grep 'mingw64' | awk '{print $3}'); do
|
||||
cp "$dll" .
|
||||
done
|
||||
|
||||
ls -lah
|
||||
|
||||
- name: Add config files
|
||||
run: |
|
||||
mkdir -p dist/etc/nipovpn
|
||||
|
||||
if [ -d nipovpn/etc/nipovpn ]; then
|
||||
cp -a nipovpn/etc/nipovpn/. dist/etc/nipovpn/
|
||||
fi
|
||||
|
||||
- name: Create ZIP package
|
||||
run: |
|
||||
cd dist
|
||||
zip -r ../nipovpn_${PACKAGE_VERSION}_windows_x86_64.zip .
|
||||
|
||||
- name: Upload Windows artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-windows-x86_64
|
||||
path: nipovpn_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
|
||||
- name: Create main Windows Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: windows-v${{ env.PACKAGE_VERSION }}
|
||||
name: Windows Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: nipovpn_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -0,0 +1,98 @@
|
||||
name: Build Windows Binary - mori
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- mori
|
||||
paths:
|
||||
- 'core/**'
|
||||
- 'server/**'
|
||||
- 'agent/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/windows-mori.yml'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 0.1.${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW64
|
||||
update: true
|
||||
install: >-
|
||||
git
|
||||
zip
|
||||
mingw-w64-x86_64-gcc
|
||||
mingw-w64-x86_64-cmake
|
||||
mingw-w64-x86_64-ninja
|
||||
mingw-w64-x86_64-boost
|
||||
mingw-w64-x86_64-openssl
|
||||
mingw-w64-x86_64-yaml-cpp
|
||||
|
||||
- name: Build nipovpn.exe
|
||||
run: |
|
||||
rm -rf build dist
|
||||
mkdir -p build dist
|
||||
|
||||
cmake -S . -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CXX_FLAGS="-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DNOGDI -DOUT=NIPO_OUT"
|
||||
|
||||
cmake --build build -j$(nproc)
|
||||
|
||||
cp build/core/nipovpn.exe dist/
|
||||
|
||||
- name: Copy required DLL files
|
||||
run: |
|
||||
cd dist
|
||||
|
||||
for dll in $(ldd nipovpn.exe | grep 'mingw64' | awk '{print $3}'); do
|
||||
cp "$dll" .
|
||||
done
|
||||
|
||||
ls -lah
|
||||
|
||||
- name: Add config files
|
||||
run: |
|
||||
mkdir -p dist/etc/nipovpn
|
||||
|
||||
if [ -d nipovpn/etc/nipovpn ]; then
|
||||
cp -a nipovpn/etc/nipovpn/. dist/etc/nipovpn/
|
||||
fi
|
||||
|
||||
- name: Create ZIP package
|
||||
run: |
|
||||
cd dist
|
||||
zip -r ../nipovpn_mori_${PACKAGE_VERSION}_windows_x86_64.zip .
|
||||
|
||||
- name: Upload Windows artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nipovpn-mori-windows-x86_64
|
||||
path: nipovpn_mori_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
|
||||
- name: Create Mori Windows Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: mori-windows-v${{ env.PACKAGE_VERSION }}
|
||||
name: Mori Windows Binary v${{ env.PACKAGE_VERSION }}
|
||||
prerelease: true
|
||||
files: nipovpn_mori_${{ env.PACKAGE_VERSION }}_windows_x86_64.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -1,4 +1,4 @@
|
||||
# NipoVPN (Not ready yet :D)
|
||||
# NipoVPN
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -36,6 +36,9 @@ To contribute take a look at [contribution page](https://github.com/MortezaBashs
|
||||
|
||||
Build from source for [Linux](guides/BuildLinux.md)
|
||||
|
||||
## Termux
|
||||
|
||||
Build from source for [Linux](guides/InstallTermux.md)
|
||||
|
||||
|
||||
## Run
|
||||
|
||||
@@ -38,3 +38,7 @@ target_include_directories(${CORE_TARGET} PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
target_link_libraries(${CORE_TARGET} ${Boost_LIBRARIES})
|
||||
target_link_libraries(${CORE_TARGET} ${YAML_CPP_LIBRARIES})
|
||||
target_link_libraries(${CORE_TARGET} ${OPENSSL_LIBRARIES})
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${CORE_TARGET} ws2_32 mswsock)
|
||||
endif()
|
||||
+68
-69
@@ -1,5 +1,7 @@
|
||||
#include "agenthandler.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
AgentHandler::AgentHandler(boost::asio::streambuf &readBuffer,
|
||||
boost::asio::streambuf &writeBuffer,
|
||||
const std::shared_ptr<Config> &config,
|
||||
@@ -19,16 +21,13 @@ AgentHandler::AgentHandler(boost::asio::streambuf &readBuffer,
|
||||
connect_ = false;
|
||||
}
|
||||
|
||||
|
||||
AgentHandler::~AgentHandler() {}
|
||||
|
||||
|
||||
void AgentHandler::handle() {
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
if (!request_->detectType()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [AgentHandler handle] [NOT HTTP Request] [Request] : " +
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [NOT HTTP Request] [Request] : " +
|
||||
streambufToString(readBuffer_),
|
||||
Log::Level::DEBUG);
|
||||
client_->socketShutdown();
|
||||
@@ -36,19 +35,16 @@ void AgentHandler::handle() {
|
||||
}
|
||||
|
||||
if (request_->parsedHttpRequest().target().length() > 0) {
|
||||
log_->write("[" + to_string(uuid_) + "] [FORWARD] [SRC " + clientConnStr_ +
|
||||
"] [DST " +
|
||||
std::string(request_->parsedHttpRequest().target()) +
|
||||
"]",
|
||||
log_->write("[" + to_string(uuid_) + "] [FORWARD] [SRC " + clientConnStr_ + "] [DST " +
|
||||
std::string(request_->parsedHttpRequest().target()) + "]",
|
||||
Log::Level::INFO);
|
||||
}
|
||||
|
||||
if (config_->agent().tlsEnable && !client_->tlsEnabled()) {
|
||||
if (config_->general().tlsEnable && !client_->tlsEnabled()) {
|
||||
if (!client_->enableTlsClient()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TLS] [ERROR] [Init Client Context] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp +
|
||||
":" + std::to_string(config_->agent().serverPort) + "]",
|
||||
log_->write("[" + to_string(uuid_) + "] [TLS] [ERROR] [Init Client Context] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp + ":" +
|
||||
std::to_string(config_->agent().serverPort) + "]",
|
||||
Log::Level::ERROR);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
@@ -56,67 +52,64 @@ void AgentHandler::handle() {
|
||||
}
|
||||
|
||||
if (!client_->isOpen()) {
|
||||
connect_ = true;
|
||||
|
||||
if (!client_->doConnect(config_->agent().serverIp,
|
||||
config_->agent().serverPort)) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [CONNECT] [ERROR] [To Server] [SRC " + clientConnStr_ +
|
||||
"] [DST " + config_->agent().serverIp + ":" +
|
||||
if (!client_->doConnect(config_->agent().serverIp, config_->agent().serverPort)) {
|
||||
log_->write("[" + to_string(uuid_) + "] [CONNECT] [ERROR] [To Server] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp + ":" +
|
||||
std::to_string(config_->agent().serverPort) + "]",
|
||||
Log::Level::INFO);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (client_->tlsEnabled()) {
|
||||
if (!client_->doHandshakeClient()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TLS] [ERROR] [Client Handshake] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp +
|
||||
":" + std::to_string(config_->agent().serverPort) + "]",
|
||||
Log::Level::ERROR);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
if (client_->tlsEnabled() && !client_->doHandshakeClient()) {
|
||||
log_->write("[" + to_string(uuid_) + "] [TLS] [ERROR] [Client Handshake] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp + ":" +
|
||||
std::to_string(config_->agent().serverPort) + "]",
|
||||
Log::Level::ERROR);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BoolStr encryption{false, std::string("FAILED")};
|
||||
encryption = aes256Encrypt(hexStreambufToStr(readBuffer_), config_->general().token);
|
||||
|
||||
if (encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Encryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
if (!encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Encryption Failed] : [ " +
|
||||
encryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string innerRequest = encode64(encryption.message);
|
||||
|
||||
std::string hostHeader = config_->general().fakeUrl;
|
||||
auto pos = hostHeader.find("://");
|
||||
if (pos != std::string::npos) hostHeader = hostHeader.substr(pos + 3);
|
||||
pos = hostHeader.find('/');
|
||||
if (pos != std::string::npos) hostHeader = hostHeader.substr(0, pos);
|
||||
const std::string action =
|
||||
request_->httpType() == HTTP::HttpType::connect ? "open" : "request";
|
||||
|
||||
std::ostringstream outer;
|
||||
outer << "POST /relay HTTP/1.1\r\n"
|
||||
<< "Host: " << hostHeader << "\r\n"
|
||||
<< "User-Agent: Mozilla/5.0\r\n"
|
||||
const bool directTunnelOpen =
|
||||
config_->general().tunnelEnable &&
|
||||
request_->httpType() == HTTP::HttpType::connect;
|
||||
|
||||
outer << config_->randomMethod() + " /" + config_->randomEndPoint() + " HTTP/" << config_->agent().httpVersion << "\r\n"
|
||||
<< "Host: " << relayHostHeader(config_) << "\r\n"
|
||||
<< "User-Agent: " << config_->agent().userAgent << "\r\n"
|
||||
<< "Accept: */*\r\n"
|
||||
<< "Content-Type: application/octet-stream\r\n"
|
||||
<< "Content-Type: application/text\r\n"
|
||||
<< "X-Nipo-Session: " << to_string(uuid_) << "\r\n"
|
||||
<< "X-Nipo-Action: " << action << "\r\n"
|
||||
<< "Content-Length: " << innerRequest.size() << "\r\n"
|
||||
<< "Connection: keep-alive\r\n"
|
||||
<< "Connection: "
|
||||
<< ((config_->general().connectionReuse || directTunnelOpen) ? "keep-alive" : "close")
|
||||
<< "\r\n"
|
||||
<< "\r\n"
|
||||
<< innerRequest;
|
||||
|
||||
copyStringToStreambuf(outer.str(), readBuffer_);
|
||||
|
||||
client_->doWrite(readBuffer_);
|
||||
client_->doReadAgent();
|
||||
|
||||
if (client_->readBuffer().size() == 0) {
|
||||
if (client_->readBuffer().size() == 0 && !config_->general().connectionReuse) {
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
@@ -124,36 +117,42 @@ void AgentHandler::handle() {
|
||||
const std::string outerResponse = streambufToString(client_->readBuffer());
|
||||
const auto bodyPos = outerResponse.find("\r\n\r\n");
|
||||
if (bodyPos == std::string::npos) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [AgentHandler handle] [NOT HTTP Response] [Response] : " +
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [NOT HTTP Response] [Response] : " +
|
||||
outerResponse,
|
||||
Log::Level::DEBUG);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
BoolStr decryption{false, std::string("FAILED")};
|
||||
decryption = aes256Decrypt(outerResponse.substr(bodyPos + 4), config_->general().token);
|
||||
if (decryption.ok) {
|
||||
copyStringToStreambuf(decryption.message, writeBuffer_);
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Decryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Decryption Failed] : [ " +
|
||||
decryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
}
|
||||
|
||||
|
||||
const std::string innerResponse = decryption.message;
|
||||
|
||||
if (request_->httpType() == HTTP::HttpType::connect) {
|
||||
copyStringToStreambuf(innerResponse, writeBuffer_);
|
||||
connect_ = true;
|
||||
end_ = false;
|
||||
const std::string encryptedBody = outerResponse.substr(bodyPos + 4);
|
||||
if (encryptedBody.empty()) {
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
copyStringToStreambuf(innerResponse, writeBuffer_);
|
||||
connect_ = false;
|
||||
BoolStr decryption{false, std::string("FAILED")};
|
||||
decryption = aes256Decrypt(encryptedBody, config_->general().token);
|
||||
if (!decryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Decryption Failed] : [ " +
|
||||
decryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
client_->socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
copyStringToStreambuf(decryption.message, writeBuffer_);
|
||||
log_->write("[" + to_string(uuid_) + "] [AgentHandler handle] [Decryption Done]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
connect_ = request_->httpType() == HTTP::HttpType::connect;
|
||||
end_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string AgentHandler::relayHostHeader(const std::shared_ptr<Config> &config) {
|
||||
std::string hostHeader = config->randomFakeUrl();
|
||||
auto pos = hostHeader.find("://");
|
||||
if (pos != std::string::npos) hostHeader = hostHeader.substr(pos + 3);
|
||||
pos = hostHeader.find('/');
|
||||
if (pos != std::string::npos) hostHeader = hostHeader.substr(0, pos);
|
||||
return hostHeader;
|
||||
}
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
const std::string &clientConnStr,
|
||||
boost::uuids::uuid uuid);
|
||||
|
||||
std::string relayHostHeader(const std::shared_ptr<Config> &config);
|
||||
const std::shared_ptr<Config> &config_;
|
||||
const std::shared_ptr<Log> &log_;
|
||||
const TCPClient::pointer &client_;
|
||||
|
||||
+110
-27
@@ -1,5 +1,6 @@
|
||||
#include "config.hpp"
|
||||
|
||||
|
||||
Config::Config(const RunMode &mode, const std::string &filePath)
|
||||
: runMode_(mode),
|
||||
filePath_(filePath),
|
||||
@@ -8,30 +9,30 @@ Config::Config(const RunMode &mode, const std::string &filePath)
|
||||
listenIp_("127.0.0.1"),
|
||||
listenPort_(0),
|
||||
general_({configYaml_["general"]["token"].as<std::string>(),
|
||||
configYaml_["general"]["fakeUrl"].as<std::string>(),
|
||||
configYaml_["general"]["method"].as<std::string>(),
|
||||
configYaml_["general"]["fakeUrls"].as<std::vector<std::string>>(),
|
||||
configYaml_["general"]["methods"].as<std::vector<std::string>>(),
|
||||
configYaml_["general"]["endPoints"].as<std::vector<std::string>>(),
|
||||
configYaml_["general"]["timeout"].as<unsigned short>(),
|
||||
configYaml_["general"]["chunkHeader"].as<std::string>()}),
|
||||
configYaml_["general"]["pullTimeout"].as<unsigned short>(),
|
||||
configYaml_["general"]["tunnelEnable"].as<bool>(false),
|
||||
configYaml_["general"]["connectionReuse"].as<bool>(false),
|
||||
configYaml_["general"]["tlsEnable"].as<bool>(false),
|
||||
configYaml_["general"]["tlsVerifyPeer"].as<bool>(false),
|
||||
configYaml_["general"]["tlsCertFile"].as<std::string>(""),
|
||||
configYaml_["general"]["tlsKeyFile"].as<std::string>(""),
|
||||
configYaml_["general"]["tlsCaFile"].as<std::string>("")}),
|
||||
log_({configYaml_["log"]["logLevel"].as<std::string>(),
|
||||
configYaml_["log"]["logFile"].as<std::string>()}),
|
||||
server_({configYaml_["server"]["threads"].as<unsigned short>(),
|
||||
configYaml_["server"]["listenIp"].as<std::string>(),
|
||||
configYaml_["server"]["listenPort"].as<unsigned short>(),
|
||||
configYaml_["server"]["tlsEnable"].as<bool>(false),
|
||||
configYaml_["server"]["tlsVerifyPeer"].as<bool>(false),
|
||||
configYaml_["server"]["tlsCertFile"].as<std::string>(""),
|
||||
configYaml_["server"]["tlsKeyFile"].as<std::string>(""),
|
||||
configYaml_["server"]["tlsCaFile"].as<std::string>("")}),
|
||||
configYaml_["server"]["listenPort"].as<unsigned short>()}),
|
||||
agent_({configYaml_["agent"]["threads"].as<unsigned short>(),
|
||||
configYaml_["agent"]["listenIp"].as<std::string>(),
|
||||
configYaml_["agent"]["listenPort"].as<unsigned short>(),
|
||||
configYaml_["agent"]["serverIp"].as<std::string>(),
|
||||
configYaml_["agent"]["serverPort"].as<unsigned short>(),
|
||||
configYaml_["agent"]["httpVersion"].as<std::string>(),
|
||||
configYaml_["agent"]["userAgent"].as<std::string>(),
|
||||
configYaml_["agent"]["tlsEnable"].as<bool>(false),
|
||||
configYaml_["agent"]["tlsVerifyPeer"].as<bool>(false),
|
||||
configYaml_["agent"]["tlsCaFile"].as<std::string>("")}) {
|
||||
configYaml_["agent"]["userAgent"].as<std::string>()}) {
|
||||
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
@@ -66,38 +67,72 @@ Config::~Config() = default;
|
||||
|
||||
std::string Config::toString() const {
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "\nConfig :\n"
|
||||
<< " General :\n"
|
||||
<< " token: " << general_.token << "\n"
|
||||
<< " fakeUrl: " << general_.fakeUrl << "\n"
|
||||
<< " method: " << general_.method << "\n"
|
||||
<< " fakeUrls: ";
|
||||
|
||||
for (std::size_t i = 0; i < general_.fakeUrls.size(); ++i) {
|
||||
ss << general_.fakeUrls[i];
|
||||
|
||||
if (i != general_.fakeUrls.size() - 1) {
|
||||
ss << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << "\n"
|
||||
<< " methods: ";
|
||||
|
||||
for (std::size_t i = 0; i < general_.methods.size(); ++i) {
|
||||
ss << general_.methods[i];
|
||||
|
||||
if (i != general_.methods.size() - 1) {
|
||||
ss << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << "\n"
|
||||
<< " endPoints: ";
|
||||
|
||||
for (std::size_t i = 0; i < general_.endPoints.size(); ++i) {
|
||||
ss << general_.endPoints[i];
|
||||
|
||||
if (i != general_.endPoints.size() - 1) {
|
||||
ss << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << "\n"
|
||||
<< " timeout: " << general_.timeout << "\n"
|
||||
<< " chunkHeader: " << general_.chunkHeader << "\n"
|
||||
<< " pullTimeout: " << general_.pullTimeout << "\n"
|
||||
<< " tunnelEnable: " << std::boolalpha << general_.tunnelEnable << "\n"
|
||||
<< " connectionReuse: " << std::boolalpha << general_.connectionReuse << "\n"
|
||||
<< " tlsEnable: " << std::boolalpha << general_.tlsEnable << "\n"
|
||||
<< " tlsVerifyPeer: " << std::boolalpha << general_.tlsVerifyPeer << "\n"
|
||||
<< " tlsCertFile: " << general_.tlsCertFile << "\n"
|
||||
<< " tlsKeyFile: " << general_.tlsKeyFile << "\n"
|
||||
<< " tlsCaFile: " << general_.tlsCaFile << "\n"
|
||||
|
||||
<< " Log :\n"
|
||||
<< " logLevel: " << log_.level << "\n"
|
||||
<< " logFile: " << log_.file << "\n"
|
||||
<< " server :\n"
|
||||
|
||||
<< " Server :\n"
|
||||
<< " threads: " << server_.threads << "\n"
|
||||
<< " listenIp: " << server_.listenIp << "\n"
|
||||
<< " listenPort: " << server_.listenPort << "\n"
|
||||
<< " tlsEnable: " << server_.tlsEnable << "\n"
|
||||
<< " tlsVerifyPeer: " << server_.tlsVerifyPeer << "\n"
|
||||
<< " tlsCertFile: " << server_.tlsCertFile << "\n"
|
||||
<< " tlsKeyFile: " << server_.tlsKeyFile << "\n"
|
||||
<< " tlsCaFile: " << server_.tlsCaFile << "\n"
|
||||
<< " agent :\n"
|
||||
|
||||
<< " Agent :\n"
|
||||
<< " threads: " << agent_.threads << "\n"
|
||||
<< " listenIp: " << agent_.listenIp << "\n"
|
||||
<< " listenPort: " << agent_.listenPort << "\n"
|
||||
<< " serverIp: " << agent_.serverIp << "\n"
|
||||
<< " serverPort: " << agent_.serverPort << "\n"
|
||||
<< " httpVersion: " << agent_.httpVersion << "\n"
|
||||
<< " userAgent: " << agent_.userAgent << "\n"
|
||||
<< " tlsEnable: " << agent_.tlsEnable << "\n"
|
||||
<< " tlsVerifyPeer: " << agent_.tlsVerifyPeer << "\n"
|
||||
<< " tlsCaFile: " << agent_.tlsCaFile << "\n";
|
||||
<< " userAgent: " << agent_.userAgent << "\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
@@ -173,4 +208,52 @@ std::string Config::modeToString() const {
|
||||
default:
|
||||
return "UNKNOWN MODE";
|
||||
}
|
||||
}
|
||||
|
||||
std::string Config::randomFakeUrl() const {
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
if (general_.fakeUrls.empty()) {
|
||||
return "www.google.com";
|
||||
}
|
||||
|
||||
static thread_local std::mt19937 generator{std::random_device{}()};
|
||||
|
||||
std::uniform_int_distribution<std::size_t> distribution(
|
||||
0,
|
||||
general_.fakeUrls.size() - 1);
|
||||
|
||||
return general_.fakeUrls[distribution(generator)];
|
||||
}
|
||||
|
||||
std::string Config::randomMethod() const {
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
if (general_.methods.empty()) {
|
||||
return "GET";
|
||||
}
|
||||
|
||||
static thread_local std::mt19937 generator{std::random_device{}()};
|
||||
|
||||
std::uniform_int_distribution<std::size_t> distribution(
|
||||
0,
|
||||
general_.methods.size() - 1);
|
||||
|
||||
return general_.methods[distribution(generator)];
|
||||
}
|
||||
|
||||
std::string Config::randomEndPoint() const {
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
if (general_.endPoints.empty()) {
|
||||
return "api";
|
||||
}
|
||||
|
||||
static thread_local std::mt19937 generator{std::random_device{}()};
|
||||
|
||||
std::uniform_int_distribution<std::size_t> distribution(
|
||||
0,
|
||||
general_.endPoints.size() - 1);
|
||||
|
||||
return general_.endPoints[distribution(generator)];
|
||||
}
|
||||
+19
-13
@@ -4,8 +4,10 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "general.hpp"
|
||||
|
||||
@@ -18,10 +20,18 @@ class Config : private Uncopyable {
|
||||
private:
|
||||
struct General {
|
||||
std::string token;
|
||||
std::string fakeUrl;
|
||||
std::string method;
|
||||
std::vector<std::string> fakeUrls;
|
||||
std::vector<std::string> methods;
|
||||
std::vector<std::string> endPoints;
|
||||
unsigned short timeout;
|
||||
std::string chunkHeader;
|
||||
unsigned short pullTimeout;
|
||||
bool tunnelEnable;
|
||||
bool connectionReuse;
|
||||
bool tlsEnable;
|
||||
bool tlsVerifyPeer;
|
||||
std::string tlsCertFile;
|
||||
std::string tlsKeyFile;
|
||||
std::string tlsCaFile;
|
||||
};
|
||||
|
||||
struct Log {
|
||||
@@ -33,12 +43,6 @@ private:
|
||||
unsigned short threads;
|
||||
std::string listenIp;
|
||||
unsigned short listenPort;
|
||||
|
||||
bool tlsEnable;
|
||||
bool tlsVerifyPeer;
|
||||
std::string tlsCertFile;
|
||||
std::string tlsKeyFile;
|
||||
std::string tlsCaFile;
|
||||
};
|
||||
|
||||
struct Agent {
|
||||
@@ -49,10 +53,6 @@ private:
|
||||
unsigned short serverPort;
|
||||
std::string httpVersion;
|
||||
std::string userAgent;
|
||||
|
||||
bool tlsEnable;
|
||||
bool tlsVerifyPeer;
|
||||
std::string tlsCaFile;
|
||||
};
|
||||
|
||||
const RunMode &runMode_;
|
||||
@@ -107,4 +107,10 @@ public:
|
||||
std::string modeToString() const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string randomFakeUrl() const;
|
||||
|
||||
std::string randomMethod() const;
|
||||
|
||||
std::string randomEndPoint() const;
|
||||
};
|
||||
@@ -325,10 +325,12 @@ inline BoolStr validateConfig(int argc, const char *argv[]) {
|
||||
|
||||
try {
|
||||
configYaml["general"]["token"].as<std::string>();
|
||||
configYaml["general"]["fakeUrl"].as<std::string>();
|
||||
configYaml["general"]["method"].as<std::string>();
|
||||
configYaml["general"]["fakeUrls"].as<std::vector<std::string>>();
|
||||
configYaml["general"]["methods"].as<std::vector<std::string>>();
|
||||
configYaml["general"]["endPoints"].as<std::vector<std::string>>();
|
||||
configYaml["general"]["timeout"].as<unsigned short>();
|
||||
configYaml["general"]["chunkHeader"].as<std::string>();
|
||||
configYaml["general"]["pullTimeout"].as<unsigned short>();
|
||||
configYaml["general"]["tunnelEnable"].as<bool>();
|
||||
} catch (const std::exception &e) {
|
||||
result.message = std::string("Error in 'general' block: ") + e.what() + "\n";
|
||||
return result;
|
||||
|
||||
+8
-10
@@ -11,7 +11,6 @@ HTTP::HTTP(const std::shared_ptr<Config> &config,
|
||||
httpType_(HTTP::HttpType::https),
|
||||
parsedTlsRequest_{"", "", TlsTypes::TLSHandshake},
|
||||
uuid_(uuid) {
|
||||
chunkHeader_ = "no";
|
||||
}
|
||||
|
||||
HTTP::HTTP(const HTTP &http)
|
||||
@@ -21,7 +20,6 @@ HTTP::HTTP(const HTTP &http)
|
||||
parsedHttpRequest_(http.parsedHttpRequest_),
|
||||
parsedTlsRequest_(http.parsedTlsRequest_),
|
||||
uuid_(http.uuid_) {
|
||||
chunkHeader_ = "no";
|
||||
}
|
||||
|
||||
|
||||
@@ -158,10 +156,11 @@ bool HTTP::parseTls() {
|
||||
}
|
||||
|
||||
const std::string HTTP::genHttpPostReqString(const std::string &body) const {
|
||||
return std::string(config_->general().method + " " +
|
||||
config_->general().fakeUrl + " HTTP/" +
|
||||
auto fakeUrl = config_->randomFakeUrl();
|
||||
return std::string(config_->randomMethod() + " " +
|
||||
fakeUrl + " HTTP/" +
|
||||
config_->agent().httpVersion + "\r\n") +
|
||||
"Host: " + config_->general().fakeUrl + "\r\n" +
|
||||
"Host: " + fakeUrl + "\r\n" +
|
||||
"User-Agent: " + config_->agent().userAgent + "\r\n" +
|
||||
"Accept: */*\r\n" + "Connection: keep-alive\r\n" +
|
||||
"Content-Length: " + std::to_string(body.length()) + "\r\n" +
|
||||
@@ -169,10 +168,11 @@ const std::string HTTP::genHttpPostReqString(const std::string &body) const {
|
||||
}
|
||||
|
||||
const std::string HTTP::genHttpRestPostReqString() const {
|
||||
return std::string(config_->general().method + " " +
|
||||
config_->general().fakeUrl + " HTTP/" +
|
||||
auto fakeUrl = config_->randomFakeUrl();
|
||||
return std::string(config_->randomMethod() + " " +
|
||||
fakeUrl + " HTTP/" +
|
||||
config_->agent().httpVersion + "\r\n") +
|
||||
"Host: " + config_->general().fakeUrl + "\r\n" +
|
||||
"Host: " + fakeUrl + "\r\n" +
|
||||
"User-Agent: " + config_->agent().userAgent + "\r\n" +
|
||||
"Accept: */*\r\n" + "Connection: keep-alive\r\n" +
|
||||
"Rest: yes\r\n" + "COMP\r\n\r\n";
|
||||
@@ -182,7 +182,6 @@ const std::string HTTP::genHttpOkResString(const std::string &body) const {
|
||||
return std::string("HTTP/1.1 200 OK\r\n") +
|
||||
"Content-Type: application/x-www-form-urlencoded\r\n" +
|
||||
"Content-Length: " + std::to_string(body.length()) + "\r\n" +
|
||||
config_->general().chunkHeader + ": " + chunkHeader_ + "\r\n" +
|
||||
"Connection: keep-alive\r\n" + "Cache-Control: no-cache\r\n" +
|
||||
"Pragma: no-cache\r\n" + "\r\n" + body + "COMP\r\n\r\n";
|
||||
}
|
||||
@@ -228,7 +227,6 @@ void HTTP::setIPPort() {
|
||||
? withoutScheme
|
||||
: withoutScheme.substr(0, slashPos);
|
||||
} else {
|
||||
// origin-form like "/relay"
|
||||
auto hostIt = parsedHttpRequest_.find("Host");
|
||||
if (hostIt != parsedHttpRequest_.end()) {
|
||||
hostPort = boost::lexical_cast<std::string>(hostIt->value());
|
||||
|
||||
@@ -83,8 +83,6 @@ public:
|
||||
|
||||
const std::string restoString() const;
|
||||
|
||||
std::string chunkHeader_;
|
||||
|
||||
private:
|
||||
explicit HTTP(const std::shared_ptr<Config> &config,
|
||||
const std::shared_ptr<Log> &log,
|
||||
|
||||
+7
-1
@@ -7,6 +7,12 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
using runnerThread = std::thread;
|
||||
#else
|
||||
using runnerThread = std::jthread;
|
||||
#endif
|
||||
|
||||
#include "config.hpp"
|
||||
#include "log.hpp"
|
||||
#include "tcpserver.hpp"
|
||||
@@ -34,7 +40,7 @@ private:
|
||||
|
||||
std::atomic<bool> running_;
|
||||
|
||||
std::vector<std::jthread> threadPool_;
|
||||
std::vector<runnerThread> threadPool_;
|
||||
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
|
||||
};
|
||||
+322
-108
@@ -1,5 +1,69 @@
|
||||
#include "serverhandler.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
std::mutex ServerHandler::sessionsMutex_;
|
||||
std::unordered_map<std::string, TCPClient::pointer> ServerHandler::sessions_;
|
||||
|
||||
std::string ServerHandler::HttpUtils::lowerCopy(std::string s) {
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string ServerHandler::HttpUtils::trimCopy(std::string s) {
|
||||
while (!s.empty() && (s.front() == ' ' || s.front() == '\t')) {
|
||||
s.erase(s.begin());
|
||||
}
|
||||
|
||||
while (!s.empty() &&
|
||||
(s.back() == ' ' ||
|
||||
s.back() == '\t' ||
|
||||
s.back() == '\r' ||
|
||||
s.back() == '\n')) {
|
||||
s.pop_back();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string ServerHandler::HttpUtils::getRawHeader(const std::string &headers,
|
||||
const std::string &name) {
|
||||
std::istringstream iss(headers);
|
||||
std::string line;
|
||||
|
||||
const std::string prefix = lowerCopy(name) + ":";
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
|
||||
std::string lower = lowerCopy(line);
|
||||
|
||||
if (lower.rfind(prefix, 0) == 0) {
|
||||
return trimCopy(line.substr(name.size() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ServerHandler::HttpUtils::extractHttpBody(const std::string &msg) {
|
||||
const auto pos = msg.find("\r\n\r\n");
|
||||
|
||||
if (pos == std::string::npos) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return msg.substr(pos + 4);
|
||||
}
|
||||
|
||||
ServerHandler::ServerHandler(boost::asio::streambuf &readBuffer,
|
||||
boost::asio::streambuf &writeBuffer,
|
||||
const std::shared_ptr<Config> &config,
|
||||
@@ -21,52 +85,198 @@ ServerHandler::ServerHandler(boost::asio::streambuf &readBuffer,
|
||||
|
||||
ServerHandler::~ServerHandler() {}
|
||||
|
||||
void ServerHandler::makePlainHttpResponse(const std::string &body,
|
||||
const std::string &status,
|
||||
const std::string &connection) {
|
||||
std::ostringstream outer;
|
||||
|
||||
outer << "HTTP/1.1 " << status << "\r\n"
|
||||
<< "Content-Type: application/text\r\n"
|
||||
<< "Content-Length: " << body.size() << "\r\n"
|
||||
<< "Connection: " << connection << "\r\n"
|
||||
<< "\r\n"
|
||||
<< body;
|
||||
|
||||
copyStringToStreambuf(outer.str(), writeBuffer_);
|
||||
|
||||
end_ = false;
|
||||
connect_ = false;
|
||||
}
|
||||
|
||||
void ServerHandler::makeEncryptedHttpResponse(const std::string &plainBody,
|
||||
const std::string &status,
|
||||
const std::string &connection) {
|
||||
BoolStr encryption = aes256Encrypt(plainBody, config_->general().token);
|
||||
|
||||
if (!encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler] [Encryption Failed] " + encryption.message,
|
||||
Log::Level::DEBUG);
|
||||
|
||||
makePlainHttpResponse("", "500 Internal Server Error", "close");
|
||||
return;
|
||||
}
|
||||
|
||||
makePlainHttpResponse(encryption.message, status, connection);
|
||||
}
|
||||
|
||||
void ServerHandler::handle() {
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
if (!request_->detectType()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [NOT HTTP Request From Agent] "
|
||||
"[Request] : " +
|
||||
streambufToString(readBuffer_),
|
||||
Log::Level::DEBUG);
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [NOT HTTP Request From Agent] [Request] : " +
|
||||
streambufToString(readBuffer_),
|
||||
Log::Level::DEBUG);
|
||||
|
||||
client_->socket().close();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &outerReq = request_->parsedHttpRequest();
|
||||
const std::string method = std::string(outerReq.method_string());
|
||||
const std::string target = std::string(outerReq.target());
|
||||
|
||||
if (method != "POST" || target != "/relay") {
|
||||
copyStringToStreambuf(
|
||||
"HTTP/1.1 404 Not Found\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"Connection: close\r\n\r\n",
|
||||
writeBuffer_);
|
||||
const std::string outerRaw = streambufToString(readBuffer_);
|
||||
const auto outerHeaderEnd = outerRaw.find("\r\n\r\n");
|
||||
const std::string outerHeaders =
|
||||
outerHeaderEnd == std::string::npos
|
||||
? ""
|
||||
: outerRaw.substr(0, outerHeaderEnd + 2);
|
||||
|
||||
const std::string session =
|
||||
HttpUtils::getRawHeader(outerHeaders, "X-Nipo-Session");
|
||||
|
||||
const std::string action =
|
||||
HttpUtils::getRawHeader(outerHeaders, "X-Nipo-Action");
|
||||
|
||||
std::string requestBody = std::string(outerReq.body());
|
||||
|
||||
if (requestBody.empty()) {
|
||||
requestBody = HttpUtils::extractHttpBody(outerRaw);
|
||||
}
|
||||
|
||||
BoolStr decryption{false, std::string("FAILED")};
|
||||
|
||||
try {
|
||||
decryption = aes256Decrypt(
|
||||
decode64(requestBody),
|
||||
config_->general().token);
|
||||
} catch (const std::exception &e) {
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [Base64 Decode Failed] " + e.what(),
|
||||
Log::Level::DEBUG);
|
||||
|
||||
makePlainHttpResponse("", "400 Bad Request", "close");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decryption.ok) {
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [Decryption Failed] : [ " +
|
||||
decryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
BoolStr decryption{false, std::string("FAILED")};
|
||||
decryption = aes256Decrypt(decode64(std::string(outerReq.body())), config_->general().token);
|
||||
makePlainHttpResponse("", "400 Bad Request", "close");
|
||||
return;
|
||||
}
|
||||
|
||||
if (decryption.ok) {
|
||||
copyStringToStreambuf(decryption.message, writeBuffer_);
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Decryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Decryption Failed] : [ " +
|
||||
decryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) + "] [ServerHandler handle] [Decryption Done]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
if (action == "send") {
|
||||
TCPClient::pointer targetClient;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionsMutex_);
|
||||
auto it = sessions_.find(session);
|
||||
|
||||
if (it != sessions_.end()) {
|
||||
targetClient = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetClient || !targetClient->isOpen()) {
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
boost::asio::streambuf tunnelBuf;
|
||||
copyStringToStreambuf(hexToASCII(decryption.message), tunnelBuf);
|
||||
targetClient->doWrite(tunnelBuf);
|
||||
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == "recv") {
|
||||
TCPClient::pointer targetClient;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionsMutex_);
|
||||
auto it = sessions_.find(session);
|
||||
|
||||
if (it != sessions_.end()) {
|
||||
targetClient = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetClient || !targetClient->isOpen()) {
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
boost::system::error_code ec;
|
||||
std::size_t available = targetClient->socket().available(ec);
|
||||
|
||||
if (ec || available == 0) {
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<char> data(std::min<std::size_t>(available, 65536));
|
||||
std::size_t n = targetClient->socket().read_some(
|
||||
boost::asio::buffer(data),
|
||||
ec);
|
||||
|
||||
if (ec || n == 0) {
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
makeEncryptedHttpResponse(
|
||||
std::string(data.data(), n),
|
||||
"200 OK",
|
||||
(config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == "close") {
|
||||
std::lock_guard<std::mutex> sessionLock(sessionsMutex_);
|
||||
auto it = sessions_.find(session);
|
||||
|
||||
if (it != sessions_.end()) {
|
||||
it->second->socketShutdown();
|
||||
sessions_.erase(it);
|
||||
}
|
||||
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string innerRequest = hexToASCII(decryption.message);
|
||||
|
||||
const std::size_t headerEnd = innerRequest.find("\r\n\r\n");
|
||||
|
||||
if (headerEnd == std::string::npos) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [INNER REQUEST MISSING HEADER END]",
|
||||
Log::Level::DEBUG);
|
||||
client_->socket().close();
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [INNER REQUEST MISSING HEADER END]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
makeEncryptedHttpResponse("", "400 Bad Request", "close");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,101 +284,120 @@ void ServerHandler::handle() {
|
||||
const std::string pendingTunnelData = innerRequest.substr(headerEnd + 4);
|
||||
|
||||
copyStringToStreambuf(innerHeaders, readBuffer_);
|
||||
|
||||
HTTP::pointer inner = HTTP::create(config_, log_, readBuffer_, uuid_);
|
||||
|
||||
if (!inner->detectType()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [NOT INNER HTTP Request] [Request] : " +
|
||||
streambufToString(readBuffer_),
|
||||
Log::Level::DEBUG);
|
||||
client_->socket().close();
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [ServerHandler handle] [NOT INNER HTTP Request] [Request] : " +
|
||||
streambufToString(readBuffer_),
|
||||
Log::Level::DEBUG);
|
||||
|
||||
makeEncryptedHttpResponse("", "400 Bad Request", "close");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (inner->httpType()) {
|
||||
case HTTP::HttpType::connect: {
|
||||
if (client_->doConnect(inner->dstIP(), inner->dstPort())) {
|
||||
log_->write("[" + to_string(uuid_) + "] [CONNECT] [SRC " + clientConnStr_ +
|
||||
"] [DST " + inner->dstIP() + ":" +
|
||||
std::to_string(inner->dstPort()) + "]",
|
||||
if (config_->general().tunnelEnable) {
|
||||
if (!client_->doConnect(inner->dstIP(), inner->dstPort())) {
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [ERROR] [Resolving Host] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
inner->dstIP() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
|
||||
if (!pendingTunnelData.empty()) {
|
||||
boost::asio::streambuf pendingBuf;
|
||||
copyStringToStreambuf(pendingTunnelData, pendingBuf);
|
||||
client_->doWrite(pendingBuf);
|
||||
makeEncryptedHttpResponse(
|
||||
"HTTP/1.1 502 Bad Gateway\r\n\r\n",
|
||||
"502 Bad Gateway",
|
||||
"close");
|
||||
|
||||
connect_ = false;
|
||||
end_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string connectEstablished =
|
||||
"HTTP/1.1 200 Connection Established\r\n\r\n";
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [TUNNEL] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
inner->dstIP() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
|
||||
BoolStr encryption{false, std::string("FAILED")};
|
||||
encryption = aes256Encrypt(connectEstablished, config_->general().token);
|
||||
makeEncryptedHttpResponse(
|
||||
"HTTP/1.1 200 Connection Established\r\n\r\n",
|
||||
"200 OK",
|
||||
"keep-alive");
|
||||
|
||||
if (encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Failed] : [ " +
|
||||
encryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
}
|
||||
|
||||
std::ostringstream outer;
|
||||
outer << "HTTP/1.1 200 OK\r\n"
|
||||
<< "Content-Type: application/octet-stream\r\n"
|
||||
<< "Content-Length: " << encryption.message.size() << "\r\n"
|
||||
<< "Connection: keep-alive\r\n"
|
||||
<< "\r\n"
|
||||
<< encryption.message;
|
||||
|
||||
copyStringToStreambuf(outer.str(), writeBuffer_);
|
||||
connect_ = true;
|
||||
end_ = false;
|
||||
return;
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [CONNECT] [ERROR] [Resolving Host] [SRC " +
|
||||
clientConnStr_ + "] [DST " + inner->dstIP() + ":" +
|
||||
std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
}
|
||||
|
||||
const std::string connectFailed =
|
||||
"HTTP/1.1 502 Bad Gateway\r\n\r\n";
|
||||
TCPClient::pointer targetClient = TCPClient::create(
|
||||
static_cast<boost::asio::io_context &>(
|
||||
client_->socket().get_executor().context()),
|
||||
config_,
|
||||
log_);
|
||||
|
||||
BoolStr encryption{false, std::string("FAILED")};
|
||||
encryption = aes256Encrypt(connectFailed, config_->general().token);
|
||||
targetClient->uuid_ = uuid_;
|
||||
|
||||
if (encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Failed] : [ " +
|
||||
encryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
}
|
||||
if (!targetClient->doConnect(inner->dstIP(), inner->dstPort())) {
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [ERROR] [Resolving Host] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
inner->dstIP() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
|
||||
std::ostringstream outer;
|
||||
outer << "HTTP/1.1 502 Bad Gateway\r\n"
|
||||
<< "Content-Type: application/octet-stream\r\n"
|
||||
<< "Content-Length: " << encryption.message.size() << "\r\n"
|
||||
<< "Connection: close\r\n"
|
||||
<< "\r\n"
|
||||
<< encryption.message;
|
||||
makeEncryptedHttpResponse(
|
||||
"HTTP/1.1 502 Bad Gateway\r\n\r\n",
|
||||
"502 Bad Gateway",
|
||||
"close");
|
||||
|
||||
copyStringToStreambuf(outer.str(), writeBuffer_);
|
||||
connect_ = false;
|
||||
end_ = true;
|
||||
end_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
inner->dstIP() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
|
||||
if (!pendingTunnelData.empty()) {
|
||||
boost::asio::streambuf pendingBuf;
|
||||
copyStringToStreambuf(pendingTunnelData, pendingBuf);
|
||||
targetClient->doWrite(pendingBuf);
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> sessionLock(sessionsMutex_);
|
||||
sessions_[session.empty() ? to_string(uuid_) : session] = targetClient;
|
||||
}
|
||||
|
||||
makeEncryptedHttpResponse(
|
||||
"HTTP/1.1 200 Connection Established\r\n\r\n",
|
||||
"200 OK",
|
||||
"keep-alive");
|
||||
|
||||
connect_ = false;
|
||||
end_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
case HTTP::HttpType::http:
|
||||
case HTTP::HttpType::https: {
|
||||
|
||||
copyStringToStreambuf(innerRequest, readBuffer_);
|
||||
|
||||
if (!client_->socket().is_open()) {
|
||||
if (!client_->doConnect(inner->dstIP(), inner->dstPort())) {
|
||||
client_->socket().close();
|
||||
makeEncryptedHttpResponse("", "502 Bad Gateway", "close");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -178,30 +407,15 @@ void ServerHandler::handle() {
|
||||
|
||||
if (client_->readBuffer().size() == 0) {
|
||||
client_->socket().close();
|
||||
makeEncryptedHttpResponse("", "200 OK", (config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
return;
|
||||
}
|
||||
|
||||
BoolStr encryption{false, std::string("FAILED")};
|
||||
encryption = aes256Encrypt(streambufToString(client_->readBuffer()), config_->general().token);
|
||||
makeEncryptedHttpResponse(
|
||||
streambufToString(client_->readBuffer()),
|
||||
"200 OK",
|
||||
(config_->general().connectionReuse ? "keep-alive" : "close"));
|
||||
|
||||
if (encryption.ok) {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Done]", Log::Level::DEBUG);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [ServerHandler handle] [Encryption Failed] : [ " +
|
||||
encryption.message + "] ",
|
||||
Log::Level::DEBUG);
|
||||
}
|
||||
const std::string innerResponse = encryption.message;
|
||||
|
||||
std::ostringstream outer;
|
||||
outer << "HTTP/1.1 200 OK\r\n"
|
||||
<< "Content-Type: application/octet-stream\r\n"
|
||||
<< "Content-Length: " << innerResponse.size() << "\r\n"
|
||||
<< "Connection: keep-alive\r\n"
|
||||
<< "\r\n"
|
||||
<< innerResponse;
|
||||
|
||||
copyStringToStreambuf(outer.str(), writeBuffer_);
|
||||
connect_ = false;
|
||||
end_ = false;
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "general.hpp"
|
||||
@@ -19,8 +22,7 @@ public:
|
||||
const TCPClient::pointer &client,
|
||||
const std::string &clientConnStr,
|
||||
boost::uuids::uuid uuid) {
|
||||
return pointer(new ServerHandler(readBuffer, writeBuffer, config, log,
|
||||
client, clientConnStr, uuid));
|
||||
return pointer(new ServerHandler(readBuffer, writeBuffer, config, log, client, clientConnStr, uuid));
|
||||
}
|
||||
|
||||
~ServerHandler();
|
||||
@@ -28,13 +30,19 @@ public:
|
||||
void handle();
|
||||
|
||||
inline const HTTP::pointer &request() & { return request_; }
|
||||
|
||||
inline const HTTP::pointer &&request() && { return std::move(request_); }
|
||||
|
||||
bool end_;
|
||||
bool connect_;
|
||||
|
||||
private:
|
||||
struct HttpUtils {
|
||||
static std::string lowerCopy(std::string s);
|
||||
static std::string trimCopy(std::string s);
|
||||
static std::string getRawHeader(const std::string &headers, const std::string &name);
|
||||
static std::string extractHttpBody(const std::string &msg);
|
||||
};
|
||||
|
||||
explicit ServerHandler(boost::asio::streambuf &readBuffer,
|
||||
boost::asio::streambuf &writeBuffer,
|
||||
const std::shared_ptr<Config> &config,
|
||||
@@ -43,6 +51,17 @@ private:
|
||||
const std::string &clientConnStr,
|
||||
boost::uuids::uuid uuid);
|
||||
|
||||
void makeEncryptedHttpResponse(const std::string &plainBody,
|
||||
const std::string &status = "200 OK",
|
||||
const std::string &connection = "close");
|
||||
|
||||
void makePlainHttpResponse(const std::string &body,
|
||||
const std::string &status = "200 OK",
|
||||
const std::string &connection = "close");
|
||||
|
||||
static std::mutex sessionsMutex_;
|
||||
static std::unordered_map<std::string, TCPClient::pointer> sessions_;
|
||||
|
||||
const std::shared_ptr<Config> &config_;
|
||||
const std::shared_ptr<Log> &log_;
|
||||
const TCPClient::pointer &client_;
|
||||
@@ -51,6 +70,5 @@ private:
|
||||
HTTP::pointer request_;
|
||||
const std::string &clientConnStr_;
|
||||
boost::uuids::uuid uuid_;
|
||||
|
||||
std::mutex mutex_;
|
||||
};
|
||||
+288
-166
@@ -5,119 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
|
||||
std::string toLowerCopy(std::string s) {
|
||||
std::transform(s.begin(), s.end(), s.begin(),
|
||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string extractHeaders(const std::string &msg) {
|
||||
auto pos = msg.find("\r\n\r\n");
|
||||
if (pos == std::string::npos) return {};
|
||||
return msg.substr(0, pos + 4);
|
||||
}
|
||||
|
||||
std::string extractBody(const std::string &msg) {
|
||||
auto pos = msg.find("\r\n\r\n");
|
||||
if (pos == std::string::npos) return {};
|
||||
return msg.substr(pos + 4);
|
||||
}
|
||||
|
||||
bool parseContentLength(const std::string &headers, std::size_t &value) {
|
||||
std::istringstream iss(headers);
|
||||
std::string line;
|
||||
while (std::getline(iss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
auto lower = toLowerCopy(line);
|
||||
if (lower.rfind("content-length:", 0) == 0) {
|
||||
auto raw = line.substr(std::string("Content-Length:").size());
|
||||
raw.erase(0, raw.find_first_not_of(" \t"));
|
||||
try {
|
||||
value = static_cast<std::size_t>(std::stoull(raw));
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isChunked(const std::string &headers) {
|
||||
std::istringstream iss(headers);
|
||||
std::string line;
|
||||
while (std::getline(iss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
auto lower = toLowerCopy(line);
|
||||
if (lower.rfind("transfer-encoding:", 0) == 0 &&
|
||||
lower.find("chunked") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename SyncReadStream>
|
||||
bool readHttpMessage(SyncReadStream &stream,
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec) {
|
||||
out.consume(out.size());
|
||||
|
||||
boost::asio::read_until(stream, out, "\r\n\r\n", ec);
|
||||
if (ec) return false;
|
||||
|
||||
std::string current = streambufToString(out);
|
||||
std::string headers = extractHeaders(current);
|
||||
std::string body = extractBody(current);
|
||||
|
||||
std::size_t contentLength = 0;
|
||||
if (parseContentLength(headers, contentLength)) {
|
||||
if (body.size() < contentLength) {
|
||||
boost::asio::read(stream, out,
|
||||
boost::asio::transfer_exactly(contentLength - body.size()),
|
||||
ec);
|
||||
if (ec) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isChunked(headers)) {
|
||||
for (;;) {
|
||||
current = streambufToString(out);
|
||||
auto bodyPos = current.find("\r\n\r\n");
|
||||
if (bodyPos == std::string::npos) return false;
|
||||
|
||||
std::string bodyPart = current.substr(bodyPos + 4);
|
||||
auto lastChunkPos = bodyPart.find("\r\n0\r\n\r\n");
|
||||
if (lastChunkPos != std::string::npos || bodyPart == "0\r\n\r\n") {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::array<char, 4096> tmp{};
|
||||
std::size_t n = stream.read_some(boost::asio::buffer(tmp), ec);
|
||||
if (ec) return false;
|
||||
std::ostream os(&out);
|
||||
os.write(tmp.data(), static_cast<std::streamsize>(n));
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
std::array<char, 4096> tmp{};
|
||||
std::size_t n = stream.read_some(boost::asio::buffer(tmp), ec);
|
||||
if (ec == boost::asio::error::eof) {
|
||||
ec.clear();
|
||||
return true;
|
||||
}
|
||||
if (ec) return false;
|
||||
std::ostream os(&out);
|
||||
os.write(tmp.data(), static_cast<std::streamsize>(n));
|
||||
}
|
||||
}
|
||||
|
||||
}// namespace
|
||||
#include <vector>
|
||||
|
||||
TCPClient::TCPClient(boost::asio::io_context &io_context,
|
||||
const std::shared_ptr<Config> &config,
|
||||
@@ -146,7 +34,6 @@ bool TCPClient::isOpen() const {
|
||||
}
|
||||
|
||||
bool TCPClient::enableTlsClient() {
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
try {
|
||||
if (tlsEnabled_) return true;
|
||||
@@ -160,11 +47,11 @@ bool TCPClient::enableTlsClient() {
|
||||
|
||||
SSL_CTX_set_min_proto_version(sslContext_.native_handle(), TLS1_2_VERSION);
|
||||
|
||||
if (config_->agent().tlsVerifyPeer) {
|
||||
if (config_->general().tlsVerifyPeer) {
|
||||
sslContext_.set_verify_mode(boost::asio::ssl::verify_peer);
|
||||
|
||||
if (!config_->agent().tlsCaFile.empty()) {
|
||||
sslContext_.load_verify_file(config_->agent().tlsCaFile);
|
||||
if (!config_->general().tlsCaFile.empty()) {
|
||||
sslContext_.load_verify_file(config_->general().tlsCaFile);
|
||||
}
|
||||
} else {
|
||||
sslContext_.set_verify_mode(boost::asio::ssl::verify_none);
|
||||
@@ -204,16 +91,26 @@ bool TCPClient::enableTlsClient() {
|
||||
}
|
||||
|
||||
bool TCPClient::doConnect(const std::string &dstIP, const unsigned short &dstPort) {
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
try {
|
||||
if (tlsEnabled_ && sslSocket_ && sslSocket_->lowest_layer().is_open()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!tlsEnabled_ && socket_.is_open()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doConnect] [DST " + dstIP +
|
||||
":" + std::to_string(dstPort) + "]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
boost::system::error_code error_code;
|
||||
auto endpoint =
|
||||
resolver_.resolve(dstIP.c_str(), std::to_string(dstPort).c_str(), error_code);
|
||||
|
||||
auto endpoint = resolver_.resolve(
|
||||
dstIP.c_str(),
|
||||
std::to_string(dstPort).c_str(),
|
||||
error_code);
|
||||
|
||||
if (error_code) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
@@ -223,9 +120,19 @@ bool TCPClient::doConnect(const std::string &dstIP, const unsigned short &dstPor
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tlsEnabled_ && sslSocket_) {
|
||||
if (tlsEnabled_) {
|
||||
if (!sslSocket_ || closed_ || !sslSocket_->lowest_layer().is_open()) {
|
||||
sslSocket_ = std::make_unique<ssl_stream>(io_context_, sslContext_);
|
||||
closed_ = false;
|
||||
}
|
||||
|
||||
boost::asio::connect(sslSocket_->lowest_layer(), endpoint, error_code);
|
||||
} else {
|
||||
if (!socket_.is_open()) {
|
||||
socket_ = tcp::socket(io_context_);
|
||||
closed_ = false;
|
||||
}
|
||||
|
||||
boost::asio::connect(socket_, endpoint, error_code);
|
||||
}
|
||||
|
||||
@@ -240,7 +147,8 @@ bool TCPClient::doConnect(const std::string &dstIP, const unsigned short &dstPor
|
||||
return true;
|
||||
|
||||
} catch (std::exception &error) {
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doConnect] " +
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doConnect] " +
|
||||
error.what(),
|
||||
Log::Level::ERROR);
|
||||
return false;
|
||||
@@ -248,12 +156,11 @@ bool TCPClient::doConnect(const std::string &dstIP, const unsigned short &dstPor
|
||||
}
|
||||
|
||||
bool TCPClient::doHandshakeClient() {
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
try {
|
||||
if (!tlsEnabled_ || !sslSocket_) return true;
|
||||
|
||||
std::string sniHost = config_->general().fakeUrl;
|
||||
std::string sniHost = config_->randomFakeUrl();
|
||||
|
||||
if (!sniHost.empty()) {
|
||||
auto pos = sniHost.find("://");
|
||||
@@ -329,13 +236,11 @@ bool TCPClient::doHandshakeClient() {
|
||||
}
|
||||
|
||||
void TCPClient::writeBuffer(boost::asio::streambuf &buffer) {
|
||||
std::lock_guard lock(mutex_);
|
||||
moveStreambuf(buffer, writeBuffer_);
|
||||
}
|
||||
|
||||
|
||||
void TCPClient::doWrite(boost::asio::streambuf &buffer) {
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
try {
|
||||
moveStreambuf(buffer, writeBuffer_);
|
||||
@@ -357,7 +262,7 @@ void TCPClient::doWrite(boost::asio::streambuf &buffer) {
|
||||
resetTimeout();
|
||||
|
||||
if (tlsEnabled_ && sslSocket_) {
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doWrite] [DST " +
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doWrite] [SSL] [DST " +
|
||||
sslSocket_->lowest_layer().remote_endpoint().address().to_string() +
|
||||
":" +
|
||||
std::to_string(sslSocket_->lowest_layer().remote_endpoint().port()) +
|
||||
@@ -365,7 +270,7 @@ void TCPClient::doWrite(boost::asio::streambuf &buffer) {
|
||||
Log::Level::DEBUG);
|
||||
boost::asio::write(*sslSocket_, writeBuffer_, error);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doWrite] [DST " +
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient doWrite] [TCP] [DST " +
|
||||
socket_.remote_endpoint().address().to_string() + ":" +
|
||||
std::to_string(socket_.remote_endpoint().port()) +
|
||||
"] [Bytes " + std::to_string(writeBuffer_.size()) + "] ",
|
||||
@@ -393,51 +298,70 @@ void TCPClient::doWrite(boost::asio::streambuf &buffer) {
|
||||
|
||||
void TCPClient::doReadAgent() {
|
||||
boost::system::error_code error;
|
||||
std::lock_guard lock(mutex_);
|
||||
readBuffer_.consume(readBuffer_.size());
|
||||
|
||||
try {
|
||||
if (!isOpen()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] Socket is not OPEN",
|
||||
Log::Level::DEBUG);
|
||||
return;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
readBuffer_.consume(readBuffer_.size());
|
||||
|
||||
if (!isOpen()) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] Socket is not OPEN",
|
||||
Log::Level::DEBUG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
resetTimeout();
|
||||
|
||||
bool ok = false;
|
||||
if (tlsEnabled_ && sslSocket_) {
|
||||
ok = readHttpMessage(*sslSocket_, readBuffer_, error);
|
||||
if (tlsEnabled_) {
|
||||
if (!sslSocket_) {
|
||||
cancelTimeout();
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] SSL socket is null",
|
||||
Log::Level::DEBUG);
|
||||
socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
ok = HttpUtils::readHttpMessage(*sslSocket_, readBuffer_, error);
|
||||
} else {
|
||||
ok = readHttpMessage(socket_, readBuffer_, error);
|
||||
ok = HttpUtils::readHttpMessage(socket_, readBuffer_, error);
|
||||
}
|
||||
|
||||
cancelTimeout();
|
||||
|
||||
if (!ok) {
|
||||
if (error == boost::asio::error::eof) {
|
||||
if (error == boost::asio::error::operation_aborted) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] [aborted]",
|
||||
Log::Level::DEBUG);
|
||||
} else if (error == boost::asio::error::eof) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] [EOF] Connection closed by peer.",
|
||||
Log::Level::TRACE);
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] [error] " + error.message(),
|
||||
"] [TCPClient doReadAgent] [error] " +
|
||||
error.message(),
|
||||
Log::Level::ERROR);
|
||||
}
|
||||
socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (readBuffer_.size() > 0) {
|
||||
copyStreambuf(readBuffer_, buffer_);
|
||||
} else {
|
||||
socketShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (std::exception &error) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] [catch read] " + error.what(),
|
||||
"] [TCPClient doReadAgent] empty read buffer",
|
||||
Log::Level::DEBUG);
|
||||
socketShutdown();
|
||||
} catch (const std::exception &ex) {
|
||||
cancelTimeout();
|
||||
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient doReadAgent] [catch read] " +
|
||||
ex.what(),
|
||||
Log::Level::DEBUG);
|
||||
socketShutdown();
|
||||
}
|
||||
@@ -446,7 +370,6 @@ void TCPClient::doReadAgent() {
|
||||
void TCPClient::doReadServer() {
|
||||
boost::system::error_code error;
|
||||
end_ = false;
|
||||
std::lock_guard lock(mutex_);
|
||||
readBuffer_.consume(readBuffer_.size());
|
||||
|
||||
try {
|
||||
@@ -541,24 +464,223 @@ void TCPClient::onTimeout(const boost::system::error_code &error) {
|
||||
}
|
||||
|
||||
void TCPClient::socketShutdown() {
|
||||
try {
|
||||
boost::system::error_code ignored;
|
||||
boost::system::error_code ec;
|
||||
|
||||
if (sslSocket_) {
|
||||
sslSocket_->shutdown(ignored);
|
||||
sslSocket_->lowest_layer().shutdown(
|
||||
boost::asio::ip::tcp::socket::shutdown_both, ignored);
|
||||
sslSocket_->lowest_layer().close(ignored);
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
if (socket_.is_open()) {
|
||||
socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored);
|
||||
socket_.close(ignored);
|
||||
}
|
||||
if (closed_) return;
|
||||
closed_ = true;
|
||||
|
||||
} catch (std::exception &error) {
|
||||
log_->write("[" + to_string(uuid_) +
|
||||
"] [TCPClient socketShutdown] [catch] " + error.what(),
|
||||
cancelTimeout();
|
||||
|
||||
if (sslSocket_) {
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient socketShutdown] [SSL]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
auto &lowest = sslSocket_->lowest_layer();
|
||||
|
||||
lowest.cancel(ec);
|
||||
ec.clear();
|
||||
|
||||
if (lowest.is_open()) {
|
||||
lowest.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
|
||||
ec.clear();
|
||||
|
||||
lowest.close(ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (socket_.is_open()) {
|
||||
log_->write("[" + to_string(uuid_) + "] [TCPClient socketShutdown] [TCP]",
|
||||
Log::Level::DEBUG);
|
||||
|
||||
socket_.cancel(ec);
|
||||
ec.clear();
|
||||
|
||||
socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
|
||||
ec.clear();
|
||||
|
||||
socket_.close(ec);
|
||||
}
|
||||
|
||||
tlsEnabled_ = false;
|
||||
}
|
||||
|
||||
std::string TCPClient::HttpUtils::toLowerCopy(std::string s) {
|
||||
std::transform(s.begin(), s.end(), s.begin(),
|
||||
[](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string TCPClient::HttpUtils::extractHeaders(const std::string &msg) {
|
||||
auto pos = msg.find("\r\n\r\n");
|
||||
if (pos == std::string::npos) return {};
|
||||
return msg.substr(0, pos + 4);
|
||||
}
|
||||
|
||||
std::string TCPClient::HttpUtils::extractBody(const std::string &msg) {
|
||||
auto pos = msg.find("\r\n\r\n");
|
||||
if (pos == std::string::npos) return {};
|
||||
return msg.substr(pos + 4);
|
||||
}
|
||||
|
||||
bool TCPClient::HttpUtils::parseContentLength(const std::string &headers, std::size_t &value) {
|
||||
std::istringstream iss(headers);
|
||||
std::string line;
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
|
||||
auto lower = toLowerCopy(line);
|
||||
|
||||
if (lower.rfind("content-length:", 0) == 0) {
|
||||
auto raw = line.substr(std::string("Content-Length:").size());
|
||||
raw.erase(0, raw.find_first_not_of(" \t"));
|
||||
|
||||
try {
|
||||
value = static_cast<std::size_t>(std::stoull(raw));
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TCPClient::HttpUtils::isChunked(const std::string &headers) {
|
||||
std::istringstream iss(headers);
|
||||
std::string line;
|
||||
|
||||
while (std::getline(iss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
|
||||
auto lower = toLowerCopy(line);
|
||||
|
||||
if (lower.rfind("transfer-encoding:", 0) == 0 &&
|
||||
lower.find("chunked") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TCPClient::HttpUtils::readHttpMessage(
|
||||
tcp::socket &stream,
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec) {
|
||||
return readHttpMessageImpl(
|
||||
out,
|
||||
ec,
|
||||
[&stream](boost::asio::mutable_buffer buffer,
|
||||
boost::system::error_code &error) {
|
||||
return stream.read_some(buffer, error);
|
||||
},
|
||||
[&stream](boost::asio::streambuf &buffer,
|
||||
boost::system::error_code &error) {
|
||||
boost::asio::read_until(stream, buffer, "\r\n\r\n", error);
|
||||
return !error;
|
||||
});
|
||||
}
|
||||
|
||||
bool TCPClient::HttpUtils::readHttpMessage(
|
||||
ssl_stream &stream,
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec) {
|
||||
return readHttpMessageImpl(
|
||||
out,
|
||||
ec,
|
||||
[&stream](boost::asio::mutable_buffer buffer,
|
||||
boost::system::error_code &error) {
|
||||
return stream.read_some(buffer, error);
|
||||
},
|
||||
[&stream](boost::asio::streambuf &buffer,
|
||||
boost::system::error_code &error) {
|
||||
boost::asio::read_until(stream, buffer, "\r\n\r\n", error);
|
||||
return !error;
|
||||
});
|
||||
}
|
||||
|
||||
bool TCPClient::HttpUtils::readHttpMessageImpl(
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec,
|
||||
const std::function<std::size_t(
|
||||
boost::asio::mutable_buffer,
|
||||
boost::system::error_code &)> &readSome,
|
||||
const std::function<bool(
|
||||
boost::asio::streambuf &,
|
||||
boost::system::error_code &)> &readHeaders) {
|
||||
|
||||
out.consume(out.size());
|
||||
|
||||
if (!readHeaders(out, ec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string current = streambufToString(out);
|
||||
std::string headers = extractHeaders(current);
|
||||
std::string body = extractBody(current);
|
||||
|
||||
std::size_t contentLength = 0;
|
||||
if (parseContentLength(headers, contentLength)) {
|
||||
while (body.size() < contentLength) {
|
||||
char tmp[8192];
|
||||
std::size_t remaining =
|
||||
contentLength - body.size();
|
||||
std::size_t toRead =
|
||||
std::min<std::size_t>(
|
||||
sizeof(tmp),
|
||||
remaining);
|
||||
std::size_t n =
|
||||
readSome(
|
||||
boost::asio::buffer(
|
||||
tmp,
|
||||
toRead),
|
||||
ec);
|
||||
if (ec) {
|
||||
return false;
|
||||
}
|
||||
if (n == 0) {
|
||||
ec = boost::asio::error::eof;
|
||||
return false;
|
||||
}
|
||||
boost::asio::buffer_copy(
|
||||
out.prepare(n),
|
||||
boost::asio::buffer(tmp, n));
|
||||
out.commit(n);
|
||||
body.append(tmp, n);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (isChunked(headers)) {
|
||||
while (
|
||||
body.find("\r\n0\r\n\r\n") ==
|
||||
std::string::npos &&
|
||||
body.find("\r\n0\r\n") ==
|
||||
std::string::npos) {
|
||||
char tmp[8192];
|
||||
std::size_t n =
|
||||
readSome(
|
||||
boost::asio::buffer(tmp),
|
||||
ec);
|
||||
if (ec) {
|
||||
return false;
|
||||
}
|
||||
if (n == 0) {
|
||||
ec = boost::asio::error::eof;
|
||||
return false;
|
||||
}
|
||||
boost::asio::buffer_copy(
|
||||
out.prepare(n),
|
||||
boost::asio::buffer(tmp, n));
|
||||
out.commit(n);
|
||||
body.append(tmp, n);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+28
-15
@@ -5,6 +5,7 @@
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -27,35 +28,25 @@ public:
|
||||
}
|
||||
|
||||
tcp::socket &socket();
|
||||
|
||||
ssl_stream &sslSocket();
|
||||
|
||||
bool tlsEnabled() const;
|
||||
|
||||
bool isOpen() const;
|
||||
|
||||
bool enableTlsClient();
|
||||
|
||||
bool doHandshakeClient();
|
||||
bool doConnect(const std::string &dstIP, const unsigned short &dstPort);
|
||||
|
||||
void writeBuffer(boost::asio::streambuf &buffer);
|
||||
|
||||
inline boost::asio::streambuf &writeBuffer() & { return writeBuffer_; }
|
||||
|
||||
inline boost::asio::streambuf &&writeBuffer() && {
|
||||
return std::move(writeBuffer_);
|
||||
}
|
||||
inline boost::asio::streambuf &&writeBuffer() && { return std::move(writeBuffer_); }
|
||||
|
||||
inline boost::asio::streambuf &readBuffer() & { return readBuffer_; }
|
||||
|
||||
inline boost::asio::streambuf &&readBuffer() && { return std::move(readBuffer_); }
|
||||
|
||||
bool doConnect(const std::string &dstIP, const unsigned short &dstPort);
|
||||
|
||||
void doWrite(boost::asio::streambuf &buffer);
|
||||
|
||||
void doReadAgent();
|
||||
|
||||
void doReadServer();
|
||||
|
||||
void socketShutdown();
|
||||
@@ -64,15 +55,36 @@ public:
|
||||
bool end_;
|
||||
|
||||
private:
|
||||
struct HttpUtils {
|
||||
static std::string toLowerCopy(std::string s);
|
||||
static std::string extractHeaders(const std::string &msg);
|
||||
static std::string extractBody(const std::string &msg);
|
||||
static bool parseContentLength(const std::string &headers, std::size_t &value);
|
||||
static bool isChunked(const std::string &headers);
|
||||
|
||||
static bool readHttpMessage(tcp::socket &stream,
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec);
|
||||
|
||||
static bool readHttpMessage(ssl_stream &stream,
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec);
|
||||
|
||||
static bool readHttpMessageImpl(
|
||||
boost::asio::streambuf &out,
|
||||
boost::system::error_code &ec,
|
||||
const std::function<std::size_t(boost::asio::mutable_buffer,
|
||||
boost::system::error_code &)> &readSome,
|
||||
const std::function<bool(boost::asio::streambuf &,
|
||||
boost::system::error_code &)> &readHeaders);
|
||||
};
|
||||
|
||||
explicit TCPClient(boost::asio::io_context &io_context,
|
||||
const std::shared_ptr<Config> &config,
|
||||
const std::shared_ptr<Log> &log);
|
||||
|
||||
void resetTimeout();
|
||||
|
||||
|
||||
void cancelTimeout();
|
||||
|
||||
void onTimeout(const boost::system::error_code &error);
|
||||
|
||||
const std::shared_ptr<Config> &config_;
|
||||
@@ -91,4 +103,5 @@ private:
|
||||
tcp::resolver resolver_;
|
||||
boost::asio::steady_timer timeout_;
|
||||
mutable std::mutex mutex_;
|
||||
bool closed_ = false;
|
||||
};
|
||||
+669
-403
File diff suppressed because it is too large.
Load diff
+67
-26
@@ -1,15 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "agenthandler.hpp"
|
||||
#include "general.hpp"
|
||||
@@ -18,8 +23,7 @@
|
||||
class TCPConnection : public boost::enable_shared_from_this<TCPConnection> {
|
||||
public:
|
||||
using pointer = boost::shared_ptr<TCPConnection>;
|
||||
using ssl_stream =
|
||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket>;
|
||||
using ssl_stream = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>;
|
||||
|
||||
static pointer create(boost::asio::io_context &io_context,
|
||||
const std::shared_ptr<Config> &config,
|
||||
@@ -29,13 +33,10 @@ public:
|
||||
}
|
||||
|
||||
boost::asio::ip::tcp::socket &socket();
|
||||
|
||||
inline TCPClient::pointer client() { return client_; }
|
||||
|
||||
ssl_stream &tlsSocket();
|
||||
|
||||
bool initTlsServerContext();
|
||||
|
||||
bool doHandshakeServer();
|
||||
|
||||
inline void writeBuffer(boost::asio::streambuf &buffer) {
|
||||
@@ -43,47 +44,83 @@ public:
|
||||
}
|
||||
|
||||
inline const boost::asio::streambuf &readBuffer() & { return readBuffer_; }
|
||||
|
||||
inline const boost::asio::streambuf &&readBuffer() && {
|
||||
return std::move(readBuffer_);
|
||||
}
|
||||
|
||||
inline const boost::asio::streambuf &&readBuffer() && { return std::move(readBuffer_); }
|
||||
inline boost::uuids::uuid uuid() { return uuid_; }
|
||||
|
||||
void startAgent();
|
||||
|
||||
void startServer();
|
||||
|
||||
void doReadAgent();
|
||||
|
||||
void doReadServer();
|
||||
|
||||
void handleReadAgent(const boost::system::error_code &error,
|
||||
size_t bytes_transferred);
|
||||
|
||||
void handleReadServer(const boost::system::error_code &error,
|
||||
size_t bytes_transferred);
|
||||
void handleReadAgent(const boost::system::error_code &error, size_t bytes_transferred);
|
||||
void handleReadServer(const boost::system::error_code &error, size_t bytes_transferred);
|
||||
|
||||
void socketShutdown();
|
||||
|
||||
void enableTunnelMode();
|
||||
void enableDirectTunnelMode();
|
||||
|
||||
void relayClientToRemote();
|
||||
void relayClientToServer();
|
||||
void relayServerToClient();
|
||||
|
||||
void relayRemoteToClient();
|
||||
void relayAgentToTarget();
|
||||
void relayTargetToAgent();
|
||||
|
||||
inline void asyncWriteToAgentConnection(
|
||||
const char *data,
|
||||
std::size_t bytes,
|
||||
std::function<void(const boost::system::error_code &)> done);
|
||||
|
||||
inline void asyncReadFromAgentConnection(
|
||||
std::array<char, 8192> &buffer,
|
||||
std::function<void(const boost::system::error_code &, std::size_t)> done);
|
||||
|
||||
inline void asyncWriteToAgentServerConnection(
|
||||
const char *data,
|
||||
std::size_t bytes,
|
||||
std::function<void(const boost::system::error_code &)> done);
|
||||
|
||||
inline void asyncReadFromAgentServerConnection(
|
||||
std::array<char, 8192> &buffer,
|
||||
std::function<void(const boost::system::error_code &, std::size_t)> done);
|
||||
|
||||
private:
|
||||
struct HttpUtils {
|
||||
static std::string toLowerCopy(std::string s);
|
||||
static std::string extractHeaders(const std::string &msg);
|
||||
static std::string extractBody(const std::string &msg);
|
||||
static bool parseContentLength(const std::string &headers, std::size_t &value);
|
||||
static bool isChunked(const std::string &headers);
|
||||
|
||||
static bool readRemainingHttpBody(boost::asio::ip::tcp::socket &stream,
|
||||
boost::asio::streambuf &buf,
|
||||
boost::system::error_code &ec);
|
||||
|
||||
static bool readRemainingHttpBody(ssl_stream &stream,
|
||||
boost::asio::streambuf &buf,
|
||||
boost::system::error_code &ec);
|
||||
|
||||
static bool readRemainingHttpBodyImpl(
|
||||
boost::asio::streambuf &buf,
|
||||
boost::system::error_code &ec,
|
||||
const std::function<std::size_t(boost::asio::mutable_buffer,
|
||||
boost::system::error_code &)> &readSome);
|
||||
};
|
||||
|
||||
explicit TCPConnection(boost::asio::io_context &io_context,
|
||||
const std::shared_ptr<Config> &config,
|
||||
const std::shared_ptr<Log> &log,
|
||||
TCPClient::pointer client);
|
||||
|
||||
void resetTimeout();
|
||||
|
||||
void cancelTimeout();
|
||||
|
||||
void onTimeout(const boost::system::error_code &error);
|
||||
|
||||
void startTunnelReadFromClient();
|
||||
void startTunnelPollServer();
|
||||
std::string postTunnelAction(const std::string &action, const std::string &rawBody);
|
||||
std::string makeRelayHostHeader() const;
|
||||
void closeTunnelSession();
|
||||
|
||||
boost::asio::ip::tcp::socket socket_;
|
||||
boost::asio::ssl::context sslContext_;
|
||||
std::unique_ptr<ssl_stream> tlsSocket_;
|
||||
@@ -97,6 +134,7 @@ private:
|
||||
boost::asio::streambuf writeBuffer_;
|
||||
|
||||
boost::asio::steady_timer timeout_;
|
||||
boost::asio::steady_timer pollTimer_;
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
|
||||
|
||||
boost::uuids::uuid uuid_;
|
||||
@@ -105,7 +143,10 @@ private:
|
||||
bool end_;
|
||||
bool connect_;
|
||||
bool tunnelMode_;
|
||||
bool tunnelClosed_;
|
||||
bool pollInProgress_;
|
||||
std::atomic_bool closed_{false};
|
||||
|
||||
std::array<char, 16384> downstreamBuf_;
|
||||
std::array<char, 16384> upstreamBuf_;
|
||||
std::array<char, 8192> downstreamBuf_;
|
||||
std::array<char, 8192> upstreamBuf_;
|
||||
};
|
||||
@@ -31,7 +31,7 @@ void TCPServer::handleAccept(TCPConnection::pointer connection,
|
||||
try {
|
||||
if (!error) {
|
||||
if (config_->runMode() == RunMode::server) {
|
||||
if (config_->server().tlsEnable) {
|
||||
if (config_->general().tlsEnable) {
|
||||
if (!connection->initTlsServerContext()) {
|
||||
log_->write("[TCPServer handleAccept] TLS server context init failed",
|
||||
Log::Level::ERROR);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
## Install on Termux
|
||||
|
||||
### Requirements
|
||||
|
||||
libyaml-cpp >= 0.8
|
||||
boost >= 1.88.0
|
||||
|
||||
### Dependencies
|
||||
Install the dependencies
|
||||
```bash
|
||||
pkg install boost libyaml-cpp
|
||||
```
|
||||
|
||||
### Install
|
||||
Download the nipovpn_VERSION_termux_aarch64 version from releases pages
|
||||
```bash
|
||||
pkg install ./nipovpn_VERSION_termux_aarch64.deb
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
Package : nipovpn
|
||||
Version : 0.1
|
||||
Maintainer : Morteza Bashsiz
|
||||
Architecture : amd64
|
||||
Description : Powerfull and Secure http/s Proxy
|
||||
Depends : libyaml-cpp0.8
|
||||
Homepage : https://github.com/MortezaBashsiz/nipovpn
|
||||
Package: nipovpn
|
||||
Version: ${PACKAGE_VERSION}
|
||||
Maintainer: Morteza Bashsiz
|
||||
Architecture: ${{ matrix.arch }}
|
||||
Description: Powerfull and Secure http/s Proxy
|
||||
Depends: libyaml-cpp0.8
|
||||
Homepage: https://github.com/MortezaBashsiz/nipovpn
|
||||
@@ -3,20 +3,58 @@
|
||||
general:
|
||||
# token: 32 bytes of string. this will be used on agent and server side to encryption
|
||||
token: "af445adb-2434-4975-9445-2c1b2231"
|
||||
# fakeUrl: string
|
||||
# Defines the fake url and endpoint between agent and server
|
||||
fakeUrl: "http://nipo.ciron.net"
|
||||
# method: "HEAD|GET|POST|PUT|DELETE"
|
||||
# Defines with which method
|
||||
# fakeUrls:
|
||||
# Defines the list of fake urls between agent and server
|
||||
fakeUrls:
|
||||
- nipo.ciron.net
|
||||
- sudoer.ir
|
||||
- sudoer.net
|
||||
- google.com
|
||||
- cloudflare.com
|
||||
# methods:
|
||||
# Defines the list of using methods
|
||||
# you like to send requests from agent to server
|
||||
method: "POST"
|
||||
# Program will choose randomly from this list
|
||||
methods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
# endPoints:
|
||||
# Defines the list of using endpoints
|
||||
# you like to send requests from agent to server
|
||||
# Program will choose randomly from this list
|
||||
endPoints:
|
||||
- api
|
||||
- login
|
||||
- user
|
||||
- update
|
||||
# timeout: unsigned short
|
||||
# Defines the timeout for I/O Operation in seconds. 0 indicates no timeout.
|
||||
# Useful to automatically close stalled connections.
|
||||
timeout: 10
|
||||
# chunkHeader: String
|
||||
# Defines the chunk header that you want to inform Agent/Server if it is end or not.
|
||||
chunkHeader: "END"
|
||||
# pullTimeout: unsigned short
|
||||
# Defines the timeout for I/O Operation in milliseconds.
|
||||
# Useful to expire serverside read timer.
|
||||
pullTimeout: 50
|
||||
# tunnelEnable: bool
|
||||
# Defines the connection mode between agent and server. If enabled then the traffic
|
||||
# will be TCP/TLS tunnel like.
|
||||
tunnelEnable: false
|
||||
# connectionReuse: bool
|
||||
# If false then it will use same connection between agent and server to handle client request
|
||||
# If true then it will create new connection for each request between agent and server
|
||||
connectionReuse: true
|
||||
# tlsEnable: bool
|
||||
# It enables or disables tls between agent and server
|
||||
tlsEnable: false
|
||||
# tlsVerifyPeer: bool
|
||||
# Use it to controll if the certificate should be validated or not
|
||||
tlsVerifyPeer: false
|
||||
# Use following configurations to specify the key and cert which will be used between agent and server
|
||||
tlsCertFile: "/etc/nipovpn/server.crt"
|
||||
tlsKeyFile: "/etc/nipovpn/server.key"
|
||||
tlsCaFile: ""
|
||||
|
||||
|
||||
# This block is to define log directives
|
||||
@@ -34,12 +72,8 @@ server:
|
||||
# listenIp: which must be IPv4 which is used on server
|
||||
listenIp: "0.0.0.0"
|
||||
# listenPort: the port number which will be used on server
|
||||
listenPort: 8081
|
||||
tlsEnable: false
|
||||
tlsVerifyPeer: false
|
||||
tlsCertFile: "/etc/nipovpn/server.crt"
|
||||
tlsKeyFile: "/etc/nipovpn/server.key"
|
||||
tlsCaFile: ""
|
||||
listenPort: 80
|
||||
|
||||
|
||||
# This block is to define agent directives
|
||||
agent:
|
||||
@@ -52,11 +86,8 @@ agent:
|
||||
# serverIp: IPv4 of the nipoServer
|
||||
serverIp: "127.0.0.10"
|
||||
# serverPort: port number of the nipoServer
|
||||
serverPort: 8081
|
||||
serverPort: 80
|
||||
# httpVersion: This version will be used between agent and server
|
||||
httpVersion: "1.1"
|
||||
# userAgent: This is the http user agent which will be used between agent and server
|
||||
userAgent : "NipoAgent"
|
||||
tlsEnable: false
|
||||
tlsVerifyPeer: false
|
||||
tlsCaFile: ""
|
||||
userAgent : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"
|
||||
Reference in new issue
Block a user