Skip to content

Commit

Permalink
revert: support yaml config
Browse files Browse the repository at this point in the history
  • Loading branch information
kslr committed Oct 20, 2020
1 parent 2aedff1 commit 3c6e116
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 138 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.15

require (
github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.2
Expand All @@ -26,6 +25,3 @@ require (
google.golang.org/protobuf v1.25.0
h12.io/socks v1.0.1
)

// override gopkg.in/yaml.v2 version defined in github.com/ghodss/yaml
replace gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.3.0
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew=
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -309,6 +307,9 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
34 changes: 0 additions & 34 deletions infra/conf/serial/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"bytes"
"encoding/json"
"io"
"io/ioutil"

"github.com/ghodss/yaml"

"v2ray.com/core"
"v2ray.com/core/common/errors"
Expand Down Expand Up @@ -70,22 +67,6 @@ func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
return jsonConfig, nil
}

// DecodeYAMLConfig reads from reader and decode the config into *conf.Config
// syntax error could NOT be detected.
func DecodeYAMLConfig(reader io.Reader) (*conf.Config, error) {
yamlConfig := &conf.Config{}

// Since v2ray use json.RawMessage a lot, so we use a wrapper to convert yaml to json
if tmpBuf, err := ioutil.ReadAll(reader); err != nil {
return nil, newError("failed to read").Base(err)
} else if err := yaml.Unmarshal(tmpBuf, yamlConfig); err != nil {
return nil, newError("failed to parse config").Base(err)
}

return yamlConfig, nil
}

// LoadJSONConfig uses content in reader to return a core.Config
func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
jsonConfig, err := DecodeJSONConfig(reader)
if err != nil {
Expand All @@ -99,18 +80,3 @@ func LoadJSONConfig(reader io.Reader) (*core.Config, error) {

return pbConfig, nil
}

// LoadYAMLConfig uses content in reader to return a core.Config
func LoadYAMLConfig(reader io.Reader) (*core.Config, error) {
yamlConfig, err := DecodeYAMLConfig(reader)
if err != nil {
return nil, err
}

pbConfig, err := yamlConfig.Build()
if err != nil {
return nil, newError("failed to parse yaml config").Base(err)
}

return pbConfig, nil
}
6 changes: 0 additions & 6 deletions main/distro/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ import (
// The following line loads JSON internally
// _ "v2ray.com/core/main/jsonem"

// YAML config support. Choose only one from the two below.
// The following line loads YAML from v2ctl
_ "v2ray.com/core/main/yaml"
// The following line loads YAML internally
// _ "v2ray.com/core/main/yamlem"

// Load config from file or http(s)
_ "v2ray.com/core/main/confloader/external"
)
2 changes: 0 additions & 2 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ func GetConfigFormat() string {
switch strings.ToLower(*format) {
case "pb", "protobuf":
return "protobuf"
case "yml", "yaml":
return "yaml"
default:
return "json"
}
Expand Down
34 changes: 0 additions & 34 deletions main/yaml/config_yaml.go

This file was deleted.

9 changes: 0 additions & 9 deletions main/yaml/errors.generated.go

This file was deleted.

9 changes: 0 additions & 9 deletions main/yamlem/errors.generated.go

This file was deleted.

38 changes: 0 additions & 38 deletions main/yamlem/yamlem.go

This file was deleted.

0 comments on commit 3c6e116

Please sign in to comment.