v2ray пре 9 година
родитељ
комит
09f7e8b61e

+ 3 - 2
proxy/blackhole/config_json.go

@@ -4,6 +4,7 @@ package blackhole
 
 import (
 	"encoding/json"
+	"errors"
 
 	"github.com/v2ray/v2ray-core/common/loader"
 	"github.com/v2ray/v2ray-core/proxy/internal"
@@ -15,7 +16,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JSONConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Blackhole: Failed to parse config: " + err.Error())
 	}
 
 	this.Response = new(NoneResponse)
@@ -25,7 +26,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 		loader.RegisterCreator("http", func() interface{} { return new(HTTPResponse) })
 		response, err := loader.Load(jsonConfig.Response)
 		if err != nil {
-			return err
+			return errors.New("Blackhole: Failed to parse response config: " + err.Error())
 		}
 		this.Response = response.(Response)
 	}

+ 2 - 1
proxy/dokodemo/config_json.go

@@ -4,6 +4,7 @@ package dokodemo
 
 import (
 	"encoding/json"
+	"errors"
 
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	"github.com/v2ray/v2ray-core/proxy/internal"
@@ -18,7 +19,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	rawConfig := new(DokodemoConfig)
 	if err := json.Unmarshal(data, rawConfig); err != nil {
-		return err
+		return errors.New("Dokodemo: Failed to parse config: " + err.Error())
 	}
 	this.Address = rawConfig.Host.Address
 	this.Port = rawConfig.PortValue

+ 2 - 1
proxy/freedom/config_json.go

@@ -4,6 +4,7 @@ package freedom
 
 import (
 	"encoding/json"
+	"errors"
 	"strings"
 
 	"github.com/v2ray/v2ray-core/proxy/internal"
@@ -16,7 +17,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Freedom: Failed to parse config: " + err.Error())
 	}
 	this.DomainStrategy = DomainStrategyAsIs
 	domainStrategy := strings.ToLower(jsonConfig.DomainStrategy)

+ 4 - 3
proxy/http/config_json.go

@@ -5,6 +5,7 @@ package http
 import (
 	"crypto/tls"
 	"encoding/json"
+	"errors"
 
 	"github.com/v2ray/v2ray-core/proxy/internal"
 )
@@ -18,7 +19,7 @@ func (this *CertificateConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("HTTP: Failed to parse certificate config: " + err.Error())
 	}
 
 	cert, err := tls.LoadX509KeyPair(jsonConfig.CertFile, jsonConfig.KeyFile)
@@ -38,7 +39,7 @@ func (this *TLSConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("HTTP: Failed to parse TLS config: " + err.Error())
 	}
 
 	this.Enabled = jsonConfig.Enabled
@@ -53,7 +54,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("HTTP: Failed to parse config: " + err.Error())
 	}
 
 	this.TLSConfig = jsonConfig.Tls

+ 2 - 1
proxy/shadowsocks/config_json.go

@@ -4,6 +4,7 @@ package shadowsocks
 
 import (
 	"encoding/json"
+	"errors"
 	"strings"
 
 	"github.com/v2ray/v2ray-core/common/log"
@@ -21,7 +22,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Shadowsocks: Failed to parse config: " + err.Error())
 	}
 
 	this.UDP = jsonConfig.UDP

+ 2 - 1
proxy/socks/config_json.go

