Commit 90667aae authored by ale's avatar ale

Remove a bunch of unused code, improve password generation

parent b219179c
...@@ -2,10 +2,9 @@ package autoradio ...@@ -2,10 +2,9 @@ package autoradio
import ( import (
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base32"
"fmt" "fmt"
"hash/crc32" "hash/crc32"
"net"
"strings" "strings"
) )
...@@ -59,50 +58,13 @@ func IcecastPathToMountPath(path string) string { ...@@ -59,50 +58,13 @@ func IcecastPathToMountPath(path string) string {
return strings.TrimPrefix(path, IcecastMountPrefix) 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. // GeneratePassword returns a new random password.
func GeneratePassword() string { func GeneratePassword() string {
b := make([]byte, 6) b := make([]byte, 20)
if _, err := rand.Read(b); err != nil { if _, err := rand.Read(b); err != nil {
panic(err) panic(err)
} }
return base64.StdEncoding.EncodeToString(b) return strings.ToLower(base32.StdEncoding.EncodeToString(b))
} }
// GenerateUsername returns a username somehow related to the name of // GenerateUsername returns a username somehow related to the name of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment