Below the cut I’ll tell you what happened and how I managed to overcome it.
Disclaimer: This article is for informational, research and academic purposes only. The author is not engaged in propaganda, advertising or popularization of means of bypassing blocking, and also does not call for violation of current legislation. All described technologies, protocols and software solutions are considered solely from the point of view of their technical design, the architecture of modern networks and information security. The application of the acquired knowledge for practical purposes remains the personal responsibility of the reader.
I thought for a long time whether it was necessary to write about this on Habr and in what format. Still, I decided to publish it in the form of an article, since many people don’t look at the updates and may think that the tool just broke and died.
How it worked before
When applied to HTTPS, DPI knows where you are going by the SNI field in ClientHello, the first packet of the TLS handshake, where the site's domain name is simply plain text. We see youtube.com there - we drop the connection, and the client goes into a timeout.
NoDPI cut ClientHello into small TLS records so that the domain name was broken into pieces of a couple of bytes. The server merges such records normally, but did not find the DPI signature and missed the connection. In principle, it was expected that this was most likely a forced limitation on the part of DPI simply due to lack of power and sooner or later this shop would be closed. And so it happened.
What's broken
In the last month, users began to complain to me that YouTube stopped opening - connections are working, there are no errors, but the page freezes. In fact, this affected not only YouTube, but also other sites on most providers. Unfortunately, I myself did not notice this problem, since a year has passed since I switched to my own VPN (yes, this happens), and I only use NoDPI at my dacha on the mobile Internet.
So, DPI, judging by the experiments, now collects the entire TCP stream and looks for SNI in the collected data, so packet splitting no longer helps. The problem was reproduced on multiple machines with different operators. Along the way, an interesting detail emerged:
Google IP with someone else's SNI - passes;
alien IP with SNI youtube - passes;
Google IP with SNI youtube - interruption.
This means that TSPU is looking at the “IP + SNI” combination. Next, several crushing options were tested:
fragmentation on TLS records, even 1 byte - block;
each fragment is a separate TCP segment - block;
delays between segments - 1-2 connections out of 10 pass through.
In tcpdump it looks like this: ClientHello goes out in separate segments, SNI goes out in chunks of 7 bytes (record header + 2 bytes of name). Small segments reach, and the last one, after which DPI has already collected a name, goes into endless retransmits. The connection is then closed “on behalf of” Google. The fake is issued by TTL: in one connection, FIN comes with TTL 122 without the DF flag, and RST comes with TTL 110 and DF. ServerHello doesn't arrive at all.
Disorder: breaking the order of packets
After relatively short experiments, which I will not describe, I finally managed to figure out what was what.
Since DPI collects the stream, a logical solution arises: you need to break the order of its segments. This does not interfere with the server, since TCP collects the rearranged segments by sequence numbers. It looks like this:
The first segment with the start of SNI leaves with TTL=1 and dies on the first hop, not reaching the TSPU.
The rest of ClientHello (still chopped) immediately leaves with a normal TTL.
The OS kernel does not receive confirmation for the first segment and after ~200 ms it itself resends it, already with a normal TTL.
The server receives everything and collects a normal ClientHello, but TSPU sees only the middle of the stream without the beginning and SNI does not recognize it.
Everything is done using the standard library via setsockopt: without drivers, raw sockets and administrator rights. Minus: about 200 (approximately!) ms to establish a connection, this does not affect the download speed.
The implementation itself:
Code
async def _send_disorder(
self, writer: asyncio.StreamWriter, first: bytes, rest: bytes
) -> None:
sock = writer.get_extra_info("socket")
if sock.family == socket.AF_INET6:
level = socket.IPPROTO_IPV6
option = getattr(socket, "IPV6_UNICAST_HOPS", 16)
else:
level, option = socket.IPPROTO_IP, socket.IP_TTL
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
default_ttl = sock.getsockopt(level, option)
sock.setsockopt(level, option, 1)
try:
writer.write(first)
await writer.drain()
await asyncio.sleep(0.01)
finally:
sock.setsockopt(level, option, default_ttl)
writer.write(rest)
await writer.drain()TCP_NODELAY is needed so that the kernel does not glue segments together using Nagle’s algorithm. A 10ms pause allows the first segment to elapse before the TTL returns to normal.
What's new in v2.3
The release with this fix was released yesterday, October 25th on GitHub. Now:
The disorder method is enabled by default. Deprecated methods
sniandrandomhave been removed along with the--fragment-methodparameter. (Although, strictly speaking, sni became the only fragmentation method)New flag
--no-disorderdisables disorder and leaves only SNI fragmentation.ClientHello is read as a whole along the length of the record. Previously, the ClientHello of modern browsers with post-quantum key exchange could not be read in its entirety, since it does not fit into one TCP segment.
Unfortunately, all this is an arms race: if TSPU learns to collect reordered flows (and this will happen sooner or later), we will have to look for the next method.
What's next
A year ago, I promised to add new features to the project. I confess I never had time to do this. But I promise to take the matter seriously in the near future) I will finally try to do:
Built-in resolution via DNS‑over‑HTTPS with fallback to system DNS. Saves you from DNS spoofing by your provider.
Blacklist for IP and subnets.
OOB (TCP urgent byte) method.
SOCKS5 proxy.
Assemblies for routers
And maybe something else...
I will also research, but I don’t promise:
Try to unblock Telegram (MTProto) and other social networks. networks
UDP/QUIC, calls (this is completely unlikely)
All new features and fixes will naturally be transferred to the Android port - NoDPI4Android. I might also work on the interface there.
Just a few words about project support
Many people ask me if I plan to collect donations, and how they can support the project financially. The answer is, I don’t plan to yet. For all articles with a rating of 30 and above, I receive royalties from Habr according to PPA and they are quite large (for 30 - 3K₽, for 50 - 5K₽ and a plus on top). This covers all the costs for the VPS and other things.
Conclusion
That's all, thanks for your attention! I hope it was interesting and at least somewhat useful. I will be glad to report errors, suggestions, criticism. The project, as always, is available here:
And here you can download the latest release.
Also, thanks to everyone who is participating in the discussions, especially on GitHub - your contributions are truly invaluable!
💬 Discussion 0
BBCode & Emoji supportedParticipate in discussions, ask authors questions, and share benchmarks by joining the ProArena engineering community.