Browse Source

Split json config files

V2Ray 10 years ago
parent
commit
ce07ea9769
3 changed files with 41 additions and 32 deletions
  1. 32 0
      config/json/connection.go
  2. 0 32
      config/json/json.go
  3. 9 0
      config/json/log.go

+ 32 - 0
config/json/connection.go

@@ -0,0 +1,32 @@
+package json
+
+import (
+	"encoding/json"
+
+	"github.com/v2ray/v2ray-core/common/log"
+	"github.com/v2ray/v2ray-core/config"
+)
+
+type ConnectionConfig struct {
+	ProtocolString  string          `json:"protocol"`
+	SettingsMessage json.RawMessage `json:"settings"`
+	Type            config.Type     `json:"-"`
+}
+
+func (c *ConnectionConfig) Protocol() string {
+	return c.ProtocolString
+}
+
+func (c *ConnectionConfig) Settings() interface{} {
+	creator, found := configCache[getConfigKey(c.Protocol(), c.Type)]
+	if !found {
+		panic("Unknown protocol " + c.Protocol())
+	}
+	configObj := creator()
+	err := json.Unmarshal(c.SettingsMessage, configObj)
+	if err != nil {
+		log.Error("Unable to parse connection config: %v", err)
+		panic("Failed to parse connection config.")
+	}
+	return configObj
+}

+ 0 - 32
config/json/json.go

@@ -9,38 +9,6 @@ import (
 	"github.com/v2ray/v2ray-core/config"
 )
 
-type ConnectionConfig struct {
-	ProtocolString  string          `json:"protocol"`
-	SettingsMessage json.RawMessage `json:"settings"`
-	Type            config.Type     `json:"-"`
-}
-
-func (config *ConnectionConfig) Protocol() string {
-	return config.ProtocolString
-}
-
-func (config *ConnectionConfig) Settings() interface{} {
-	creator, found := configCache[getConfigKey(config.Protocol(), config.Type)]
-	if !found {
-		panic("Unknown protocol " + config.Protocol())
-	}
-	configObj := creator()
-	err := json.Unmarshal(config.SettingsMessage, configObj)
-	if err != nil {
-		log.Error("Unable to parse connection config: %v", err)
-		panic("Failed to parse connection config.")
-	}
-	return configObj
-}
-
-type LogConfig struct {
-	AccessLogValue string `json:"access"`
-}
-
-func (config *LogConfig) AccessLog() string {
-	return config.AccessLogValue
-}
-
 // Config is the config for Point server.
 type Config struct {
 	PortValue           uint16            `json:"port"` // Port of this Point server.

+ 9 - 0
config/json/log.go

@@ -0,0 +1,9 @@
+package json
+
+type LogConfig struct {
+	AccessLogValue string `json:"access"`
+}
+
+func (config *LogConfig) AccessLog() string {
+	return config.AccessLogValue
+}