diff --git a/README.md b/README.md index 2930973..7d40c08 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,31 @@ # ws-tcp-relay [![License MIT](https://img.shields.io/npm/l/express.svg)](http://opensource.org/licenses/MIT) -A relay between Websocket and TCP. All messages will be copied from all -Websocket connections to the target TCP server, and vice-versa. - -In other words, it's [websocketd](https://github.com/joewalnes/websocketd), but for TCP connections instead of `STDIN` and `STDOUT`. - -## Installation -```go get -u github.com/isobit/ws-tcp-relay``` +A relay between WebSocket clients and TCP servers. Data received from +WebSocket clients is simply forwarded to the specified TCP server, and +vice-versa. In other words, it's +[websocketd](https://github.com/joewalnes/websocketd), but for TCP connections +instead of `STDIN` and `STDOUT`. ## Usage ``` Usage: ws-tcp-relay - -p int - Port to listen on. (default 1337) - -port int - Port to listen on. (default 1337) + -p uint + The port to listen on (default 4223) + -port uint + The port to listen on (default 4223) -tlscert string - TLS cert file path + TLS cert file path -tlskey string - TLS key file path + TLS key file path ``` -## WSS Support -To use secure websockets simply specify both the `tlscert` and `tlskey` flags. +### WSS Support +To use secure WebSockets simply specify both the `tlscert` and `tlskey` flags. + +## Installation +``` +go get -u github.com/isobit/ws-tcp-relay +``` -## Building -`go build ws-tcp-relay.go` +Binaries are also available on the [release page](https://github.com/isobit/ws-tcp-relay/releases/). diff --git a/glide.lock b/glide.lock deleted file mode 100644 index b1be9ec..0000000 --- a/glide.lock +++ /dev/null @@ -1,8 +0,0 @@ -hash: 25e9dfe48d9c291f001e8b76ff2c387427cc1e170f3d6c1299982531965f1025 -updated: 2016-08-03T14:34:29.480169718-07:00 -imports: -- name: golang.org/x/net - version: 57bfaa875b96fb91b4766077f34470528d4b03e9 - subpackages: - - websocket -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 0e689f3..0000000 --- a/glide.yaml +++ /dev/null @@ -1,5 +0,0 @@ -package: . -import: -- package: golang.org/x/net - subpackages: - - websocket diff --git a/ws-tcp-relay.go b/ws-tcp-relay.go index f4a54cd..ec7e71c 100644 --- a/ws-tcp-relay.go +++ b/ws-tcp-relay.go @@ -1,13 +1,14 @@ package main import ( - "fmt" - "log" "flag" + "fmt" "io" - "os" + "log" "net" "net/http" + "os" + "golang.org/x/net/websocket" ) @@ -42,26 +43,26 @@ func usage() { } func main() { - var port int + var port uint var certFile string var keyFile string - flag.IntVar(&port, "p", 4223, "Port to listen on.") - flag.IntVar(&port, "port", 4223, "Port to listen on.") + flag.UintVar(&port, "p", 4223, "The port to listen on") + flag.UintVar(&port, "port", 4223, "The port to listen on") flag.StringVar(&certFile, "tlscert", "", "TLS cert file path") flag.StringVar(&keyFile, "tlskey", "", "TLS key file path") - flag.Usage = usage; - flag.Parse(); + flag.Usage = usage + flag.Parse() tcpAddress = flag.Arg(0) if tcpAddress == "" { - fmt.Fprintln(os.Stderr, "no address specified") + fmt.Fprintln(os.Stderr, "No address specified") os.Exit(1) } portString := fmt.Sprintf(":%d", port) - log.Printf("[INFO] starting server on port %d\n", port) + log.Printf("[INFO] Listening on %s\n", portString) http.Handle("/", websocket.Handler(relayHandler))