forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package m3u8
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
cacheEnkey []byte
|
||||
cacheTvEnkey []byte
|
||||
initOnce sync.Once
|
||||
)
|
||||
|
||||
// 安全初始化 m3u8 key
|
||||
func init() {
|
||||
initOnce.Do(func() {
|
||||
if len(cacheEnkey) == 0 {
|
||||
data, err := ioutil.ReadFile("conf/m3u8.key")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cacheEnkey = data
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Enkey 密匙key
|
||||
func Enkey(ctx context.Context) (buffer *bytes.Buffer, err error) {
|
||||
buffer = bytes.NewBuffer(cacheEnkey)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user