Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Usage of ./wsd:
origin of WebSocket client (default "http://localhost/")
-protocol string
WebSocket subprotocol
-userAgent string
"User-Agent" header
-url string
WebSocket server address to connect to (default "ws://localhost:1337/ws")
-version
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
origin string
url string
protocol string
userAgent string
displayHelp bool
displayVersion bool
insecureSkipVerify bool
Expand All @@ -35,6 +36,7 @@ func init() {
flag.StringVar(&origin, "origin", "http://localhost/", "origin of WebSocket client")
flag.StringVar(&url, "url", "ws://localhost:1337/ws", "WebSocket server address to connect to")
flag.StringVar(&protocol, "protocol", "", "WebSocket subprotocol")
flag.StringVar(&userAgent, "userAgent", "", "User-Agent header")
flag.BoolVar(&insecureSkipVerify, "insecureSkipVerify", false, "Skip TLS certificate verification")
flag.BoolVar(&displayHelp, "help", false, "Display help information about wsd")
flag.BoolVar(&displayVersion, "version", false, "Display version number")
Expand Down Expand Up @@ -92,6 +94,9 @@ func dial(url, protocol, origin string) (ws *websocket.Conn, err error) {
if protocol != "" {
config.Protocol = []string{protocol}
}
if userAgent != "" {
config.Header.Add("User-Agent", userAgent)
}
config.TlsConfig = &tls.Config{
InsecureSkipVerify: insecureSkipVerify,
}
Expand Down