Compare commits

..
3 Commits
Author SHA1 Message Date
Morteza Bashsiz c0942c4015 Implement Random fakeUrl
* implement random fakeUrl
2026-05-31 23:06:14 +02:00
Morteza Bashsiz 228aff5d63 Dev fix #167 (#174)
* Fix #167 package versioning
2026-05-29 10:46:51 +02:00
Morteza Bashsiz 5647fd2f69 Fix #167 (#171)
* Fix #167 package versioning
2026-05-29 10:00:14 +02:00
11 changed files with 164 additions and 123 deletions

No files matched your search

+37 -36
View File
@@ -1,13 +1,21 @@
name: Build and Release Debian Package
name: Build and Release Debian Package - DEV
on:
push:
branches:
- main
- dev
paths:
- 'core/src/**'
- '.github/workflows/debian-dev.yml'
- 'core/**'
- 'nipovpn/**'
- '.github/workflows/debian-dev.yml'
permissions:
contents: write
env:
PACKAGE_VERSION: 0.1.${{ github.run_number }}
PACKAGE_FILE: nipovpn_dev_0.1.${{ github.run_number }}_amd64.deb
jobs:
build:
@@ -17,9 +25,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set package version
run: echo "PACKAGE_VERSION=0.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Set up dependencies
run: |
sudo apt-get update
@@ -34,62 +39,58 @@ jobs:
libboost-all-dev \
libyaml-cpp-dev
- name: Build the package
- name: Build binary
run: |
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
cd ..
rm -rf package
mkdir -p package/DEBIAN
mkdir -p package/usr/bin
- name: Build Debian package
run: |
mkdir -p nipovpn/usr/bin
cp build/core/nipovpn package/usr/bin/nipovpn
chmod 755 package/usr/bin/nipovpn
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
chmod 755 nipovpn/usr/bin/nipovpn
cat > package/DEBIAN/control <<EOF
Package: nipovpn
Version: ${PACKAGE_VERSION}
Maintainer: Morteza Bashsiz
Architecture: amd64
Description: Powerful and Secure HTTP/S Proxy
Depends: libyaml-cpp0.8
Homepage: https://github.com/MortezaBashsiz/nipovpn
EOF
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" nipovpn/DEBIAN/control
dpkg-deb --build package "build/nipovpn_dev_${PACKAGE_VERSION}_amd64.deb"
echo "Final control file:"
cat nipovpn/DEBIAN/control
grep "^Version: ${PACKAGE_VERSION}$" nipovpn/DEBIAN/control
dpkg-deb --build nipovpn "build/${PACKAGE_FILE}"
- name: Show package information
run: |
dpkg -I "build/nipovpn_dev_${PACKAGE_VERSION}_amd64.deb"
dpkg -I "build/${PACKAGE_FILE}"
dpkg -c "build/${PACKAGE_FILE}"
- name: Upload Debian package as artifact
uses: actions/upload-artifact@v4
with:
name: nipovpn
path: build/nipovpn_dev_${{ env.PACKAGE_VERSION }}_amd64.deb
name: nipovpn-dev-deb
path: build/${{ env.PACKAGE_FILE }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set package version
run: echo "PACKAGE_VERSION=0.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Download build artifact
- name: Download Debian package artifact
uses: actions/download-artifact@v4
with:
name: nipovpn
name: nipovpn-dev-deb
path: ./
- name: Create GitHub Release
- name: Create DEV GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PACKAGE_VERSION }}
name: Version v${{ env.PACKAGE_VERSION }}
files: nipovpn_dev_${{ env.PACKAGE_VERSION }}_amd64.deb
tag_name: dev-v${{ env.PACKAGE_VERSION }}
name: DEV Version v${{ env.PACKAGE_VERSION }}
prerelease: true
files: ${{ env.PACKAGE_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
+37 -36
View File
@@ -1,13 +1,21 @@
name: Build and Release Debian Package
name: Build and Release Debian Package - MORI
on:
push:
branches:
- main
- mori
paths:
- 'core/src/**'
- '.github/workflows/debian-mori.yml'
- 'core/**'
- 'nipovpn/**'
- '.github/workflows/debian-mori.yml'
permissions:
contents: write
env:
PACKAGE_VERSION: 0.2.${{ github.run_number }}
PACKAGE_FILE: nipovpn_mori_0.2.${{ github.run_number }}_amd64.deb
jobs:
build:
@@ -17,9 +25,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set package version
run: echo "PACKAGE_VERSION=0.0.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Set up dependencies
run: |
sudo apt-get update
@@ -34,62 +39,58 @@ jobs:
libboost-all-dev \
libyaml-cpp-dev
- name: Build the package
- name: Build binary
run: |
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
cd ..
rm -rf package
mkdir -p package/DEBIAN
mkdir -p package/usr/bin
- name: Build Debian package
run: |
mkdir -p nipovpn/usr/bin
cp build/core/nipovpn package/usr/bin/nipovpn
chmod 755 package/usr/bin/nipovpn
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
chmod 755 nipovpn/usr/bin/nipovpn
cat > package/DEBIAN/control <<EOF
Package: nipovpn
Version: ${PACKAGE_VERSION}
Maintainer: Morteza Bashsiz
Architecture: amd64
Description: Powerful and Secure HTTP/S Proxy
Depends: libyaml-cpp0.8
Homepage: https://github.com/MortezaBashsiz/nipovpn
EOF
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" nipovpn/DEBIAN/control
dpkg-deb --build package "build/nipovpn_mori_${PACKAGE_VERSION}_amd64.deb"
echo "Final control file:"
cat nipovpn/DEBIAN/control
grep "^Version: ${PACKAGE_VERSION}$" nipovpn/DEBIAN/control
dpkg-deb --build nipovpn "build/${PACKAGE_FILE}"
- name: Show package information
run: |
dpkg -I "build/nipovpn_mori_${PACKAGE_VERSION}_amd64.deb"
dpkg -I "build/${PACKAGE_FILE}"
dpkg -c "build/${PACKAGE_FILE}"
- name: Upload Debian package as artifact
uses: actions/upload-artifact@v4
with:
name: nipovpn
path: build/nipovpn_mori_${{ env.PACKAGE_VERSION }}_amd64.deb
name: nipovpn-mori-deb
path: build/${{ env.PACKAGE_FILE }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set package version
run: echo "PACKAGE_VERSION=0.0.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Download build artifact
- name: Download Debian package artifact
uses: actions/download-artifact@v4
with:
name: nipovpn
name: nipovpn-mori-deb
path: ./
- name: Create GitHub Release
- name: Create MORI GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PACKAGE_VERSION }}
name: Version v${{ env.PACKAGE_VERSION }}
files: nipovpn_mori_${{ env.PACKAGE_VERSION }}_amd64.deb
tag_name: mori-v${{ env.PACKAGE_VERSION }}
name: MORI Version v${{ env.PACKAGE_VERSION }}
prerelease: true
files: ${{ env.PACKAGE_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
+38 -33
View File
@@ -1,4 +1,4 @@
name: Build and Release Debian Package
name: Build and Release Debian Package - MAIN
on:
push:
@@ -6,8 +6,16 @@ on:
- main
paths:
- 'core/src/**'
- '.github/workflows/debian.yml'
- 'core/**'
- 'nipovpn/**'
- '.github/workflows/debian.yml'
permissions:
contents: write
env:
PACKAGE_VERSION: 1.1.${{ github.run_number }}
PACKAGE_FILE: nipovpn_1.1.${{ github.run_number }}_amd64.deb
jobs:
build:
@@ -17,9 +25,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set package version
run: echo "PACKAGE_VERSION=1.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Set up dependencies
run: |
sudo apt-get update
@@ -34,62 +39,62 @@ jobs:
libboost-all-dev \
libyaml-cpp-dev
- name: Build the package
- name: Build binary
run: |
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
cd ..
rm -rf package
mkdir -p package/DEBIAN
mkdir -p package/usr/bin
- name: Build Debian package
run: |
mkdir -p nipovpn/usr/bin
cp build/core/nipovpn package/usr/bin/nipovpn
chmod 755 package/usr/bin/nipovpn
cp build/core/nipovpn nipovpn/usr/bin/nipovpn
chmod 755 nipovpn/usr/bin/nipovpn
cat > package/DEBIAN/control <<EOF
Package: nipovpn
Version: ${PACKAGE_VERSION}
Maintainer: Morteza Bashsiz
Architecture: amd64
Description: Powerful and Secure HTTP/S Proxy
Depends: libyaml-cpp0.8
Homepage: https://github.com/MortezaBashsiz/nipovpn
EOF
sed -i -E "s/^Version[[:space:]]*:.*/Version: ${PACKAGE_VERSION}/" nipovpn/DEBIAN/control
dpkg-deb --build package "build/nipovpn_${PACKAGE_VERSION}_amd64.deb"
echo "Final control file:"
cat nipovpn/DEBIAN/control
grep "^Version: ${PACKAGE_VERSION}$" nipovpn/DEBIAN/control
dpkg-deb --build nipovpn "build/${PACKAGE_FILE}"
- name: Show package information
run: |
dpkg -I "build/nipovpn_${PACKAGE_VERSION}_amd64.deb"
dpkg -I "build/${PACKAGE_FILE}"
dpkg -c "build/${PACKAGE_FILE}"
- name: Upload Debian package as artifact
uses: actions/upload-artifact@v4
with:
name: nipovpn
path: build/nipovpn_${{ env.PACKAGE_VERSION }}_amd64.deb
name: nipovpn-main-deb
path: build/${{ env.PACKAGE_FILE }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set package version
run: echo "PACKAGE_VERSION=1.1.${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Download build artifact
- name: Download Debian package artifact
uses: actions/download-artifact@v4
with:
name: nipovpn
name: nipovpn-main-deb
path: ./
- name: Create GitHub Release
- name: Check downloaded files
run: |
ls -lah
- name: Create MAIN GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PACKAGE_VERSION }}
name: Version v${{ env.PACKAGE_VERSION }}
files: nipovpn_${{ env.PACKAGE_VERSION }}_amd64.deb
prerelease: false
files: ${{ env.PACKAGE_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
+1 -1
View File
@@ -149,7 +149,7 @@ void AgentHandler::handle() {
}
std::string AgentHandler::relayHostHeader(const std::shared_ptr<Config> &config) {
std::string hostHeader = config->general().fakeUrl;
std::string hostHeader = config->randomFakeUrl();
auto pos = hostHeader.find("://");
if (pos != std::string::npos) hostHeader = hostHeader.substr(pos + 3);
pos = hostHeader.find('/');
+30 -4
View File
@@ -9,7 +9,7 @@ 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"]["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>(),
@@ -72,7 +72,17 @@ std::string Config::toString() const {
ss << "\nConfig :\n"
<< " General :\n"
<< " token: " << general_.token << "\n"
<< " fakeUrl: " << general_.fakeUrl << "\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) {
@@ -198,11 +208,27 @@ std::string Config::modeToString() const {
}
}
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";// fallback
return "GET";
}
static thread_local std::mt19937 generator{std::random_device{}()};
@@ -218,7 +244,7 @@ std::string Config::randomEndPoint() const {
std::lock_guard<std::mutex> lock(configMutex_);
if (general_.endPoints.empty()) {
return "api";// fallback
return "api";
}
static thread_local std::mt19937 generator{std::random_device{}()};
+3 -1
View File
@@ -20,7 +20,7 @@ class Config : private Uncopyable {
private:
struct General {
std::string token;
std::string fakeUrl;
std::vector<std::string> fakeUrls;
std::vector<std::string> methods;
std::vector<std::string> endPoints;
unsigned short timeout;
@@ -107,6 +107,8 @@ public:
std::string toString() const;
std::string randomFakeUrl() const;
std::string randomMethod() const;
std::string randomEndPoint() const;
+1 -1
View File
@@ -325,7 +325,7 @@ inline BoolStr validateConfig(int argc, const char *argv[]) {
try {
configYaml["general"]["token"].as<std::string>();
configYaml["general"]["fakeUrl"].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>();
+6 -4
View File
@@ -156,10 +156,11 @@ bool HTTP::parseTls() {
}
const std::string HTTP::genHttpPostReqString(const std::string &body) const {
auto fakeUrl = config_->randomFakeUrl();
return std::string(config_->randomMethod() + " " +
config_->general().fakeUrl + " HTTP/" +
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" +
@@ -167,10 +168,11 @@ const std::string HTTP::genHttpPostReqString(const std::string &body) const {
}
const std::string HTTP::genHttpRestPostReqString() const {
auto fakeUrl = config_->randomFakeUrl();
return std::string(config_->randomMethod() + " " +
config_->general().fakeUrl + " HTTP/" +
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";
+1 -1
View File
@@ -160,7 +160,7 @@ bool TCPClient::doHandshakeClient() {
try {
if (!tlsEnabled_ || !sslSocket_) return true;
std::string sniHost = config_->general().fakeUrl;
std::string sniHost = config_->randomFakeUrl();
if (!sniHost.empty()) {
auto pos = sniHost.find("://");
+1 -1
View File
@@ -390,7 +390,7 @@ void TCPConnection::handleReadServer(const boost::system::error_code &error, siz
}
std::string TCPConnection::makeRelayHostHeader() const {
std::string hostHeader = config_->general().fakeUrl;
std::string hostHeader = config_->randomFakeUrl();
auto pos = hostHeader.find("://");
if (pos != std::string::npos) hostHeader = hostHeader.substr(pos + 3);
+9 -5
View File
@@ -3,9 +3,13 @@
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 between agent and server
fakeUrl: "www.google.com"
# fakeUrls:
# Defines the list of fake urls between agent and server
fakeUrls:
- www.google.com
- nipo.ciron.net
- sudoer.net
- sudoer.ir
# methods:
# Defines the list of using methods
# you like to send requests from agent to server
@@ -36,7 +40,7 @@ general:
# 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: false
connectionReuse: true
# tlsEnable: bool
# It enables or disables tls between agent and server
tlsEnable: false
@@ -76,7 +80,7 @@ agent:
# listenPort: the port number which will be used on agent
listenPort: 8080
# serverIp: IPv4 of the nipoServer
serverIp: "127.0.0.1"
serverIp: "127.0.0.10"
# serverPort: port number of the nipoServer
serverPort: 80
# httpVersion: This version will be used between agent and server