(ctx context.Context, keys ...string)
| 204 | ) |
| 205 | |
| 206 | func (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 | |
| 226 | func (c *cluster) getTLSServerName(target string) string { |
| 227 | tlsServerName := c.tlsServerName |
no test coverage detected