Skip to content

Commit 715f37f

Browse files
committed
Clean up and prep for dev release
1 parent 5363a1c commit 715f37f

File tree

4 files changed

+30
-40
lines changed

4 files changed

+30
-40
lines changed

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
# ws-tcp-relay
22
[![License MIT](https://img.shields.io/npm/l/express.svg)](http://opensource.org/licenses/MIT)
33

4-
A relay between Websocket and TCP. All messages will be copied from all
5-
Websocket connections to the target TCP server, and vice-versa.
6-
7-
In other words, it's [websocketd](https://github.com/joewalnes/websocketd), but for TCP connections instead of `STDIN` and `STDOUT`.
8-
9-
## Installation
10-
```go get -u github.com/isobit/ws-tcp-relay```
4+
A relay between WebSocket clients and TCP servers. Data received from
5+
WebSocket clients is simply forwarded to the specified TCP server, and
6+
vice-versa. In other words, it's
7+
[websocketd](https://github.com/joewalnes/websocketd), but for TCP connections
8+
instead of `STDIN` and `STDOUT`.
119

1210
## Usage
1311
```
1412
Usage: ws-tcp-relay <tcpTargetAddress>
15-
-p int
16-
Port to listen on. (default 1337)
17-
-port int
18-
Port to listen on. (default 1337)
13+
-p uint
14+
The port to listen on (default 4223)
15+
-port uint
16+
The port to listen on (default 4223)
1917
-tlscert string
20-
TLS cert file path
18+
TLS cert file path
2119
-tlskey string
22-
TLS key file path
20+
TLS key file path
2321
```
2422

25-
## WSS Support
26-
To use secure websockets simply specify both the `tlscert` and `tlskey` flags.
23+
### WSS Support
24+
To use secure WebSockets simply specify both the `tlscert` and `tlskey` flags.
25+
26+
## Installation
27+
```
28+
go get -u github.com/isobit/ws-tcp-relay
29+
```
2730

28-
## Building
29-
`go build ws-tcp-relay.go`
31+
Binaries are also available on the [release page](https://github.com/isobit/ws-tcp-relay/releases/).

glide.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

glide.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

ws-tcp-relay.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package main
22

33
import (
4-
"fmt"
5-
"log"
64
"flag"
5+
"fmt"
76
"io"
8-
"os"
7+
"log"
98
"net"
109
"net/http"
10+
"os"
11+
1112
"golang.org/x/net/websocket"
1213
)
1314

@@ -42,26 +43,26 @@ func usage() {
4243
}
4344

4445
func main() {
45-
var port int
46+
var port uint
4647
var certFile string
4748
var keyFile string
4849

49-
flag.IntVar(&port, "p", 4223, "Port to listen on.")
50-
flag.IntVar(&port, "port", 4223, "Port to listen on.")
50+
flag.UintVar(&port, "p", 4223, "The port to listen on")
51+
flag.UintVar(&port, "port", 4223, "The port to listen on")
5152
flag.StringVar(&certFile, "tlscert", "", "TLS cert file path")
5253
flag.StringVar(&keyFile, "tlskey", "", "TLS key file path")
53-
flag.Usage = usage;
54-
flag.Parse();
54+
flag.Usage = usage
55+
flag.Parse()
5556

5657
tcpAddress = flag.Arg(0)
5758
if tcpAddress == "" {
58-
fmt.Fprintln(os.Stderr, "no address specified")
59+
fmt.Fprintln(os.Stderr, "No address specified")
5960
os.Exit(1)
6061
}
6162

6263
portString := fmt.Sprintf(":%d", port)
6364

64-
log.Printf("[INFO] starting server on port %d\n", port)
65+
log.Printf("[INFO] Listening on %s\n", portString)
6566

6667
http.Handle("/", websocket.Handler(relayHandler))
6768

0 commit comments

Comments
 (0)