Internet of Things: Wifi Radio

How I redirected my Internet Radio to talk to my Raspberry Pi

Have you ever wondered what your Internet-connected devices are doing behind your back?

My internet radio had some problems with displaying special characters in the list of radio stations. When I checked the network traffic on Wireshark, I found that the protocol for connecting back was unencrypted, so I made it talk through a proxy which modifies the responses on the fly to fix up wrong character encoding in the server responses.

Basic setup:

Reverse proxies are simple to write in Go: use httputil.NewSingleHostReverseProxy and then set the ReverseProxy.ModifyResponse property on the returned object to an appropriate modification function such as:

func Modify(resp *http.Response) error {
        b, err := ioutil.ReadAll(resp.Body)
        if err != nil {
                return err
        b = ModifyBody(b)  // Actual replacements done here.
        resp.Body = ioutil.NopCloser(bytes.NewReader(b))
        resp.ContentLength = int64(len(b))
        resp.Header.Set("Content-Length", strconv.Itoa(len(b)))
        return nil

In my implementation, I’m replacing some wrongly encoded characters with correct ones in the server response, and for demo purposes and some silly entertainment, I’m changing the German word for Switzerland to “Swizzle”: