From 90667aaef4ebfdce8f2699ef49aa5cba44daa53e Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sat, 13 Apr 2019 12:02:28 +0100
Subject: [PATCH] Remove a bunch of unused code, improve password generation

---
 api.go | 44 +++-----------------------------------------
 1 file changed, 3 insertions(+), 41 deletions(-)

diff --git a/api.go b/api.go
index d1b3789c..87a6bec3 100644
--- a/api.go
+++ b/api.go
@@ -2,10 +2,9 @@ package autoradio
 
 import (
 	"crypto/rand"
-	"encoding/base64"
+	"encoding/base32"
 	"fmt"
 	"hash/crc32"
-	"net"
 	"strings"
 )
 
@@ -59,50 +58,13 @@ func IcecastPathToMountPath(path string) string {
 	return strings.TrimPrefix(path, IcecastMountPrefix)
 }
 
-// MasterNodeInfo stores location data for the master node. Having the
-// IP address here saves another round-trip to etcd to retrieve the
-// node info in the most common case.
-type MasterNodeInfo struct {
-	// Name of the node.
-	Name string
-
-	// Public IPs of the node.
-	IP []net.IP
-
-	// Internal IPs of the node (possibly the same as IP).
-	InternalIP []net.IP
-}
-
-func (m MasterNodeInfo) GetInternalIP() []net.IP {
-	if len(m.InternalIP) != 0 {
-		return m.InternalIP
-	}
-	return m.IP
-}
-
-// // GetMasterInfo returns the address of the current master server.
-// func (r *Client) GetMasterInfo() (*MasterNodeInfo, error) {
-// 	response, err := r.EtcdClient.Get(MasterElectionPath, false, false)
-// 	if err != nil || response.Node == nil {
-// 		return nil, err
-// 	}
-// 	if response.Node.Dir {
-// 		return nil, errors.New("key is a directory")
-// 	}
-// 	var m MasterNodeInfo
-// 	if err := json.NewDecoder(strings.NewReader(response.Node.Value)).Decode(&m); err != nil {
-// 		return nil, err
-// 	}
-// 	return &m, nil
-// }
-
 // GeneratePassword returns a new random password.
 func GeneratePassword() string {
-	b := make([]byte, 6)
+	b := make([]byte, 20)
 	if _, err := rand.Read(b); err != nil {
 		panic(err)
 	}
-	return base64.StdEncoding.EncodeToString(b)
+	return strings.ToLower(base32.StdEncoding.EncodeToString(b))
 }
 
 // GenerateUsername returns a username somehow related to the name of
-- 
GitLab