From 3f634eb54f4f5509afa1419b7a887c21a15de939 Mon Sep 17 00:00:00 2001 From: v2ray Date: Wed, 27 Jan 2016 15:57:53 +0100 Subject: [PATCH] fix build break --- proxy/shadowsocks/config_json.go | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/proxy/shadowsocks/config_json.go b/proxy/shadowsocks/config_json.go index 238f8c6c..6b5799ac 100644 --- a/proxy/shadowsocks/config_json.go +++ b/proxy/shadowsocks/config_json.go @@ -4,43 +4,43 @@ package shadowsocks import ( "encoding/json" - - "github.com/v2ray/v2ray-core/common/log" - "github.com/v2ray/v2ray-core/common/serial" - "github.com/v2ray/v2ray-core/proxy/internal" + + "github.com/v2ray/v2ray-core/common/log" + "github.com/v2ray/v2ray-core/common/serial" + "github.com/v2ray/v2ray-core/proxy/internal" ) func (this *Config) UnmarshalJSON(data []byte) error { type JsonConfig struct { - Cipher *serial.StringLiteral `json:"method"` - Password *serial.StringLiteral `json:"password"` + Cipher serial.StringLiteral `json:"method"` + Password serial.StringLiteral `json:"password"` } jsonConfig := new(JsonConfig) if err := json.Unmarshal(data, jsonConfig); err != nil { return err } - if this.Password == nil { - log.Error("Shadowsocks: Password is not specified.") - return internal.ErrorBadConfiguration - } - this.Password = jsonConfig.Password.String() - if this.Cipher == nil { - log.Error("Shadowsocks: Cipher method is not specified.") - return internal.ErrorBadConfiguration - } - jsonConfig.Cipher = jsonConfig.Cipher.ToLower() - switch jsonConfig.Cipher.String() { - case "aes-256-cfb": - this.Cipher = &AesCfb { - KeyBytes: 32 - } - case "aes-128-cfb": - this.Cipher = &AesCfb { - KeyBytes: 32 - } - default: - log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher) - return internal.ErrorBadConfiguration - } - return nil + if len(jsonConfig.Password) == 0 { + log.Error("Shadowsocks: Password is not specified.") + return internal.ErrorBadConfiguration + } + this.Password = jsonConfig.Password.String() + if this.Cipher == nil { + log.Error("Shadowsocks: Cipher method is not specified.") + return internal.ErrorBadConfiguration + } + jsonConfig.Cipher = jsonConfig.Cipher.ToLower() + switch jsonConfig.Cipher.String() { + case "aes-256-cfb": + this.Cipher = &AesCfb{ + KeyBytes: 32, + } + case "aes-128-cfb": + this.Cipher = &AesCfb{ + KeyBytes: 32, + } + default: + log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher) + return internal.ErrorBadConfiguration + } + return nil }