Skip to content

Commit

Permalink
Use in case ending space differs
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton committed Jan 3, 2017
1 parent 6d50156 commit f884c45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions commands/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func ping(ccmd *cobra.Command, args []string) error {

client, err := clients.New(host, viper.GetString("token"))
if err != nil {
fmt.Printf("Failed to connect to '%v' - %v\n", host, err)
fmt.Printf("Failed to connect to '%s' - %s\n", host, err)
return err
}

err = client.Ping()
if err != nil {
fmt.Printf("Failed to ping - %v\n", err)
fmt.Printf("Failed to ping - %s\n", err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func Start(uris []string, token string) error {
// continue
server, ok := servers[url.Scheme]
if !ok {
lumber.Error("Unsupported scheme '%v'", url.Scheme)
lumber.Error("Unsupported scheme '%s'", url.Scheme)
continue
}

// attempt to start the server
lumber.Info("Starting '%v' server...", url.Scheme)
lumber.Info("Starting '%s' server...", url.Scheme)
go server(url.Host, errChan)
}

Expand Down
9 changes: 5 additions & 4 deletions server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"fmt"
"net/http"
"strings"

"github.com/gorilla/pat"
"github.com/gorilla/websocket"
Expand Down Expand Up @@ -106,7 +107,7 @@ func StartWS(uri string, errChan chan<- error) {
// never be able to.
if err := conn.ReadJSON(&msg); err != nil {
// todo: better logging here too
if err.Error() != "websocket: close 1001" && err.Error() != "websocket: close 1006 unexpected EOF" { // don't log if client disconnects
if !strings.Contains(err.Error(), "websocket: close 1001") && !strings.Contains(err.Error(), "websocket: close 1006 unexpected EOF") { // don't log if client disconnects
errChan <- fmt.Errorf("Failed to ReadJson message from WS connection - %s", err)
}

Expand Down Expand Up @@ -205,7 +206,7 @@ func StartWSS(uri string, errChan chan<- error) {
// if the next input matches the token then add auth commands
if xtoken != authtoken {
// break // allow connection w/o admin commands
errChan <- fmt.Errorf("Token given doesn't match configured token - %v", xtoken)
errChan <- fmt.Errorf("Token given doesn't match configured token - %s", xtoken)
return // disconnect client
}

Expand All @@ -230,7 +231,7 @@ func StartWSS(uri string, errChan chan<- error) {
// want mist just looping forever tyring to write to something it will
// never be able to.
if err := conn.ReadJSON(&msg); err != nil {
if err.Error() != "websocket: close 1001" && err.Error() != "websocket: close 1006 unexpected EOF" { // don't log if client disconnects
if !strings.Contains(err.Error(), "websocket: close 1001") && !strings.Contains(err.Error(), "websocket: close 1006 unexpected EOF") { // don't log if client disconnects
errChan <- fmt.Errorf("Failed to ReadJson message from WSS connection - %s", err)
}

Expand All @@ -252,7 +253,7 @@ func StartWSS(uri string, errChan chan<- error) {
// attempt to run the command
lumber.Trace("WSS Running '%v'...", msg.Command)
if err := handler(proxy, msg); err != nil {
lumber.Debug("WSS Failed to run '%v' - %v", msg.Command, err)
lumber.Debug("WSS Failed to run '%v' - %s", msg.Command, err)
if err := conn.WriteJSON(&mist.Message{Command: msg.Command, Error: err.Error()}); err != nil {
errChan <- fmt.Errorf("WSS Failed to respond to client with error - %s", err)
}
Expand Down

0 comments on commit f884c45

Please sign in to comment.