来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83 项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet 测试目录 /server/hkdj_net,App/Web API 30331/30332 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
32 lines
667 B
Go
32 lines
667 B
Go
package m3u8
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func configuredKey(path string) (*bytes.Buffer, error) {
|
|
key, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("read media key %s: %w", path, err)
|
|
}
|
|
if len(key) != 16 {
|
|
return nil, fmt.Errorf("media key must contain 16 bytes: %s", path)
|
|
}
|
|
return bytes.NewBuffer(key), nil
|
|
}
|
|
|
|
func Enkey(ctx context.Context) (*bytes.Buffer, error) {
|
|
return configuredKey("conf/m3u8.key")
|
|
}
|
|
|
|
func NewEnkey(ctx context.Context) (*bytes.Buffer, error) {
|
|
return configuredKey("conf/newm3u8.key")
|
|
}
|
|
|
|
func LsjEnkey(ctx context.Context) (*bytes.Buffer, error) {
|
|
return configuredKey("conf/lsjm3u8.key")
|
|
}
|