Tweet-sized TCP proxy in go

I found this tweet nice for inspiration and also to know what the "competition" looks like.

package main

import (
    "io"
    "net"
)

func main() {
    s, _ := net.Listen("tcp", ":8080")
    for {
        l, _ := s.Accept()
        r, _ := net.Dial("tcp", "localhost:8081")
        go io.Copy(l, r)
        go io.Copy(r, l)
    }
}

https://twitter.com/heptajohn/status/957748274529734658

3 Likes