@@ -4,6 +4,7 @@ package socks
 
 import (
 	"encoding/json"
+	"errors"
 
 	"github.com/v2ray/v2ray-core/common/log"
 	v2net "github.com/v2ray/v2ray-core/common/net"
@@ -30,7 +31,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 
 	rawConfig := new(SocksConfig)
 	if err := json.Unmarshal(data, rawConfig); err != nil {
-		return err
+		return errors.New("Socks: Failed to parse config: " + err.Error())
 	}
 	if rawConfig.AuthMethod == AuthMethodNoAuth {
 		this.AuthType = AuthTypeNoAuth

+ 5 - 4
proxy/vmess/inbound/config_json.go

@@ -4,6 +4,7 @@ package inbound
 
 import (
 	"encoding/json"
+	"errors"
 
 	"github.com/v2ray/v2ray-core/common/protocol"
 	"github.com/v2ray/v2ray-core/proxy/internal"
@@ -15,7 +16,7 @@ func (this *DetourConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonDetourConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("VMessIn: Failed to parse detour config: " + err.Error())
 	}
 	this.ToTag = jsonConfig.ToTag
 	return nil
@@ -27,7 +28,7 @@ func (this *FeaturesConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonFeaturesConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("VMessIn: Failed to parse features config: " + err.Error())
 	}
 	this.Detour = jsonConfig.Detour
 	return nil
@@ -40,7 +41,7 @@ func (this *DefaultConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonDefaultConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("VMessIn: Failed to parse default config: " + err.Error())
 	}
 	this.AlterIDs = jsonConfig.AlterIDs
 	if this.AlterIDs == 0 {
@@ -59,7 +60,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("VMessIn: Failed to parse config: " + err.Error())
 	}
 	this.AllowedUsers = jsonConfig.Users
 	this.Features = jsonConfig.Features // Backward compatibility

+ 3 - 2
proxy/vmess/outbound/config_json.go

@@ -4,6 +4,7 @@ package outbound
 
 import (
 	"encoding/json"
+	"errors"
 
 	"github.com/v2ray/v2ray-core/common/log"
 	"github.com/v2ray/v2ray-core/proxy/internal"
@@ -16,10 +17,10 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	rawOutbound := &RawOutbound{}
 	err := json.Unmarshal(data, rawOutbound)
 	if err != nil {
-		return err
+		return errors.New("VMessOut: Failed to parse config: " + err.Error())
 	}
 	if len(rawOutbound.Receivers) == 0 {
-		log.Error("VMess: 0 VMess receiver configured.")
+		log.Error("VMessOut: 0 VMess receiver configured.")
 		return internal.ErrorBadConfiguration
 	}
 	this.Receivers = rawOutbound.Receivers

+ 7 - 7
shell/point/config_json.go

@@ -34,7 +34,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse config: " + err.Error())
 	}
 	this.Port = jsonConfig.Port
 	this.LogConfig = jsonConfig.LogConfig
@@ -65,7 +65,7 @@ func (this *InboundConnectionConfig) UnmarshalJSON(data []byte) error {
 
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse inbound config: " + err.Error())
 	}
 	this.Port = v2net.Port(jsonConfig.Port)
 	this.ListenOn = v2net.AnyIP
@@ -89,7 +89,7 @@ func (this *OutboundConnectionConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonConnectionConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse outbound config: " + err.Error())
 	}
 	this.Protocol = jsonConfig.Protocol
 	this.Settings = jsonConfig.Settings
@@ -112,7 +112,7 @@ func (this *LogConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonLogConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse log config: " + err.Error())
 	}
 	this.AccessLog = jsonConfig.AccessLog
 	this.ErrorLog = jsonConfig.ErrorLog
@@ -141,7 +141,7 @@ func (this *InboundDetourAllocationConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonInboundDetourAllocationConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse inbound detour allocation config: " + err.Error())
 	}
 	this.Strategy = jsonConfig.Strategy
 	this.Concurrency = jsonConfig.Concurrency
@@ -171,7 +171,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonInboundDetourConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse inbound detour config: " + err.Error())
 	}
 	if jsonConfig.PortRange == nil {
 		log.Error("Point: Port range not specified in InboundDetour.")
@@ -207,7 +207,7 @@ func (this *OutboundDetourConfig) UnmarshalJSON(data []byte) error {
 	}
 	jsonConfig := new(JsonOutboundDetourConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
-		return err
+		return errors.New("Point: Failed to parse outbound detour config: " + err.Error())
 	}
 	this.Protocol = jsonConfig.Protocol
 	this.Tag = jsonConfig.Tag