MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / loadKeys

Method loadKeys

pkg/cluster/cluster.go:206–224  ·  view source on GitHub ↗
(ctx context.Context, keys ...string)

Source from the content-addressed store, hash-verified

204)
205
206func (c *cluster) loadKeys(ctx context.Context, keys ...string) error {
207 for _, key := range keys {
208 decodedKey, err := hex.DecodeString(key)
209 if err != nil {
210 return errInvalidClusterKey.WithCause(err)
211 }
212 switch len(decodedKey) {
213 case 16, 24, 32:
214 default:
215 return errInvalidClusterKey.WithCause(errInvalidKeyLength)
216 }
217 c.keys = append(c.keys, decodedKey)
218 }
219 if c.keys == nil {
220 c.keys = [][]byte{random.Bytes(32)}
221 log.FromContext(ctx).WithField("key", hex.EncodeToString(c.keys[0])).Warn("No cluster key configured, generated a random one")
222 }
223 return nil
224}
225
226func (c *cluster) getTLSServerName(target string) string {
227 tlsServerName := c.tlsServerName

Callers 1

defaultNewFunction · 0.95

Calls 5

BytesFunction · 0.92
FromContextFunction · 0.92
WarnMethod · 0.65
WithFieldMethod · 0.65
WithCauseMethod · 0.45

Tested by

no test coverage detected