Skip to content
Snippets Groups Projects
Commit 90667aae authored by ale's avatar ale
Browse files

Remove a bunch of unused code, improve password generation

parent b219179c
No related branches found
No related tags found
1 merge request!1v2.0
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment