From 54b41610450018b1da0c7b91dfe608da8e7fa86c Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 14 Sep 2022 14:16:37 -0400 Subject: [PATCH] service name refactoring (#59) --- controller/tunnel.go | 2 +- controller/util.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/tunnel.go b/controller/tunnel.go index 6e5f179f..f1279dae 100644 --- a/controller/tunnel.go +++ b/controller/tunnel.go @@ -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())) diff --git a/controller/util.go b/controller/util.go index d149b677..a85e0124 100644 --- a/controller/util.go +++ b/controller/util.go @@ -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 }