What Safeveil is.
Safeveil is self-hosted VPN gateway software. You install it on a Linux server, and it turns that server into a WireGuard gateway with a small control API. A web console manages who can connect: people's devices, and AI agents that should only reach specific services.
Gateway
A WireGuard interface, the control API, a policy DNS resolver for agent tunnels and an nftables rule set. Installed by one script on Debian 12 or Ubuntu 24.04.
Console
A static web app that manages a gateway over HTTPS. It also has a preview mode that runs entirely in the browser, so you can try it before deploying anything.
Device access
Standard WireGuard configurations for the official apps on Windows, macOS, iOS, Android and Linux. Device traffic is never logged.
Agent tunnels
WireGuard access for AI agents that can only reach allowlisted domains, expires on its own, and keeps an activity log.
Control path and data path.
Two separate paths keep management and traffic apart. The console only ever talks to the control API; VPN traffic only ever flows through WireGuard.
wg-quickThe console reaches the gateway at https://your-domain/api/. nginx terminates TLS and forwards to the API, which listens on 127.0.0.1:8787 only.
Browser → HTTPS → nginx → control API. Every request except the health check needs the admin bearer token. The API changes WireGuard peers, firewall sets and the peer database.
Device → encrypted WireGuard tunnel → gateway → internet. The console, the website and Vercel never carry VPN traffic.
Deploy to a clean server.
Requirements
A record pointing your domain at the serverRun the installer
Copy this repository to the server, then run the installer as root from the repository folder. Use the two-letter country code of the server's location as the location ID; it must match an entry in dist/locations.json.
export UNTRACE_DOMAIN="vpn.example.com"
export UNTRACE_ADMIN_EMAIL="admin@example.com"
export UNTRACE_ADMIN_TOKEN="$(openssl rand -base64 48)"
export UNTRACE_LOCATION_ID="de"
export UNTRACE_LOCATION_NAME="Germany · Frankfurt"
echo "$UNTRACE_ADMIN_TOKEN" # store this in a password manager now
sudo --preserve-env=UNTRACE_DOMAIN,UNTRACE_ADMIN_EMAIL,UNTRACE_ADMIN_TOKEN,UNTRACE_LOCATION_ID,UNTRACE_LOCATION_NAME \
bash gateway/bootstrap.sh
What the installer does
WireGuard, nftables, nginx, certbot and Node.js from the distribution's repositories.
Generates the server key once, writes wg0 on 10.70.0.1/24, and enables IPv4 forwarding and NAT.
Writes /etc/untrace/control.env (readable by root only) and starts untrace-control, which runs the API and the agent policy resolver.
Copies the website to nginx, requests a Let's Encrypt certificate and redirects HTTP to HTTPS. If ufw is active, it opens the required ports and DNS on wg0.
The installer never prints the token. Anyone with it can create and revoke access. Don't put it in source control, screenshots or support messages.
Connect a device.
Open https://vpn.example.com/console.html, choose the gateway's location, switch to Live gateway, and enter the gateway URL and admin token.
Select + Device and give it a name. The gateway generates a key pair and returns a configuration with the private key. It is shown once.
Download the .conf file and import it into the official WireGuard app, or scan it from another device. Turn the tunnel on.
Revoke removes the key from the live interface and the database at once. The configuration stops working immediately.
Device configurations use the DNS servers from UNTRACE_DNS (Cloudflare by default) and route all traffic through the tunnel. IPv6 is routed into the tunnel and dropped, so it can't leak around it, but the gateway doesn't provide IPv6 internet access.
Agent tunnels.
An agent tunnel is a WireGuard peer for an AI agent or automated job. It has three rules the gateway enforces: an allowlist of domains, an expiry time, and an activity log. The goal is to limit what an agent can reach even if it is tricked by content it reads (prompt injection) or misbehaves.
Create one
In the console, select + Agent tunnel, name it, and list the domains it needs, one per line. Presets add the usual hosts for GitHub, PyPI, npm, the Anthropic API and the OpenAI API.
From 5 minutes to 7 days. Pick the shortest time the job needs.
Copy the configuration to that machine or container and run sudo wg-quick up ./research-agent.conf. Leave the DNS line unchanged: it points at the gateway's policy resolver.
For the strongest isolation, run the agent in its own container or virtual machine with the tunnel as its only route, so nothing else on the host shares it.
How enforcement works
Agent configurations use 10.70.0.1 as their DNS server. The gateway answers only for allowlisted names and returns NXDOMAIN for everything else. Blocked lookups never leave the gateway, which also stops data from being smuggled out inside DNS queries.
Each address the resolver returns is added to an nftables set for that agent only. New connections from the agent to any other address are dropped, so connecting to a raw IP address doesn't work either.
- Allowed addresses stay open for the record's DNS lifetime, clamped between 5 minutes and 1 hour, and are refreshed on each lookup.
- Connections that are already open continue until they close, even after an allowlist change.
- IPv6 (
AAAA) andHTTPS/SVCBlookups get empty answers, because IPv6 isn't routed and those records can carry address hints. - The resolver only answers agent tunnels. Other sources get
REFUSED, so it is never an open resolver.
Allowlist rules
| Entry | Matches |
|---|---|
| api.github.com | Exactly api.github.com. Not github.com and not other subdomains. |
| *.pypi.org | Any subdomain, such as upload.pypi.org. Not pypi.org itself; add it separately if needed. |
| https://pypi.org/simple/ | Pasted URLs are reduced to the host name, pypi.org. |
| 203.0.113.7 | Rejected. Allowlists accept domain names only. |
An allowlist can hold up to 64 entries. Edit it at any time from the console or with PUT /api/peers/:id/allowlist. Saving clears the agent's previously resolved addresses, so removed domains stop working for new connections right away.
Expiry
When a tunnel expires, the resolver stops answering it immediately, and within 15 seconds the gateway removes its WireGuard key, clears its firewall entries and deletes its activity log. Expired tunnels are also cleaned up when the service restarts.
Activity log
For agent tunnels only, the gateway records each domain lookup with its result and the addresses returned, plus allowlist changes. Repeated identical lookups within a minute are combined into one entry. The last 500 entries are kept in /var/lib/untrace/activity/. The console also lists blocked direct-IP connections from the last hour, read live from the firewall.
- Enforcement works on domain names and IP addresses, not on the content of requests. An agent can still send data to a service you allowed, such as a repository or an API.
- Some providers serve many sites from shared addresses. A site that shares an IP address with an allowed domain may be reachable while that address is allowed.
- Pair agent tunnels with narrowly scoped API keys, short expiry times and short allowlists.
Check a link first.
Domain check is a separate tool at check.html. Paste any link or domain, and Safeveil's agent runs a security check and gives a score from 0 to 100 with a verdict: Looks safe, Be careful or Likely dangerous. A safe result can be sent straight to a new agent tunnel's allowlist.
| Check | What it looks for |
|---|---|
| Lookalike | Imitations of about 40 well-known brands: swapped characters (g1thub), near-miss spellings, brand names with words like "login" or "verify", foreign alphabets, and a brand placed in front of another domain (github.com.account-check.io). |
| Link structure | Hidden credentials (user@host), raw IP addresses, plain http, unusual ports, very long or deeply nested names. |
| Domain ending | Endings that are often used for throwaway sites. |
| DNS | Whether the domain exists, its public addresses, and mail setup (SPF and DMARC). Addresses in private networks are refused. |
| Domain age | The registration date from RDAP. Domains younger than 30 days fail; most phishing domains are brand new. |
| Certificate | A trusted TLS certificate that matches the domain, its issuer and days until expiry. |
| Headers and redirects | Five common security headers, and whether the site immediately sends visitors to a different domain. |
Use it from code
# On the website (no token; 20 checks a minute per address)
curl "https://safeveil.pro/api/check?url=g1thub-login.com"
# On your gateway, for agents (admin token required)
curl -X POST https://vpn.example.com/api/check \
-H "Authorization: Bearer $UNTRACE_ADMIN_TOKEN" \
-H "Content-Type: application/json" -d '{"url":"https://example.com/login"}'
Both return the same JSON report: score, verdict, summary and a checks list where each entry has a status of pass, warn, fail or info.
- These are automated, heuristic checks, not a guarantee. A site can pass every check and still be malicious, and the brand list is not exhaustive.
- The check doesn't use paid reputation feeds or blocklists.
- Checking a link makes requests to that site and to public registries from Safeveil's servers (or your gateway), never from your device. Nothing you check is stored.
- Safeveil never connects to private or reserved network addresses, and never follows redirects. It only reports where they go.
Add country gateways.
Each gateway serves one exit location. To offer several countries, deploy one server per country, each with its own domain and a unique UNTRACE_LOCATION_ID. Then mark it live in dist/locations.json and redeploy the website:
{"id":"de","country":"Germany","flag":"🇩🇪","city":"Frankfurt",
"region":"Europe, Middle East & Africa",
"available":true,"controlUrl":"https://de.vpn.example.com"}
The locations page then shows the country as deployed, and the console fills in the gateway URL automatically. The console refuses to connect if a gateway reports a different location from the one selected.
Using the console.
/console.html, which works with no extra setup. To use a console hosted elsewhere, such as on Vercel, set UNTRACE_ALLOWED_ORIGIN on the gateway to that site's exact origin.Control API reference.
All endpoints are under /api/ and return JSON. Send the admin token as Authorization: Bearer <token> on every request except /api/health.
| Endpoint | Description |
|---|---|
| GET /api/health | Service status, location and supported features. No token needed. |
| GET /api/status | Interface, endpoint, and every peer with its latest handshake and transfer counters. |
| GET /api/peers | Saved peers without live WireGuard data. |
| POST /api/peers | Create a device or agent tunnel. Returns the client configuration once. |
| DELETE /api/peers/:id | Revoke a peer immediately. |
| PUT /api/peers/:id/allowlist | Replace an agent tunnel's allowlist. |
| GET /api/peers/:id/activity | An agent tunnel's activity log and blocked direct connections. |
| POST /api/check | Run a domain check on a link. See Domain check. |
Create an agent tunnel
curl -X POST https://vpn.example.com/api/peers \
-H "Authorization: Bearer $UNTRACE_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"research-agent","type":"agent",
"allowlist":["api.github.com","*.pypi.org"],
"expiresInMinutes":60}'
Response (201)
{
"peer": {
"id": "4f6c…", "name": "research-agent", "type": "agent",
"address": "10.70.0.12", "allowlist": ["api.github.com", "*.pypi.org"],
"expiresAt": "2026-11-08T16:02:11.000Z", …
},
"clientConfig": "[Interface]\nPrivateKey = …\nDNS = 10.70.0.1\n…",
"notice": "This configuration contains the private key and is returned only once."
}
type is "device" (default) or "agent". For agents, allowlist is required and expiresInMinutes must be from 5 to 10080 (default 60). Errors return {"error": "…"} with status 400 (invalid input), 401 (missing or wrong token), 404, 409 (duplicate name, wrong location or full subnet), 413 or 429 (more than 90 requests a minute from one address).
Gateway settings.
The installer writes these to /etc/untrace/control.env. Restart untrace-control after changing them.
| Variable | Default | Purpose |
|---|---|---|
| UNTRACE_ADMIN_TOKEN | required | Bearer token for the API, at least 32 characters. |
| UNTRACE_WG_ENDPOINT | required | Public host:port written into client configurations. |
| UNTRACE_LOCATION_ID | custom | Location code the console checks before connecting. |
| UNTRACE_LOCATION_NAME | Private gateway | Human-readable location name. |
| UNTRACE_WG_SUBNET_PREFIX | 10.70.0 | Tunnel subnet. Peers get addresses .2 to .254. |
| UNTRACE_DNS | 1.1.1.1, 1.0.0.1 | DNS servers for device configurations. |
| UNTRACE_ALLOWED_ORIGIN | your site | The one browser origin allowed to call the API (CORS). |
| UNTRACE_AGENT_ENFORCEMENT | 1 | Runs the policy resolver and nftables rules. Set to 0 only for testing. |
| UNTRACE_AGENT_DNS_BIND | 10.70.0.1 | Address the policy resolver listens on, inside the tunnel. |
| UNTRACE_AGENT_UPSTREAM_DNS | 1.1.1.1, 1.0.0.1 | Resolvers the gateway asks on behalf of agents. IP addresses only. |
| UNTRACE_ACTIVITY_DIR | /var/lib/untrace/activity | Where agent activity logs are kept. |
| UNTRACE_PEER_DB | /var/lib/untrace/peers.json | Peer database. |
| UNTRACE_DRY_RUN | 0 | Set to 1 to exercise the API without touching WireGuard or the firewall. |
What's stored.
Run and maintain.
sudo systemctl status untrace-control wg-quick@wg0
sudo journalctl -u untrace-control --since today
sudo wg show wg0
sudo nft list table inet safeveil_agents # agent rules and sets
Upgrade
Pull the new version of the repository and run the installer again with the same variables. The server key, peer database and activity logs are kept, and existing configurations keep working.
Back up
/etc/wireguard/server_private.key, /var/lib/untrace/peers.json and /etc/untrace/control.env. Store backups encrypted; they contain the server's private key and the admin token.
Test
# Unit and API tests (no root needed)
node --test gateway/tests/*.test.mjs
# Real-kernel firewall test in a throwaway network namespace
sudo gateway/tests/run-netns-test.sh
# Run the API locally without WireGuard
UNTRACE_DRY_RUN=1 UNTRACE_ADMIN_TOKEN="development-token-with-at-least-32-chars" \
UNTRACE_WG_ENDPOINT="localhost:51820" UNTRACE_PEER_DB="./work/peers.json" \
node gateway/bin/untrace-api.mjs
Dry-run mode stores agent tunnels but doesn't enforce them, and its keys are synthetic. Never import a dry-run configuration into a real client.
Security model.
In place
Before you serve people you don't know
- Replace the single admin token with real sign-in and per-user permissions.
- Rotate the admin token regularly and whenever someone leaves.
- Add monitoring and alerts for the service, certificate expiry and disk space.
- Decide on a logging policy, including nginx, and check the laws where your server is hosted.
- Write terms of use and a way to handle abuse reports.
- Get an independent security review of the gateway and your server setup.
