diff --git a/app/app.go b/app/app.go index 1d8bd07..853f561 100644 --- a/app/app.go +++ b/app/app.go @@ -96,6 +96,10 @@ func (app *application) LoadProfiles(password string) error { // TODO: Per profile eventBus profileStore, err := storage.NewProfileStore(app.eventBus, path.Join(app.directory, "profiles", file.Name()), password) + if err != nil { + continue + } + err = profileStore.Load() if err != nil { continue diff --git a/app/cli/main.go b/app/cli/main.go index 29294c9..1e1f28e 100644 --- a/app/cli/main.go +++ b/app/cli/main.go @@ -360,6 +360,11 @@ func main() { fmt.Print("Enter a password to decrypt the profile: ") bytePassword, err := terminal.ReadPassword(int(syscall.Stdin)) + if err != nil { + fmt.Printf("\nError loading profiles: %v\n", err) + continue + } + err = app.LoadProfiles(string(bytePassword)) if err == nil { app.LaunchPeers() diff --git a/app/peer/alice/alice.go b/app/peer/alice/alice.go index b4b1217..9d4998f 100644 --- a/app/peer/alice/alice.go +++ b/app/peer/alice/alice.go @@ -32,7 +32,7 @@ func main() { alice.Init(acn, eventBus) alice.Listen() - // For every new Data Packet Alice recieved she will Print it out. + // For every new Data Packet Alice received she will Print it out. for { event := queue.Next() log.Printf(log.LevelInfo, "Received %v from %v: %s", event.EventType, event.Data["Onion"], event.Data["Data"]) diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index 2267a9c..f3e8c23 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -99,7 +99,7 @@ func (cp *cwtchPeer) Init(acn connectivity.ACN, eventBus *event.Manager) { } } - // TODO: Would be nice if ProtocolEngine did not need to explictly be given the Private Key. + // TODO: Would be nice if ProtocolEngine did not need to explicitly be given the Private Key. cp.engine = connections.NewProtocolEngine(cp.Profile.Ed25519PrivateKey, acn, eventBus, blockedPeers) cp.engine.Identity = identity.InitializeV3(cp.Profile.Name, &cp.Profile.Ed25519PrivateKey, &cp.Profile.Ed25519PublicKey) } @@ -202,7 +202,7 @@ func (cp *cwtchPeer) JoinServer(onion string) { cp.eventBus.Publish(event.NewEvent(event.JoinServer, map[event.Field]string{event.GroupServer: onion})) } -// SendMessageToGroup attemps to sent the given message to the given group id. +// SendMessageToGroup attempts to sent the given message to the given group id. func (cp *cwtchPeer) SendMessageToGroup(groupid string, message string) error { group := cp.Profile.GetGroupByGroupID(groupid) if group == nil { diff --git a/protocol/connections/connectionsmanager.go b/protocol/connections/connectionsmanager.go index 0d31ed2..5c69473 100644 --- a/protocol/connections/connectionsmanager.go +++ b/protocol/connections/connectionsmanager.go @@ -135,7 +135,7 @@ func (m *Manager) ClosePeerConnection(onion string) { m.lock.Unlock() } -// Shutdown closes all connections under managment (freeing their goroutines) +// Shutdown closes all connections under management (freeing their goroutines) func (m *Manager) Shutdown() { m.breakChannel <- true m.lock.Lock() diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index d23aec5..d5a82d9 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -211,7 +211,7 @@ func (e *Engine) JoinServer(onion string) { e.connectionsManager.ManageServerConnection(onion, e.ReceiveGroupMessage) } -// SendMessageToGroup attemps to sent the given message to the given group id. +// SendMessageToGroup attempts to sent the given message to the given group id. func (e *Engine) SendMessageToGroup(server string, ct []byte, sig []byte) error { psc := e.connectionsManager.GetPeerServerConnectionForOnion(server) if psc == nil { diff --git a/protocol/connections/spam/spamguard.go b/protocol/connections/spam/spamguard.go index 6330a4f..4150665 100644 --- a/protocol/connections/spam/spamguard.go +++ b/protocol/connections/spam/spamguard.go @@ -51,7 +51,7 @@ func (sg *Guard) GenerateChallenge(channelID int32) []byte { func (sg *Guard) SolveChallenge(challenge []byte, message []byte) []byte { solved := false var spamguard [24]byte - sum := sha256.Sum256([]byte{}) + var sum [32]byte solve := make([]byte, len(challenge)+len(message)+len(spamguard)) for !solved { diff --git a/protocol/connections/state.go b/protocol/connections/state.go index c71fbad..79e1594 100644 --- a/protocol/connections/state.go +++ b/protocol/connections/state.go @@ -18,6 +18,6 @@ const ( ) var ( - // ConnectionStateName allows conversaion of states to their string representations + // ConnectionStateName allows conversion of states to their string representations ConnectionStateName = []string{"Disconnected", "Connecting", "Connected", "Authenticated", "Failed", "Killed"} ) diff --git a/testing/cwtch_peer_server_intergration_test.go b/testing/cwtch_peer_server_integration_test.go similarity index 99% rename from testing/cwtch_peer_server_intergration_test.go rename to testing/cwtch_peer_server_integration_test.go index d76358a..fd2f48d 100644 --- a/testing/cwtch_peer_server_intergration_test.go +++ b/testing/cwtch_peer_server_integration_test.go @@ -105,7 +105,7 @@ func TestCwtchPeerIntegration(t *testing.T) { t.Fatalf("Could not start Tor: %v", err) } - // ***** Cwtch Server managment ***** + // ***** Cwtch Server management ***** var server *cwtchserver.Server serverOnline := false diff --git a/testing/quality.sh b/testing/quality.sh index 6a4431d..0d2741c 100755 --- a/testing/quality.sh +++ b/testing/quality.sh @@ -14,3 +14,11 @@ go list ./... | xargs golint echo "Time to format" gofmt -l -s -w . + +# ineffassign (https://github.com/gordonklaus/ineffassign) +echo "Checking for ineffectual assignment of errors (unchecked errors...)" +ineffassign . + +# misspell (https://github.com/client9/misspell) +echo "Checking for misspelled words..." +misspell . | grep -v "vendor/" | grep -v "go.sum" | grep -v ".idea"