https://github.com/simukti/dnswsforfun
A demo server that acts as a DNS proxy and HTTP server (including WebSocket server).
https://github.com/simukti/dnswsforfun
channel concurrent-programming go golang goroutines websocket
Last synced: 29 days ago
JSON representation
A demo server that acts as a DNS proxy and HTTP server (including WebSocket server).
- Host: GitHub
- URL: https://github.com/simukti/dnswsforfun
- Owner: simukti
- License: mit
- Created: 2022-09-01T05:45:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-26T09:36:56.000Z (about 1 year ago)
- Last Synced: 2025-02-09T23:49:07.504Z (3 months ago)
- Topics: channel, concurrent-programming, go, golang, goroutines, websocket
- Language: Go
- Homepage:
- Size: 2.44 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DNS And Websocket For Fun
A toy server that acts as a DNS proxy and HTTP server (including WebSocket server).
## Overview
![]()
- DNS request log will be broadcasted to all connected WebSocket clients. To demonstrate server-initiated events.
- It also receives an incoming free text message from the WebSocket client and the WebSocket hub will broadcast those
messages to all connected WebSocket clients. To demonstrate client-initiated events.
- The internal mechanism for passing data between goroutine is using go-channel.
- Implements [`share memory by communicating`](http://go-proverbs.github.io/).**_NOTE: this repository is a sample for the Golang sharing session showcase, mainly to cover WebSocket and concurrent
programming (using goroutine and channel)._**## Build And Execute
### Requirement
- Go >= v1.16
### Build
All dependencies are included in `vendor` folder (`go mod tidy && go mod vendor`), so you can just clone this repo and
then:- `go build -trimpath -a -mod=vendor -tags "osusergo,netgo" -ldflags '-w -s -v' -o ./build/server ./main.go`
### Execute
- `./build/server`
For available arguments, use `./build/server -h`.
## Demo
- Open `http://127.0.0.1:8080` to see the web page, it will open new WebSocket session from the web browser.
- Point your DNS resolver to `127.0.0.1` port `53` Or simple test using `dig` command, for example: `dig MX simukti.net @127.0.0.1`.To simulate another WebSocket client connected, you can use one of these tools to connect to the WebSocket server at `ws://127.0.0.1:8080/ws`:
- [WebSocket King Client (Chrome extension)](https://chrome.google.com/webstore/detail/websocket-king-client/cbcbkhdmedgianpaifchdaddpnmgnknn?hl=en)
- [Weasel (Firefox extension)](https://addons.mozilla.org/en-US/firefox/addon/websocket-weasel/)
- [Websocat CLI](https://github.com/vi/websocat)## LICENSE
MIT