Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a0c414f63 | ||
|
|
5ddfcf1a0d | ||
|
|
703595501c | ||
|
|
3b195208ff | ||
|
|
a63d7ca141 | ||
|
|
882c68179f | ||
|
|
5e8b76769d | ||
|
|
c1afc7dab2 | ||
|
|
ef04fb3fb2 | ||
|
|
ec5eaf824b | ||
|
|
de4606d884 | ||
|
|
4860804ef1 | ||
|
|
d9c3a45074 |
No files matched your search
@@ -16,7 +16,7 @@ permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.57
|
||||
PACKAGE_VERSION: 1.1.59
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
|
||||
@@ -100,9 +100,32 @@ jobs:
|
||||
|
||||
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
|
||||
|
||||
mkdir -p package-root/DEBIAN
|
||||
cat > package-root/DEBIAN/conffiles <<'EOF'
|
||||
/etc/nipovpn/config.yaml
|
||||
EOF
|
||||
|
||||
rm -f package-root/var/log/nipovpn/nipovpn.log
|
||||
mkdir -p package-root/var/log/nipovpn
|
||||
|
||||
cat > package-root/DEBIAN/postinst <<'EOF'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p /var/log/nipovpn
|
||||
|
||||
if [ ! -f /var/log/nipovpn/nipovpn.log ]; then
|
||||
touch /var/log/nipovpn/nipovpn.log
|
||||
chmod 0644 /var/log/nipovpn/nipovpn.log
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
chmod 755 package-root/DEBIAN/postinst
|
||||
|
||||
echo "Final control file:"
|
||||
cat package-root/DEBIAN/control
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Build and Release Package - Main
|
||||
name: Build and Release Package - main
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -14,7 +14,7 @@ permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.57
|
||||
PACKAGE_VERSION: 1.1.59
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -100,9 +100,32 @@ jobs:
|
||||
|
||||
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
|
||||
|
||||
mkdir -p package-root/DEBIAN
|
||||
cat > package-root/DEBIAN/conffiles <<'EOF'
|
||||
/etc/nipovpn/config.yaml
|
||||
EOF
|
||||
|
||||
rm -f package-root/var/log/nipovpn/nipovpn.log
|
||||
mkdir -p package-root/var/log/nipovpn
|
||||
|
||||
cat > package-root/DEBIAN/postinst <<'EOF'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p /var/log/nipovpn
|
||||
|
||||
if [ ! -f /var/log/nipovpn/nipovpn.log ]; then
|
||||
touch /var/log/nipovpn/nipovpn.log
|
||||
chmod 0644 /var/log/nipovpn/nipovpn.log
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
chmod 755 package-root/DEBIAN/postinst
|
||||
|
||||
echo "Final control file:"
|
||||
cat package-root/DEBIAN/control
|
||||
|
||||
@@ -285,7 +308,7 @@ jobs:
|
||||
run: |
|
||||
ls -lah
|
||||
|
||||
- name: Create GitHub Release
|
||||
- name: Create main GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ env.PACKAGE_VERSION }}
|
||||
@@ -296,4 +319,4 @@ jobs:
|
||||
nipovpn_${{ env.PACKAGE_VERSION }}_arm64.deb
|
||||
nipovpn_${{ env.PACKAGE_VERSION }}_termux_aarch64.deb
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -15,7 +15,7 @@ permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PACKAGE_VERSION: 1.1.57
|
||||
PACKAGE_VERSION: 1.1.59
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
|
||||
@@ -38,7 +38,7 @@ Build from source for [Linux](guides/BuildLinux.md)
|
||||
|
||||
## Termux
|
||||
|
||||
Build from source for [Linux](guides/InstallTermux.md)
|
||||
Build from source for [Termux](guides/InstallTermux.md)
|
||||
|
||||
|
||||
## Run
|
||||
|
||||
@@ -62,8 +62,7 @@ void AgentHandler::handle() {
|
||||
return;
|
||||
} else {
|
||||
log_->write("[" + to_string(uuid_) + "] [CONNECT] [SRC " +
|
||||
clientConnStr_ + "] [DST " + config_->agent().serverIp + ":" +
|
||||
std::to_string(config_->agent().serverPort) + "]",
|
||||
clientConnStr_ + "] [ORIGIN " + std::string(request_->parsedHttpRequest().target()) + "]",
|
||||
Log::Level::INFO);
|
||||
}
|
||||
|
||||
|
||||
+15
-13
@@ -10,11 +10,12 @@ Config::Config(RunMode mode, const std::string &filePath)
|
||||
listenPort_(0),
|
||||
general_({configYaml_["general"]["token"].as<std::string>(),
|
||||
configYaml_["general"]["protocol"].as<std::string>(""),
|
||||
configYaml_["general"]["bufferSize"].as<unsigned int>(65536),
|
||||
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"]["pullTimeout"].as<unsigned short>(),
|
||||
configYaml_["general"]["timeout"].as<unsigned short>(10),
|
||||
configYaml_["general"]["pullTimeout"].as<unsigned short>(1),
|
||||
configYaml_["general"]["tunnelEnable"].as<bool>(false),
|
||||
configYaml_["general"]["connectionReuse"].as<bool>(false),
|
||||
configYaml_["general"]["tlsEnable"].as<bool>(false),
|
||||
@@ -22,18 +23,18 @@ Config::Config(RunMode mode, const std::string &filePath)
|
||||
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>(),
|
||||
log_({configYaml_["log"]["logLevel"].as<std::string>("INFO"),
|
||||
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>()}),
|
||||
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>()}) {
|
||||
server_({configYaml_["server"]["threads"].as<unsigned short>(2),
|
||||
configYaml_["server"]["listenIp"].as<std::string>("127.0.0.1"),
|
||||
configYaml_["server"]["listenPort"].as<unsigned short>(8080)}),
|
||||
agent_({configYaml_["agent"]["threads"].as<unsigned short>(2),
|
||||
configYaml_["agent"]["listenIp"].as<std::string>("127.0.0.1"),
|
||||
configYaml_["agent"]["listenPort"].as<unsigned short>(8080),
|
||||
configYaml_["agent"]["serverIp"].as<std::string>("127.0.0.1"),
|
||||
configYaml_["agent"]["serverPort"].as<unsigned short>(8080),
|
||||
configYaml_["agent"]["httpVersion"].as<std::string>("1.1"),
|
||||
configYaml_["agent"]["userAgent"].as<std::string>("NipoAgent")}) {
|
||||
|
||||
std::lock_guard<std::mutex> lock(configMutex_);
|
||||
|
||||
@@ -75,6 +76,7 @@ std::string Config::toString() const {
|
||||
<< " General :\n"
|
||||
<< " token: " << general_.token << "\n"
|
||||
<< " protocol: " << general_.protocol << "\n"
|
||||
<< " bufferSize: " << general_.bufferSize << "\n"
|
||||
<< " fakeUrls: ";
|
||||
|
||||
for (std::size_t i = 0; i < general_.fakeUrls.size(); ++i) {
|
||||
|
||||
@@ -21,6 +21,7 @@ private:
|
||||
struct General {
|
||||
std::string token;
|
||||
std::string protocol;
|
||||
unsigned int bufferSize;
|
||||
std::vector<std::string> fakeUrls;
|
||||
std::vector<std::string> methods;
|
||||
std::vector<std::string> endPoints;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static constexpr std::size_t BufferSize = 8192;
|
||||
static constexpr std::size_t BufferSize = 65536;
|
||||
|
||||
class Uncopyable {
|
||||
public:
|
||||
@@ -321,6 +321,7 @@ inline BoolStr validateConfig(int argc, const char *argv[]) {
|
||||
try {
|
||||
configYaml["general"]["token"].as<std::string>();
|
||||
configYaml["general"]["protocol"].as<std::string>();
|
||||
configYaml["general"]["bufferSize"].as<unsigned int>();
|
||||
configYaml["general"]["fakeUrls"].as<std::vector<std::string>>();
|
||||
configYaml["general"]["methods"].as<std::vector<std::string>>();
|
||||
configYaml["general"]["endPoints"].as<std::vector<std::string>>();
|
||||
@@ -361,7 +362,12 @@ inline BoolStr validateConfig(int argc, const char *argv[]) {
|
||||
}
|
||||
|
||||
if (configYaml["general"]["protocol"].as<std::string>() != "http" && configYaml["general"]["protocol"].as<std::string>() != "socks5") {
|
||||
result.message = "First argument must be one of [http|socks5]\n";
|
||||
result.message = "protocol must be one of [http|socks5]\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
if (configYaml["general"]["bufferSize"].as<unsigned int>() < 1 || configYaml["general"]["bufferSize"].as<unsigned int>() > 65536) {
|
||||
result.message = "bufferSize must be between 1 and 65536\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -12,6 +12,9 @@ int main(int argc, char const *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string mode(argv[1]);
|
||||
RunMode runMode_ = (mode == "agent") ? RunMode::agent : RunMode::server;
|
||||
|
||||
BoolStr configValidation = validateConfig(argc, argv);
|
||||
if (!configValidation.ok) {
|
||||
std::cerr << "Configuration validation failed: " << configValidation.message
|
||||
@@ -19,9 +22,6 @@ int main(int argc, char const *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string mode(argv[1]);
|
||||
RunMode runMode_ = (mode == "agent") ? RunMode::agent : RunMode::server;
|
||||
|
||||
Config::pointer config_ = Config::create(runMode_, std::string(argv[2]));
|
||||
|
||||
Log::pointer log_ = Log::create(config_);
|
||||
|
||||
@@ -197,7 +197,7 @@ void ServerHandler::handle() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<char> data(std::min<std::size_t>(available, 65536));
|
||||
std::vector<char> data(std::min<std::size_t>(available, config_->general().bufferSize));
|
||||
std::size_t n = targetClient->socket().read_some(
|
||||
boost::asio::buffer(data),
|
||||
ec);
|
||||
@@ -283,7 +283,7 @@ void ServerHandler::handle() {
|
||||
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [TUNNEL] [SRC " +
|
||||
"] [CONNECT] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
inner->dstIp() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
@@ -327,7 +327,7 @@ void ServerHandler::handle() {
|
||||
log_->write(
|
||||
"[" + to_string(uuid_) +
|
||||
"] [CONNECT] [SRC " +
|
||||
clientConnStr_ + "] [DST " +
|
||||
clientConnStr_ + "] [ORIGIN " +
|
||||
inner->dstIp() + ":" + std::to_string(inner->dstPort()) + "]",
|
||||
Log::Level::INFO);
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ void TCPConnection::doReadAgent() {
|
||||
resetTimeout();
|
||||
|
||||
socket_.async_read_some(
|
||||
readBuffer_.prepare(8192),
|
||||
readBuffer_.prepare(BufferSize),
|
||||
boost::asio::bind_executor(
|
||||
strand_,
|
||||
[self = shared_from_this()](
|
||||
@@ -869,7 +869,7 @@ void TCPConnection::asyncWriteToAgentConnection(
|
||||
}
|
||||
|
||||
void TCPConnection::asyncReadFromAgentConnection(
|
||||
std::array<char, 8192> &buffer,
|
||||
std::array<char, BufferSize> &buffer,
|
||||
std::function<void(const boost::system::error_code &, std::size_t)> done) {
|
||||
if (config_->general().tlsEnable && tlsSocket_) {
|
||||
tlsSocket_->async_read_some(
|
||||
@@ -910,7 +910,7 @@ void TCPConnection::asyncWriteToAgentServerConnection(
|
||||
}
|
||||
|
||||
void TCPConnection::asyncReadFromAgentServerConnection(
|
||||
std::array<char, 8192> &buffer,
|
||||
std::array<char, BufferSize> &buffer,
|
||||
std::function<void(const boost::system::error_code &, std::size_t)> done) {
|
||||
if (client_->tlsEnabled()) {
|
||||
client_->sslSocket().async_read_some(
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/etc/nipovpn/config.yaml
|
||||
@@ -1,7 +1,7 @@
|
||||
Package: nipovpn
|
||||
Version: ${PACKAGE_VERSION}
|
||||
Version: 0.0.0
|
||||
Maintainer: Morteza Bashsiz
|
||||
Architecture: ${{ matrix.arch }}
|
||||
Description: Powerfull and Secure http/s Proxy
|
||||
Architecture: amd64
|
||||
Depends: libyaml-cpp0.8
|
||||
Homepage: https://github.com/MortezaBashsiz/nipovpn
|
||||
Description: Powerful and secure proxy
|
||||
@@ -6,7 +6,11 @@ general:
|
||||
# protocol:
|
||||
# Defines the protocol between client and agent
|
||||
# Choose http or socks5
|
||||
protocol: http
|
||||
protocol: socks5
|
||||
# bufferSize: unsigned short
|
||||
# Defines the maximum buffer size for each request in Bytes. Default is 65536
|
||||
# Do not use less than 1 and more than 65536
|
||||
bufferSize: 65536
|
||||
# fakeUrls:
|
||||
# Defines the list of fake urls between agent and server
|
||||
fakeUrls:
|
||||
@@ -40,18 +44,18 @@ general:
|
||||
# pullTimeout: unsigned short
|
||||
# Defines the timeout for I/O Operation in milliseconds.
|
||||
# Useful to expire serverside read timer.
|
||||
pullTimeout: 50
|
||||
pullTimeout: 1
|
||||
# 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
|
||||
# If true then it will use same connection between agent and server to handle client request
|
||||
# If false 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
|
||||
tlsEnable: true
|
||||
# tlsVerifyPeer: bool
|
||||
# Use it to controll if the certificate should be validated or not
|
||||
tlsVerifyPeer: false
|
||||
@@ -64,7 +68,7 @@ general:
|
||||
# This block is to define log directives
|
||||
log:
|
||||
# logLevel: "INFO|TRACE|DEBUG"
|
||||
logLevel: "DEBUG"
|
||||
logLevel: "INFO"
|
||||
# logFile: "/var/log/nipo/nipo.log"
|
||||
# Path of log file
|
||||
logFile: "/var/log/nipovpn/nipovpn.log"
|
||||
@@ -76,7 +80,7 @@ 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: 80
|
||||
listenPort: 443
|
||||
|
||||
|
||||
# This block is to define agent directives
|
||||
@@ -90,7 +94,7 @@ agent:
|
||||
# serverIp: IPv4 of the nipoServer
|
||||
serverIp: "127.0.0.10"
|
||||
# serverPort: port number of the nipoServer
|
||||
serverPort: 80
|
||||
serverPort: 443
|
||||
# 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
|
||||
|
||||
@@ -8,6 +8,7 @@ ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
Type=simple
|
||||
LimitNOFILE=1048576
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -8,6 +8,7 @@ ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
Type=simple
|
||||
LimitNOFILE=1048576
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Whitespace-only changes.
Reference in new issue
Block a user