Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
autoradio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ale
autoradio
Commits
90667aae
Commit
90667aae
authored
Apr 13, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a bunch of unused code, improve password generation
parent
b219179c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
41 deletions
+3
-41
api.go
api.go
+3
-41
No files found.
api.go
View file @
90667aae
...
...
@@ -2,10 +2,9 @@ package autoradio
import
(
"crypto/rand"
"encoding/base
64
"
"encoding/base
32
"
"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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment