just a runnable instance of lrcd

add readme and make non ws output prettier

+45 -1
+15
README.md
··· 1 + just a simple implementation of lrcd! 2 + 3 + lrc.example.com.conf is an example nginx config file, probably if you wanna 4 + self-host this you know what you're doing better than me, but for me, i wanted 5 + to serve lrcdaemon with nginx, so my setup was just to copy the config file 6 + into conf.d, rename the server_name directive to be correct for my base 7 + domain, and then run `sudo certbot --nginx` 8 + 9 + then you'd connect to the server through e.g. tty!xcvr by doing `:dial 10 + lrc.example.com` 11 + 12 + it should be running right now at `lrc.moth11.net`, check it out with your 13 + lrc client! 14 + 15 + of course to run the server, `go run .`
+16
lrc.example.com.conf
··· 1 + server { 2 + listen 80; 3 + server_name lrc.example.com; 4 + 5 + location / { 6 + proxy_pass http://127.0.0.1:8080; 7 + proxy_http_version 1.1; 8 + proxy_set_header Upgrade $http_upgrade; 9 + proxy_set_header Connection 'upgrade'; 10 + proxy_set_header Host $host; 11 + proxy_set_header X-Real-IP $remote_addr; 12 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 13 + proxy_set_header X-Forwarded-Proto $scheme; 14 + proxy_cache_bypass $http_upgrade; 15 + } 16 + }
+14 -1
main.go
··· 17 17 panic(err) 18 18 } 19 19 fmt.Println("serving lrcd on localhost:8080") 20 - http.ListenAndServe(":8080", server.WSHandler()) 20 + http.ListenAndServe(":8080", guessIfUpgradeFail(server)) 21 + } 22 + 23 + func guessIfUpgradeFail(server *lrcd.Server) http.HandlerFunc { 24 + return func(w http.ResponseWriter, r *http.Request) { 25 + if r.Header.Get("Connection") != "upgrade" { 26 + fmt.Fprintf(w, `hi! i am an lrc server 27 + i think you should try connecting to me with an lrc client (e.g. tty!xcvr) 28 + it'll be more fun for us both. 29 + currently connected: %d`, server.Connected()) 30 + } else { 31 + server.WSHandler()(w, r) 32 + } 33 + } 21 34 }