mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 13:16:07 +03:00
fix: set json to default format to stdin (#446)
This commit is contained in:
parent
b2d8168284
commit
6c936e2fd3
@ -80,21 +80,23 @@ func getFormat(filename string) string {
|
|||||||
func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
||||||
switch v := input.(type) {
|
switch v := input.(type) {
|
||||||
case cmdarg.Arg:
|
case cmdarg.Arg:
|
||||||
|
|
||||||
formats := make([]string, len(v))
|
formats := make([]string, len(v))
|
||||||
hasProtobuf := false
|
hasProtobuf := false
|
||||||
for i, file := range v {
|
for i, file := range v {
|
||||||
var f string
|
var f string
|
||||||
|
|
||||||
if formatName == "auto" {
|
if formatName == "auto" {
|
||||||
f = getFormat(file)
|
if file != "stdin:" {
|
||||||
if f == "" {
|
f = getFormat(file)
|
||||||
return nil, newError("Unable to get format of", formatName).AtWarning()
|
} else {
|
||||||
|
f = "json"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
f = formatName
|
||||||
}
|
}
|
||||||
|
|
||||||
if f == "" {
|
if f == "" {
|
||||||
f = formatName
|
return nil, newError("Failed to get format of ", file).AtWarning()
|
||||||
}
|
}
|
||||||
|
|
||||||
if f == "protobuf" {
|
if f == "protobuf" {
|
||||||
|
Loading…
Reference in New Issue
Block a user