DNS And Websocket For Fun
A toy server that serve DNS and HTTP server (with websocket endpoint) to broadcast incoming text message and DNS request to the connected websocket clients.
- This server provides a DNS server on UDP port 53, each incoming DNS request will be broadcasted to all connected websocket clients. To demonstrate the server-to-client message.
- It also receives an incoming free text message from the WebSocket client and then the incoming message will also be broadcasted to all connected websocket clients. To demonstrate the client-to-server-to-client message.
This repo is a sample codes for sharing session, mainly to cover websocket and concurrent programming (using goroutine and channel)
Statically build then run it (tested locally using Go v1.19)
Source code is vendored, you can just clone this repo and then:
GOOS=linux GOARCH=amd64 go build -trimpath -a -tags "osusergo,netgo" -ldflags '-extldflags=-static -w -s -v' -o ./build/server-linux ./main.go
./build/server-linux
LICENSE
MIT