commit e39896f6b0f2298df068319b0941ca2c48912af8
parent c787512bf95b13fd861fa7d881d2e10dbfb408d0
Author: parazyd <parazyd@dyne.org>
Date: Tue, 13 Mar 2018 13:32:38 +0100
Add cleanups to binaries.
Diffstat:
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go
@@ -87,7 +87,7 @@ func announce(dir string, vals map[string]string, privkey *rsa.PrivateKey) (bool
return false, err
}
- decrypted, err := lib.DecryptMsgRsa([]byte(decodedSecret), privkey)
+ decrypted, err := lib.DecryptMsgRsa(decodedSecret, privkey)
if err != nil {
return false, err
}
diff --git a/cmd/dam-dir/main.go b/cmd/dam-dir/main.go
@@ -209,9 +209,7 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
// handleElse is a noop for anything that isn't /announce. We don't care about
// other requests (yet).
-func handleElse(rw http.ResponseWriter, request *http.Request) {
- return
-}
+func handleElse(rw http.ResponseWriter, request *http.Request) {}
func main() {
var wg sync.WaitGroup
diff --git a/cmd/dam-dir/main_test.go b/cmd/dam-dir/main_test.go
@@ -63,11 +63,7 @@ func getRespText(resp *http.Response) (msgStruct, error) {
decoder := json.NewDecoder(resp.Body)
err := decoder.Decode(&m)
- if err != nil {
- return m, err
- }
-
- return m, nil
+ return m, err
}
func firstAnnValid() (*http.Response, error) {
@@ -141,7 +137,7 @@ func TestValidSecondHandshake(t *testing.T) {
t.Fatal(err)
}
decryptedEncode := base64.StdEncoding.EncodeToString(decrypted)
- sig, err := lib.SignMsgRsa([]byte(decryptedEncode), privkey)
+ sig, _ := lib.SignMsgRsa([]byte(decryptedEncode), privkey)
encodedSig := base64.StdEncoding.EncodeToString(sig)
vals := ValidFirst
@@ -157,11 +153,10 @@ func TestValidSecondHandshake(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if m.Secret == lib.WelcomeMsg {
- t.Log("Server replied:", m.Secret)
- } else {
+ if m.Secret != lib.WelcomeMsg {
t.Fatal(m.Secret)
}
+ t.Log("Server replied:", m.Secret)
}
func TestInvalidNodetypeFirst(t *testing.T) {