Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
90667aae
Commit
90667aae
authored
5 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Remove a bunch of unused code, improve password generation
parent
b219179c
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
v2.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api.go
+3
-41
3 additions, 41 deletions
api.go
with
3 additions
and
41 deletions
api.go
+
3
−
41
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
base
64
.
StdEncoding
.
EncodeToString
(
b
)
return
strings
.
ToLower
(
base
32
.
StdEncoding
.
EncodeToString
(
b
)
)
}
// GenerateUsername returns a username somehow related to the name of
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment