Skip to content

Commit

Permalink
Feat: add bytes support to v5 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AkinoKaede authored and xiaokangwang committed Jun 25, 2022
1 parent 28d197b commit 2e1d542
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions infra/conf/v5cfg/init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v5cfg

import (
"bytes"
"io"

core "github.com/v2fly/v2ray-core/v5"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2e1d542

Please sign in to comment.