If you run your own Xray servers on Windows, you probably use v2rayN, or you used NekoRay until it stopped at version 4.0.1 in 2024. Both work. But every time you switch servers in v2rayN, your connection is gone for about three quarters of a second, and testing a list of servers takes a couple of seconds even when they're all on the same machine.

I wanted a client where those things are fast enough that you stop noticing them, so I built TunRay. It's free, open source under GPL-3.0, and the engine is written in Rust.

GitHub logo Mahan-Imanian / tunray

A fast Windows client for your own Xray and OpenVPN servers: VLESS with REALITY and XHTTP, Hysteria2, OpenVPN, subscriptions, real delay tests, seamless switching, and App, Whole PC and VPN modes.

TunRay

A fast Xray and OpenVPN client for Windows, for the servers you already have.

Paste a share link, a subscription or a QR code, or drop an .ovpn file TunRay tests every server for real from where you are, connects through the one that works, and keeps you connected when the network changes. Sites you choose, like your bank, skip the VPN with one click.

CI Latest release Downloads License: PolyForm Shield 1.0.0 Windows 10 and 11

Download · User guide · Troubleshooting · Changelog · فارسی · 中文 · Русский

TunRay testing nine servers while the list re-ranks itself by delay, then connecting to the fastest with a double-click and switching to another

Why TunRay

Most Xray clients show you a list and leave the rest to you. TunRay is built around the questions you actually have: which of my servers works right now which is fastest, and am I really protected?

  • Fast from the engine up. The engine is written in Rust and keeps Xray ready before you click. On the same PC it tested 20 servers in 0.08 to 0.12 s, where…

TunRay testing nine servers while the list re-ranks itself by delay, then connecting to the fastest and switching to another

The numbers

I measured TunRay 0.2.6 against v2rayN 8.0.2, v2rayN 7.25.6 and Throne 1.4.6 (the continuation of NekoRay) on one Windows 11 PC. Every client imported the same 25 share links: 20 working Shadowsocks servers on the same PC and 5 that point at unreachable addresses. Keeping the servers local takes the internet out of the result, so the numbers show what each client adds.

What TunRay 0.2.6 v2rayN 8.0.2 Throne 1.4.6
Test 20 working servers 81–120 ms 1,399–2,266 ms 268–288 ms
Gap with no connection while switching 12–18 ms 740–778 ms 216–249 ms

So testing is 12 to 28 times faster than v2rayN, and the switching gap is 40 to 65 times shorter. The full method, every run and the limits are in docs/benchmark.md.

The limits matter, so here they are up front. It's one PC, one protocol and local servers. Real servers add their own network delay to every number, for every client. And when a list has unreachable servers, every client just waits for its timeout. Throne finishes that test first because it gives up after 5 seconds instead of 6.

How switching stays under 20 ms

Most clients switch by stopping the current connection, starting the core with the new server, and hoping it works. Your connection is down the whole time the new core starts.

TunRay does it in a different order:

  1. Start the new server on spare ports.
  2. Send it a real request and wait for an answer.
  3. Only then stop the current connection and move the new server onto the fixed local ports.

Apps pointed at those ports never need reconfiguring, and the gap is one core start. If the new server doesn't answer, nothing changes: you stay on the current one and the window tells you why.

Why testing was slow, and the Windows quirk behind it

In 0.2.4, testing 20 servers took 171–198 ms. Four changes in 0.2.5 brought it to 81–120 ms, and the biggest one came from a Windows behaviour I didn't expect.

To test a server, TunRay starts Xray and waits for its local port to open. On Windows, a connection to a local port that isn't open yet hangs instead of failing straight away. So the code tried in steps of about 35 ms, which meant it often noticed Xray was ready long after it actually was. Now it starts a new try every 2 ms and notices almost at once.

The other three:

  • The VPN fallback test ran too early. When another VPN is on, TunRay also tests each server through that VPN as a fallback. It used to run that for every server at the same time as the direct test, which doubled the work. Now it starts after 150 ms, and only for servers that haven't answered directly yet.
  • A probe waited 10 ms between its two requests. It doesn't any more.
  • The results waited for Xray to close. The test no longer waits for its Xray process to finish closing before it reports.

None of these is clever on its own. They only showed up because I timed each step instead of the whole test.

A test that tells you what you need to know

A ping only tells you a server answered. TunRay sends a real request through Xray to every server, 16 at a time, and re-sorts the list as results arrive. A server your network blocks shows up as failed, not fast.

It also doesn't say "Protected" until a real request has gone through the server. After sleep or a network change it reconnects on its own, and if the server stops answering it moves to the fastest working one without dropping you first.

Your bank sees you, not your VPN

Pick any site in Activity and choose Always direct. From then on it skips the VPN and sees your own IP, which is what banking, tax and government sites expect. Everything else stays on your server, so you don't have to turn the VPN off to pay a bill. It works in every mode, VPN mode included.

How it's built

TunRay window (Tauri + React) │ named pipe ▼ tunrayd: Rust engine, one per Windows user │ named pipe ▼ tunray-svc: small Windows service that runs Xray's TUN for VPN mode 

The service only accepts typed requests from the engine. It doesn't run whatever it's sent. Release builds come from GitHub Actions, and the bundled Xray and Wintun binaries are checked against pinned SHA-256 hashes during the build. There's no account and no telemetry. The only request TunRay makes of its own is a check for new versions on GitHub, and you can turn that off.

Getting it

It runs on Windows 10 and 11, in English, Persian, Chinese and Russian.

winget install MahanImanian.TunRay 

Or get the installer or portable zip from Releases. You can bring your servers over from v2rayN or NekoRay in one go, or paste share links, a subscription or a QR code. OpenVPN .ovpn files work too, in VPN mode.

Known limits:

  • The installer isn't code-signed yet, so SmartScreen will probably warn you.
  • VPN mode has been run live on two PCs so far, one Windows 10 and one Windows 11.
  • Hysteria2 port hopping isn't supported yet.
  • The translations haven't been reviewed by native speakers.

If you run Xray on Windows, I'd like to know what your current client gets wrong when one of your servers is blocked. That's the part I'm working on next.