Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to enable compression #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ type session struct {
errChan chan error
}

func connect(url, origin string, rlConf *readline.Config, allowInsecure bool) error {
func connect(url, origin string, rlConf *readline.Config, allowInsecure, enableCompression bool) error {
headers := make(http.Header)
headers.Add("Origin", origin)

dialer := websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig:&tls.Config{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: allowInsecure,
},
EnableCompression: enableCompression,
}
ws, _, err := dialer.Dial(url, headers)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const Version = "0.2.1"
var options struct {
origin string
printVersion bool
insecure bool
insecure bool
compression bool
}

func main() {
Expand All @@ -29,6 +30,7 @@ func main() {
rootCmd.Flags().StringVarP(&options.origin, "origin", "o", "", "websocket origin")
rootCmd.Flags().BoolVarP(&options.printVersion, "version", "v", false, "print version")
rootCmd.Flags().BoolVarP(&options.insecure, "insecure", "k", false, "skip ssl certificate check")
rootCmd.Flags().BoolVarP(&options.compression, "compression", "c", false, "enable compression")

rootCmd.Execute()
}
Expand Down Expand Up @@ -72,7 +74,7 @@ func root(cmd *cobra.Command, args []string) {
err = connect(dest.String(), origin, &readline.Config{
Prompt: "> ",
HistoryFile: historyFile,
}, options.insecure)
}, options.insecure, options.compression)
if err != nil {
fmt.Fprintln(os.Stderr, err)
if err != io.EOF && err != readline.ErrInterrupt {
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/gorilla/websocket/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions vendor/github.com/gorilla/websocket/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/gorilla/websocket/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions vendor/github.com/gorilla/websocket/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading