From 38ec9208d86aa2b3022454e4534f3c3a8371eda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E3=81=AE=E3=81=8B=E3=81=88=E3=81=A7?= Date: Fri, 1 Jan 2021 19:37:38 +0800 Subject: [PATCH] Change TOML package to github.com/pelletier/go-toml (#119) --- go.mod | 2 +- go.sum | 4 ++-- infra/conf/serial/loader.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e6792abd..1848092d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/xtls/xray-core go 1.15 require ( - github.com/BurntSushi/toml v0.3.1 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.4.3 @@ -11,6 +10,7 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/lucas-clemente/quic-go v0.19.3 github.com/miekg/dns v1.1.35 + github.com/pelletier/go-toml v1.8.1 github.com/pires/go-proxyproto v0.3.3 github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c github.com/stretchr/testify v1.6.1 diff --git a/go.sum b/go.sum index 832c282f..38a5b07f 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,6 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= @@ -124,6 +122,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= +github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pires/go-proxyproto v0.3.3 h1:jOXGrsAfSQVFiD1hWg1aiHpLYsd6SJw/8cLN594sB7Q= diff --git a/infra/conf/serial/loader.go b/infra/conf/serial/loader.go index 5774889e..baf6b54e 100644 --- a/infra/conf/serial/loader.go +++ b/infra/conf/serial/loader.go @@ -6,8 +6,8 @@ import ( "io" "io/ioutil" - "github.com/BurntSushi/toml" "github.com/ghodss/yaml" + "github.com/pelletier/go-toml" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" @@ -86,7 +86,7 @@ func LoadJSONConfig(reader io.Reader) (*core.Config, error) { } // DecodeTOMLConfig reads from reader and decode the config into *conf.Config -// using github.com/BurntSushi/toml and map to convert toml to json. +// using github.com/pelletier/go-toml and map to convert toml to json. func DecodeTOMLConfig(reader io.Reader) (*conf.Config, error) { tomlFile, err := ioutil.ReadAll(reader) if err != nil { @@ -94,7 +94,7 @@ func DecodeTOMLConfig(reader io.Reader) (*conf.Config, error) { } configMap := make(map[string]interface{}) - if _, err := toml.Decode(string(tomlFile), &configMap); err != nil { + if err := toml.Unmarshal(tomlFile, &configMap); err != nil { return nil, newError("failed to convert toml to map").Base(err) }