MortezaBashsiz/nipovpn
About
Powerfull proxy
Systems & InfrastructureMeasured star growth
- in 24h
- +6
- in 7 days
- +93
- in 15 days
- +163
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalNipoVPN
NipoVPN is a proxy that hides your traffic inside ordinary-looking HTTP requests.
It runs in two roles: an agent on your side and a server outside the
censored or monitored network. The agent wraps each request in a decoy HTTP
request (random method, endpoint and Host), optionally encrypts it with
AES-256-GCM and sends it over TLS. The server unwraps it, talks to the real
destination and sends the response back the same way.
It is written in C++20 on top of Boost.Asio, OpenSSL and yaml-cpp.
- Features
- How it works
- Installation
- Quick start
- Configuration reference
- Security notes
- Logging
- Troubleshooting
- Contribution
- License
Features
Client side (agent)
- HTTP proxy and SOCKS5 proxy for local applications (
agent.protocol).- HTTP: plain HTTP requests and
CONNECTtunnels (HTTPS). - SOCKS5:
CONNECTandUDP ASSOCIATEcommands, no authentication, with IPv4, IPv6 and domain name targets. UDP makes DNS, QUIC, VoIP and games work, so the agent can back a full-device VPN through tun2socks (see Full VPN mode).
- HTTP: plain HTTP requests and
- Multiple agents per server. Each agent session is identified by a UUID, so many agents (and many clients behind each agent) can share one server.
- Multi-threaded. The number of worker threads is configurable for the agent and the server separately.
Traffic obfuscation
- Decoy HTTP requests. Every request between the agent and server is a
normal HTTP request whose method, path and
Hostheader are picked at random from lists you configure (methods,endPoints,fakeUrls). - Configurable
User-Agentand HTTP version for the decoy requests. - Randomized TLS SNI. With TLS enabled, the SNI sent to the server is also
picked at random from
fakeUrls. - Hidden control data. The session ID and action travel inside the (encrypted) body, not in custom headers, so the outer request carries no NipoVPN-specific headers.
Encryption
- AES-256-GCM payload encryption (on by default). The key is the SHA-256 of the user's token; each message gets a random 12-byte nonce and a 16-byte authentication tag, so tampered or wrongly keyed payloads are rejected.
- TLS between agent and server (
tlsEnable): TLS 1.2 minimum, TLS 1.3 preferred, with AEAD-only cipher suites (AES-GCM, ChaCha20-Poly1305). - Optional certificate verification on the agent (
tlsVerifyPeer) against a custom CA (tlsCaFile).
AES and TLS are independent: you can use either, both, or (not recommended) neither.
Connection handling
- Two tunnel modes for
CONNECT/SOCKS5 traffic:- Polling mode (default,
tunnelEnable: false): every chunk of tunneled data is sent as its own decoy HTTP request (send), and the agent polls the server for incoming data (recv). Traffic looks like many short HTTP requests. Polling backs off frompullTimeoutup to 50 ms while idle and snaps back as soon as data arrives. - Direct tunnel mode (
tunnelEnable: true): after the first decoy request, the agent–server connection becomes a raw byte pipe to the destination. Faster, but only the opening request is disguised and encrypted. Use it together withtlsEnable.
- Polling mode (default,
- TCP, UDP or both (
general.traffic, the same on agent and server): choose which kinds of traffic are relayed. Defaultboth. - UDP (SOCKS5
UDP ASSOCIATE) works in both modes. In polling mode, datagrams are batched intoudpsendrequests and fetched withudprecvpolls; in direct tunnel mode they flow as length-prefixed frames on the agent–server connection. An association lives as long as its SOCKS5 control connection; on the server, an unused polling-mode association is dropped after 120 seconds. IP fragments of SOCKS5 UDP (FRAG≠ 0) are not supported and are dropped. - Connection reuse (
connectionReuse): keep one keep-alive connection between agent and server instead of opening a new one per request. - Timeouts: an I/O timeout that closes stalled connections (
timeout) and a configurable buffer size per read (bufferSize).
Operations
- Config validation at startup with clear error messages.
- Per-user monthly traffic limits (e.g. 2 GB), with usage kept in an editable file. See Usage limits.
- Multiple users on one server, each with their own token. Users can be added, disabled or removed without a restart. See Multiple users.
- Reload without restart on
SIGHUP(systemctl reload). See Reloading the configuration. - Web dashboard to manage users and server settings, watch usage and
activity, and share agent configs and
nipovpn://links with QR codes. See Dashboard. - Warning when the public sample token is still in use.
- Log levels
INFO,TRACE(per-request source/destination) andDEBUG; logs go to a file and to stdout. - Packaging:
.debpackages (amd64, arm64) with systemd units, a Docker image and compose file, a Nix flake with a NixOS module, a Termux package, Windows (x86_64) builds and an Android app.
How it works
Use cases
Bypass filtering. Run the server outside the filtered network and the agent inside it. Filtering equipment sees only HTTP(S) requests to harmless-looking hosts.

Hide your requests on the Internet. Even without censorship, NipoVPN hides which sites you visit from anyone watching your connection.

Request flow
Browser/app ──HTTP or SOCKS5──▶ Agent ──decoy HTTP(S)──▶ Server ──real request──▶ Destination
◀────────────────── ◀──────────────── ◀────────────────
- A local application sends a request to the agent (HTTP proxy or SOCKS5).
SOCKS5 requests are converted to an HTTP
CONNECTinternally. - The agent builds an envelope
action + session ID + request bytes, encrypts it with AES-256-GCM (ifaesEnable; otherwise signs it with HMAC-SHA256) and Base64-encodes it. - The envelope is sent as the body of a decoy request such as
PUT /loginwithHost: cloudflare.com, over TLS iftlsEnable. - The server decodes and decrypts the body and performs the action:
request— forward a plain HTTP request and return the response.open— open a TCP connection to theCONNECTtarget.send/recv— write to / read from that connection (polling mode).udpopen— open a UDP association (SOCKS5UDP ASSOCIATE).udpsend/udprecv— send / fetch a batch of datagrams (polling mode).close— close the connection or association.
- The server's reply is encrypted and returned as the body of an HTTP
200 OKresponse; the agent decrypts it and hands it to the application.

Installation
| Platform | How |
|---|---|
| Debian / Ubuntu (amd64, arm64) | .deb from the releases page, tested on Ubuntu 24.04 |
| Arch Linux | AUR package |
| Build from source on Linux | Linux build guide |
| Docker | Docker guide |
| Nix / NixOS | Nix guide |
| Termux | Termux guide |
| Dashboard (web page to manage the server) | nipovpn-dashboard |
| Windows (x86_64) | zip from the releases page (windows-v* tags) |
| Android | nipovpn-android |
Debian package
sudo apt install ./nipovpn.deb
The package installs:
/usr/bin/nipovpn/etc/nipovpn/config.yaml(kept on upgrade)nipovpn-server.serviceandnipovpn-agent.service
sudo systemctl enable --now nipovpn-server.service # on the server
sudo systemctl enable --now nipovpn-agent.service # on the agent machine
Arch Linux
Install NipoVPN from the AUR using your preferred AUR helper:
paru -S nipovpn
Or build and install it manually:
git clone https://aur.archlinux.org/nipovpn.git
cd nipovpn
makepkg -si
The package installs:
/usr/bin/nipovpn/etc/nipovpn/config.yamlnipovpn-server.serviceandnipovpn-agent.service
sudo systemctl enable --now nipovpn-server.service # on the server
sudo systemctl enable --now nipovpn-agent.service # on the agent machine
See the AUR package page for package details.
From source
Requirements: a C++20 compiler, CMake ≥ 3.22, Boost ≥ 1.88, yaml-cpp ≥ 0.8 and OpenSSL. See the Linux build guide for details.
cmake -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build -j$(nproc)
Quick start
The same binary and the same config file format are used on both sides; the first argument selects the role:
nipovpn <server|agent> <config_file_path>
1. Prepare the log file
sudo mkdir -p /var/log/nipovpn/
sudo touch /var/log/nipovpn/nipovpn.log
2. Create a user
Generate a token of at least 32 bytes for each person. Do not use the sample tokens from the shipped config.
openssl rand -hex 16 # prints 32 hex characters
On the server, list it in server.users. On that person's machine, put the
same token in agent.token:
# server config # agent config
server: agent:
users: token: "<alice's token>"
- name: alice
token: "<alice's token>"
3. TLS certificate (if tlsEnable: true)
The server needs a certificate and key. A self-signed pair is enough when
tlsVerifyPeer is false:
sudo openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
-subj "/CN=example.com" \
-keyout /etc/nipovpn/server.key -out /etc/nipovpn/server.crt
4. Run the server
On the server, set server.listenIp/server.listenPort, then:
sudo nipovpn server /etc/nipovpn/config.yaml
5. Run the agent
On your machine, set agent.serverIp/agent.serverPort to the server's
address, set agent.token to one of the server's users, and make sure
aesEnable, tlsEnable and tunnelEnable match the server. Then:
sudo nipovpn agent /etc/nipovpn/config.yaml
6. Point your applications at the agent
# agent.protocol: socks5
curl --socks5-hostname 127.0.0.1:8080 https://example.com
# agent.protocol: http
curl -x http://127.0.0.1:8080 https://example.com
Or configure the agent's address as the SOCKS5/HTTP proxy in your browser or operating system.
Full VPN mode (tun2socks)
To send all of a device's traffic through NipoVPN (for example an Android
VpnService), put a tun2socks layer such as
hev-socks5-tunnel or
tun2socks between the TUN interface
and the agent, and run the agent with protocol: socks5 and general.traffic: both
(the default; tcp gives a TCP-only VPN where apps fall back from QUIC to TCP,
but DNS must then go over TCP and calls and games stop working). tun2socks turns TCP
connections into SOCKS5 CONNECT and UDP flows into SOCKS5 UDP ASSOCIATE.
Use the standard SOCKS5 UDP relay mode of tun2socks; non-standard UDP-over-TCP
extensions are not supported.
Keep the agent's own connection to the server out of the VPN, or its traffic
loops back into the TUN interface. On Android, exclude the app with
VpnService.Builder.addDisallowedApplication(), or call
VpnService.protect() on the agent's socket, or exclude the server's address
from the routes.
Configuration reference
The sample config lives at nipovpn/etc/nipovpn/config.yaml. Settings marked must match have to be the same on agent and server.
general
Settings both sides use. Old configs that still have one of the settings below
in general keep working, with a warning naming the keys to move.
| Key | Type | Default | Description |
|---|---|---|---|
aesEnable |
bool | true |
AES-256-GCM payload encryption. Must match. |
tunnelEnable |
bool | false |
true = direct tunnel mode, false = polling mode. Must match. |
tlsEnable |
bool | false |
TLS between agent and server. Must match. |
traffic |
string | both |
tcp (HTTP, CONNECT, SOCKS5 CONNECT), udp (SOCKS5 UDP ASSOCIATE, needs agent.protocol: socks5) or both. Must match. The agent answers a refused SOCKS5 CONNECT with 0x02 (not allowed) and a refused UDP ASSOCIATE with 0x07 (command not supported); the server answers a mismatched agent with 403 Forbidden. |
timeout |
seconds | 10 |
I/O timeout for stalled connections. 0 disables it. Each side uses its own value. |
log
| Key | Default | Description |
|---|---|---|
logLevel |
INFO |
INFO, TRACE or DEBUG. Errors are always logged. |
logFile |
— | Log file path. The directory and file must exist. |
server
| Key | Default | Description |
|---|---|---|
threads |
2 |
Worker threads. |
listenIp |
127.0.0.1 |
IPv4 address to listen on. |
listenPort |
8080 |
Port to listen on (443 is a good choice to blend in). |
bufferSize |
65536 |
Maximum bytes read from a destination at a time in polling mode, 1–65536. |
tlsCertFile |
— | Server certificate (PEM, chain allowed), used when tlsEnable is on. |
tlsKeyFile |
— | Server private key (PEM). |
agent
| Key | Default | Description |
|---|---|---|
threads |
2 |
Worker threads. |
listenIp |
127.0.0.1 |
IPv4 address for local applications to connect to. |
listenPort |
8080 |
Port for local applications. |
protocol |
— | http or socks5: the protocol local applications use to connect to the agent. |
serverIp |
127.0.0.1 |
IPv4 address of the NipoVPN server. |
serverPort |
8080 |
Port of the NipoVPN server. |
httpVersion |
1.1 |
HTTP version in decoy requests. |
userAgent |
NipoAgent |
User-Agent header in decoy requests. |
fakeUrls |
— | Hosts used at random for the decoy Host header and TLS SNI. |
methods |
GET |
HTTP methods used at random for decoy requests. |
endPoints |
api |
URL paths used at random for decoy requests (/api, /login, ...). |
pullTimeout |
1 |
Base polling interval in milliseconds in polling mode. |
connectionReuse |
false |
Reuse one keep-alive connection to the server. The server follows the agent's choice. |
tlsVerifyPeer |
false |
Verify the server certificate. |
tlsCaFile |
— | CA file used when tlsVerifyPeer is on. |
token |
— | This agent's token, ≥ 32 bytes. Must be the token of an enabled user on the server. The AES key (or, with aesEnable: false, the signing key) is derived from it; the token itself is never sent. |
server.users
The users allowed to connect, each with their own token. Agents do not use this block.
| Key | Default | Description |
|---|---|---|
name |
— | 1–64 characters of A-Z a-z 0-9 . _ - @. Unique. Shown in the server log. |
token |
— | The user's token, ≥ 32 bytes. Unique. The user's agent puts it in agent.token. |
enabled |
true |
false rejects the user without deleting the entry. |
limit |
none | Traffic allowed per month, e.g. 2GB, 500MB, 1.5GiB. See Usage limits. |
server.usage (optional)
| Key | Default | Description |
|---|---|---|
file |
/var/lib/nipovpn/usage.yaml |
Where per-user usage is kept. Changing it needs a restart. |
resetDay |
1 |
Day of the month (1–28) on which everyone's usage goes back to zero. |
Multiple users
Every person gets their own token. The server lists them all in
server.users:
server:
users:
- name: alice
token: "4f3c9a...32 or more characters"
- name: bob
token: "b81e07...32 or more characters"
enabled: false # bob is rejected until this is set back to true
Each user's agent puts their token in agent.token. All other settings that
must match (such as aesEnable, tlsEnable and tunnelEnable) are shared by
everyone.
- The server identifies a request's user by which token decrypts it, or with
aesEnable: false, by which token's HMAC-SHA256 signature matches. Nothing on the wire names the user, so this adds nothing for a censor to fingerprint. - With
aesEnable: false, requests are signed but not encrypted: tampered requests are rejected, but anyone on the path can read them unlesstlsEnableis on. - The server log shows the user on each connection:
[SRC ...] [USER alice]. - A tunnel opened by one user cannot be used by another user.
- Upgrading from
general.token: older configs still work. An agent readsgeneral.tokenwhenagent.tokenis missing, and a server without aserver.userslist acceptsgeneral.tokenas a single user nameddefault. Both log a deprecation warning at startup. To migrate, move the agent's token toagent.tokenand add it to the server'sserver.userslist. Agents of any version keep working, since the token on the wire is the same. - Each new connection costs one decryption attempt per enabled user until a
token matches. A reused connection tries its last user first. This is fine
for dozens of users; with hundreds, prefer
connectionReuse: true.
To add, disable or remove a user, edit the config and reload. When a user is removed or disabled, or their token changes, the server closes their open connections and tunnels on reload.
Usage limits
A server with a server.users list counts each user's traffic: the bytes they send to
websites plus the bytes they receive from them. NipoVPN's own overhead (decoy
HTTP framing, base64, encryption) is not counted. Give a user a monthly
allowance with limit:
server:
usage:
resetDay: 1 # everyone's usage resets on the 1st of each month
users:
- name: alice
token: "..."
limit: 2GB # KB/MB/GB/TB = powers of 1000; KiB/MiB/GiB/TiB = powers of 1024
- name: bob
token: "..." # no limit
When a user reaches their limit, the server closes their open connections and refuses new ones until the next period, and logs:
[Usage] user alice reached their limit of 2.00 GB; blocked until the next period
They regain access as soon as their usage drops below the limit: at the next
resetDay, when you raise their limit (edit the config and reload), or when you
reset them.
Seeing and changing usage. The server writes usage to server.usage.file
(default /var/lib/nipovpn/usage.yaml) every 30 seconds, on reload and on
shutdown:
period: "2026-11-01"
users:
alice: {used: 2000123456} # 2.00 GB of 2.00 GB (100%), blocked
bob: {used: 734003200} # 734.00 MB, no limit
To reset or change a user's usage, edit their used number (for example set it
to 0) and save. The server applies the edit within 30 seconds, or right away
on reload. Traffic counted in the meantime is kept on top of your value. Do not
edit period.
Notes:
- The file is the only record of usage, so it survives restarts. With Docker,
keep
/var/lib/nipovpnon a volume (the compose file does). - If the file cannot be parsed, the server logs an error and stops saving until you fix it, rather than overwriting your edit.
- A user who is removed and later added back keeps their usage for the period.
- Usage is not tracked on a server without a
server.userslist.
Reloading the configuration
Send SIGHUP to apply config changes without dropping other users' connections:
sudo systemctl reload nipovpn-server.service # or nipovpn-agent.service
docker kill -s HUP nipovpn # Docker
kill -HUP "$(pidof nipovpn)" # anything else
The file is validated first. If it is invalid, the running configuration is
kept and the error is logged at ERROR level, so a typo never takes the server
down. A successful reload logs a summary, for example:
[Runner reload] config reloaded; 2 of 3 users enabled; access revoked for: bob
[Runner reload] closed 1 connections and 0 tunnel sessions of revoked users
New requests use the new settings at once. These settings only change on
restart: listenIp, listenPort, threads, tlsEnable and server.usage.file. If you change
them, the reload logs ... changed but needs a restart. Certificate files are
read for every new connection, so a renewed certificate needs no reload at
all. Reload is not available on Windows.
Dashboard
NipoVPN Dashboard is a
separate web dashboard that runs beside the server. It adds, edits, disables
and deletes users, changes server settings, shows usage and activity, and shares
agent configs and nipovpn:// links with QR codes. It works by editing
config.yaml and reloading the server, so it needs nothing from the server
beyond what is described above. It has its own Debian package,
nipovpn-dashboard; see its README for setup.
Security notes
- Change the token. The sample token is public; the program logs a warning if it is still in use.
- Turn on at least one of
aesEnableandtlsEnable. Without either, traffic is only obfuscated, not encrypted. - Direct tunnel mode sends tunneled bytes without the decoy framing or AES,
so pair it with
tlsEnable: true. tlsVerifyPeer: falseprotects against passive observers but not against an active man-in-the-middle. Enable it with a propertlsCaFileif that matters to you. AES-GCM with a strong token still authenticates the payload.- Listening on
0.0.0.0on the agent exposes your proxy to the local network. Use127.0.0.1unless you mean to share it.
Protocol change: this version uses AES-256-GCM and carries the session and action inside the encrypted body instead of
X-Nipo-*headers. It is not compatible with older agents, servers or the Android app; upgrade all of them together.
Logging
Log lines look like:
2026-01-01_12:00:00 [AGENT] [INFO] [<session-uuid>] [CONNECT] [SRC 127.0.0.1:51234] [ORIGIN example.com:443]
2026-01-01_12:00:00 [SERVER] [INFO] [<session-uuid>] [CONNECT] [SRC 203.0.113.7:40112] [USER alice] [ORIGIN example.com:443]
On the server, [USER ...] is the user from the server.users list, or default
when the server still uses the deprecated general.token.
INFO: startup, effective configuration (token hidden), connections opened.TRACE: adds the destination of every forwarded request.DEBUG: adds handshake, encryption and byte-level details. Use only for troubleshooting.
tail -f /var/log/nipovpn/nipovpn.log
journalctl -u nipovpn-server.service -f
Troubleshooting
| Symptom | Likely cause |
|---|---|
Configuration validation failed: ... |
A required key is missing or invalid; the message names the block. |
agent.token must be at least 32 bytes |
Use a longer token (openssl rand -hex 16). |
Error opening log file |
Create the log directory and file (see Quick start). |
Server logs Decryption Failed / Invalid Envelope |
token, aesEnable or NipoVPN versions differ between agent and server. With server.users: the agent's token is not an enabled user's token. |
agent.token is required |
Set the agent's token in the agent block (it used to be general.token). |
the server needs a server.users list with at least one user |
Add a users list under server in the server config. |
users belongs under the server block |
Configs from before this change had users/usage at the top level; indent them under server:. |
[WARNING] general.token is deprecated |
Move the token to agent.token (agent) or a server.users entry (server). |
[WARNING] these settings moved out of general: ... |
Move the listed keys from general to the block the warning names (agent or server). |
limit must be a size with a unit |
Write the limit with a unit: 2GB, 500MB, 1.5GiB, or 1024B for bytes. |
[Usage] cannot read .../usage.yaml |
The usage file has a syntax error, probably from a manual edit. Fix it; usage is not saved until then. |
[Usage] cannot save usage |
The server cannot write server.usage.file; check the directory and permissions. |
[Runner reload] config not reloaded: ... |
The edited file is invalid; the old configuration is still running. Fix the file and reload again. |
Agent logs [Tunnel closed] recv refused or failed |
The server rejected the agent's token (e.g. the user was disabled) or became unreachable. |
Agent logs [TLS] [ERROR] |
tlsEnable differs between the two sides, or the certificate/key path is wrong. |
[CONNECT] [ERROR] [To Server] |
Agent cannot reach serverIp:serverPort (firewall, wrong address, server not running). |
Tests
tests/e2e.py runs end-to-end tests: for each test it starts a real
server and agent on localhost, sends traffic through them with curl, and checks
every byte with SHA-256. It covers every combination of tlsEnable,
tunnelEnable, connectionReuse, aesEnable and protocol, plus multiple users,
unknown and disabled users, reload, usage limits, the 1.1.x config layout and
config validation. Every test config is built from the sample config.yaml.
cmake -S . -B build && cmake --build build -j
python3 tests/e2e.py --binary build/core/nipovpn # all tests
python3 tests/e2e.py --binary build/core/nipovpn -k reload # names containing "reload"
python3 tests/e2e.py --list
It needs Python 3 with PyYAML, curl and openssl. GitHub Actions runs it on every
push and pull request (.github/workflows/test.yml),
once on a release build and once with AddressSanitizer and UndefinedBehaviorSanitizer.
Contribution
See the contribution guide. In short: branch from dev,
format with scripts/format.sh, build and test, and open a pull request against
dev.
License
NipoVPN is released under the GNU General Public License v3.0.
Explore related projects
Loading…