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) logrus.Error(err)
return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error())) return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
} }
svcName, err := randomId() svcName, err := createServiceName()
if err != nil { if err != nil {
logrus.Error(err) logrus.Error(err)
return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error())) return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))

View File

@ -46,10 +46,10 @@ func createToken() string {
return shortuuid.New() return shortuuid.New()
} }
func randomId() (string, error) { func createServiceName() (string, error) {
bytes := make([]byte, 8) bytes := make([]byte, 4)
if _, err := rand.Read(bytes); err != nil { 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 return hex.EncodeToString(bytes), nil
} }