Просмотр исходного кода

refactor(config): don't check random.Read's return value

As stated in the documentation:

> Read calls io.ReadFull on Reader and crashes the program irrecoverably if an
error is returned. The default Reader uses operating system APIs that are
documented to never return an error on all but legacy Linux systems.
Julien Voisin 10 месяцев назад
Родитель
Сommit
078eb39db9
1 измененных файлов с 1 добавлено и 3 удалено
  1. 1 3
      internal/config/parser.go

+ 1 - 3
internal/config/parser.go

@@ -165,9 +165,7 @@ func (p *parser) parseLines(lines []string) (err error) {
 			p.opts.mediaProxyResourceTypes = parseStringList(value, []string{defaultMediaResourceTypes})
 			p.opts.mediaProxyResourceTypes = parseStringList(value, []string{defaultMediaResourceTypes})
 		case "MEDIA_PROXY_PRIVATE_KEY":
 		case "MEDIA_PROXY_PRIVATE_KEY":
 			randomKey := make([]byte, 16)
 			randomKey := make([]byte, 16)
-			if _, err := rand.Read(randomKey); err != nil {
-				return fmt.Errorf("config: unable to generate random key: %w", err)
-			}
+			rand.Read(randomKey)
 			p.opts.mediaProxyPrivateKey = parseBytes(value, randomKey)
 			p.opts.mediaProxyPrivateKey = parseBytes(value, randomKey)
 		case "MEDIA_PROXY_CUSTOM_URL":
 		case "MEDIA_PROXY_CUSTOM_URL":
 			p.opts.mediaProxyCustomURL = parseString(value, defaultMediaProxyURL)
 			p.opts.mediaProxyCustomURL = parseString(value, defaultMediaProxyURL)