1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

Feat: add bytes support to v5 configuration

This commit is contained in:
秋のかえで 2022-05-10 12:22:23 +08:00 committed by Xiaokang Wang (Shelikhoo)
parent 28d197b6f3
commit 2e1d542a5c

View File

@ -1,6 +1,7 @@
package v5cfg
import (
"bytes"
"io"
core "github.com/v2fly/v2ray-core/v5"
@ -30,6 +31,15 @@ func init() {
return nil, err
}
return loadJSONConfig(data)
case []byte:
r := &json.Reader{
Reader: bytes.NewReader(v),
}
data, err := buf.ReadAllToBytes(r)
if err != nil {
return nil, err
}
return loadJSONConfig(data)
case io.Reader:
data, err := buf.ReadAllToBytes(&json.Reader{
Reader: v,