service name refactoring (#59)

This commit is contained in:
Michael Quigley 2022-09-14 14:16:37 -04:00
parent 366f7db982
commit 54b4161045
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 4 additions and 4 deletions

View File

@ -61,7 +61,7 @@ func (self *tunnelHandler) Handle(params tunnel.TunnelParams, principal *rest_mo
logrus.Error(err)
return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
}
svcName, err := randomId()
svcName, err := createServiceName()
if err != nil {
logrus.Error(err)
return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))

View File

@ -46,10 +46,10 @@ func createToken() string {
return shortuuid.New()
}
func randomId() (string, error) {
bytes := make([]byte, 8)
func createServiceName() (string, error) {
bytes := make([]byte, 4)
if _, err := rand.Read(bytes); err != nil {
return "", errors.Wrap(err, "error generating random identity id")
return "", errors.Wrap(err, "error generating service name")
}
return hex.EncodeToString(bytes), nil
}