Description
@rjeczalik I took your tip and did an experiment to replace yamux with HTTP/2. At first I wanted to make it a small change but it turned out that there were many incompatibilities so I decided to start fresh.
I did a POC that can proxy HTTP and TCP and uses ProxyFunc
design (no default functions yet). It turns out that the implementation can be really short and concise with http2
package. Server is ~300LOC and client ~100LOC (mostly consumed by structs and comments). The code is available at https://github.com/mmatczuk/h2tun.
Performance using HTTP/2 is slightly better than using yamux but I think the key benefit is improved stability, you can see a report that I wrote https://github.com/mmatczuk/h2tun/blob/master/benchmark/report/README.md.
This implementation follows a similar design that the current tunnel, I'd like to highlight some changes here
- There is no identifier sent by client, instead certificate pinning is used
ProxyFunc
takesio.Writer
andio.Reader
instead ofnet.Conn
ControlMessage
is changed, protocol is a string, it has extra fields, in general it follows some version of Forwarded HTTP Extension https://tools.ietf.org/html/rfc7239.
It's a POC, some things that exists in the tunnel should be migrated to make it truly usable. I also have some new ideas you can see in https://github.com/mmatczuk/h2tun/blob/master/TODO.md.
Please let me know what do you think.
I'd be really grateful for a review if find some time.
Cheers.
cc @cihangir