k-vpn
Linux CLI for selecting public VPN Gate relays, verifying the HTTPS exit and measuring real download throughput before connecting with OpenVPN.
The client is locally controlled; the exit fleet is not self-hosted. Country availability and bandwidth change with volunteer relays. No anonymity, universal network bypass or throughput guarantee is implied.
Install
Requirements: Linux, Python 3.12+, uv, OpenVPN, curl, iproute2 and sudo.
uv tool install k-vpn
# Development checkout, the installation used on this workstation:
git clone git@github.com:kpihx-labs/k-vpn.git
cd k-vpn
make uv-link
The workstation checkout is $HOME/Labs/KpihX-Labs/VPNs/k-vpn. The command is
exposed through uv's normal user tool directory, usually $HOME/.local/bin.
Editable installation uses this checkout directly; moving it requires relinking.
Use
k-vpn # interactive country table
k-vpn --country JP --bench 6 --test-only # benchmark, then close all test tunnels
k-vpn --country Japan --bench 6 --min-speed 0.5
k-vpn --country JP --server 122.133.152.245 --bench 1 --test-only
k-vpn --country JP --bench 4 --test-only --tuning balanced
Sudo asks for a password automatically when needed. A separate manual authentication command is not required. Ctrl-C closes the owned session.
| Option | Behavior |
|---|---|
--country, -c |
Match a country name or ISO code, not a changing menu index |
--bench N |
Test up to N candidate profiles; zero skips benchmarking |
--test-only |
Benchmark without retaining a connection; requires N greater than zero |
--server IP |
Pin a relay only if it is still present in the current listing |
--tuning native |
Preserve profile MTU/buffers; default, with authentication/cipher fixes |
--tuning balanced |
Experimental UDP MTU/buffer tuning; no proven universal gain |
--min-speed X |
Fail over after repeated unusable/slow probes; zero disables monitoring |
--strict-discovery |
Forbid unauthenticated HTTP discovery fallback |
--no-strict-discovery |
Explicitly allow the warned legacy HTTP fallback |
--insecure, -k |
Disable API TLS verification only; unsafe, does not disable DNS |
Discovery first tries HTTPS. When a legacy HTTP mirror is used, the CLI warns that the relay list is unauthenticated. Root profile validation does not establish the list's origin. HTTPS destinations are verified independently.
Configuration and files
There is no legacy home-root directory, migration, snapshot recovery or automatic
benchmark report generation. Imports and --help create no application files.
| Purpose | Default path | Lifetime |
|---|---|---|
| Preferences | $HOME/.config/k-vpn/config.json |
Created once on a real CLI invocation; never overwritten automatically |
| Derived measurement cache | $HOME/.cache/k-vpn/measurements.json |
Persistent, labelled observations; ten-minute display validity |
| OpenVPN profiles, public VPN Gate credentials, control socket | $XDG_RUNTIME_DIR/k-vpn-<random>/, otherwise /tmp/k-vpn-<random>/ |
Private temporary directory, removed at session end |
XDG_CONFIG_HOME and XDG_CACHE_HOME override the standard bases when absolute.
XDG_RUNTIME_DIR is used only when it is a usable absolute directory; otherwise
Linux /tmp is used. No sudo password is stored. Configuration and temporary
credential files are private; the cache is derived data, not browsing history.
The initial configuration is:
{
"bench": 10,
"min_speed": 3.0,
"tuning": "native",
"strict_discovery": false
}
Explicit CLI flags override these preferences, including zero and false. For low-bandwidth relays, choose an appropriate monitoring threshold rather than assuming the default 3 Mbps is attainable.
How selection works
- Fetch the current VPN Gate CSV; countries, relay IPs, reported speed and public OpenVPN profiles are live data, not a hardcoded country/server catalogue.
- Parse active profile directives, ignoring comments. Prefer useful transports without discarding every non-web port; policy varies with the actual network.
- Reject hooks, plugins, external key files and unsupported profile directives before privileged execution. Keep native certificate authentication; do not inject vpn/vpn into a profile that does not request password authentication.
- Require a TUN route, interface-bound HTTPS, a valid public exit and received payload before reporting a speed. Distinguish authentication, connection, egress verification and download-host refusals. Try OVH after a failed Cloudflare measurement. Failures remain unmeasured, not zero Mbps.
- Keep the best freshly verified candidate in the selected country. Use a private UID-restricted Unix control socket for shutdown, never killall.
Advertised is the provider's field, not a measurement from your device. Recent
cached observations are scoped to uplink/profile/tuning and labelled; live
selection always remeasures. There is no guaranteed advertised-to-real ratio.
Evidence and limitations
BENCHMARKS.md is the single benchmark record: controlled runs,
the complete 95-profile survey, rechecks, failures and limitations. It establishes
no universal tuning multiplier or sustained speed guarantee.
This client handles IPv4. It has no kill switch or verified IPv6 protection. HTTPS content stays encrypted to the destination; plain HTTP and traffic metadata can be visible at the exit. A QUIC handshake or one open port does not prove every VPN protocol will cross every restrictive network.
Development and release
make check # global ruff/pyright, compilation and offline regressions
make build # validate; build sdist and wheel in dist/
make uv-link # refresh the editable installation
make push # xargs pushes the current branch to all remotes in parallel
make publish # PyPI; run with-env make publish in the authenticated ops pane
Tests use isolated temporary directories, never live tunnels or sudo. make push
fails on detached HEAD, missing remotes or a failed remote push. No secrets belong
in the repository. MIT license; see LICENSE.
Metadata
Release files for k-vpn 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| k_vpn-1.2.0.tar.gz | 16.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k_vpn-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.6 kB
Release files / k_vpn-1.2.0.tar.gz
| Download URL | k_vpn-1.2.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42c1489454f4deae15842905b044802f1401b229f5f5456e29af8cadcbd7c76a
|
|
BLAKE2b-256 checksum How to use checksums |
2714a7449e1cef06185072423be9c6cf85649dd1a782021a447c95c789ba14a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / k_vpn-1.2.0-py3-none-any.whl
| Download URL | k_vpn-1.2.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
784b905f4c6fc1762137df8ab8cbfe6dd2e0fa779375f8c3e677d65180ae627e
|
|
BLAKE2b-256 checksum How to use checksums |
0f0a98fd80199588abfef5efa48c0d88b42a0cafbfd1166a980962cade9856f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for k-vpn 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.