Proxying Youtube Videos Part I

This series of posts details how to proxy YouTube videos. Unlike using tools to download YouTube videos, we’re proxying them so there is no need for a large storage system. This can be used to avoid ads and tracking and for other media streaming purpose. First we’ll learn how to extract YouTube video urls and write a simple dynamic reverse proxy. Extracting YouTube Video Urls If we want to proxy YouTube assets, first we’ll need to know the urls of the video assets....

published on July 3, 2023 · 3 min · 630 words

Porting ttyd to Golang Part II

Continuing from previous post, this post is about how to handle ttyd using golang. Overview The golang handler consists of 3 parts: sending frontend, sending auth token and handling websocket connection. Sending Frontend Golang can embed static assets in the compiled binary so there is no need to specify a path to the file. The frontend can be extracted using devtools. //go:embed ttyd.html var ttydHtml string func index(writer http.ResponseWriter, request *http....

published on June 7, 2023 · 6 min · 1229 words

Implementing A Multi-User Webdav Server

Golang comes with a webdav server implementation. It only supports webdav operations and nothing more. To manager a group of users, we need to implement our own handling logic. hacdias’s webdav server associates each user with his/her own webdav.Handler, and each authenticated request goes to their respective handler. rclone can generate dynamic webdav backends using auth proxy. By implementing auth proxy, rclone can serve different contents based on users. However, both of them suffer from lock states not shared, meaning when multiple users share the same directory, some changes may be lost if they try to modify its resources concurrently....

published on May 29, 2023 · 3 min · 621 words

Http3 Demo

This post first demonstrates http1, http2, http3 like akamai, then shows how the demo works. Demonstrations info Firefox has a bug/feature that it will cache images even though instructed not to. Use another browser or hard refresh to rerun the tests. HTTP1 Click to test http1 HTTP2 Click to test http2 HTTP3 info If the image is gray, http3 is not used. There are several reasons why this may happen:...

published on May 17, 2023 · last edited on August 10, 2023 · 3 min · 443 words

Porting ttyd to Golang Part I

Previously I have written a post about ttyd that describes how to authenticate requests for ttyd sessions. The problem is that vanilla ttyd only supports running a predefined command, and it’s nearly impossible to customize what command to run based on the authenticated user. To solve this problem we need to port ttyd to another language. But first we need to understand how ttyd works. Request Waterfall When a browser connects to a ttyd instance, below is the order in which resources are requested....

published on April 27, 2023 · 5 min · 919 words