fix build break

pull/82/head
v2ray 9 years ago
parent 40c3a01e68
commit 3f634eb54f

@ -4,43 +4,43 @@ package shadowsocks
import ( import (
"encoding/json" "encoding/json"
"github.com/v2ray/v2ray-core/common/log" "github.com/v2ray/v2ray-core/common/log"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/internal"
) )
func (this *Config) UnmarshalJSON(data []byte) error { func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct { type JsonConfig struct {
Cipher *serial.StringLiteral `json:"method"` Cipher serial.StringLiteral `json:"method"`
Password *serial.StringLiteral `json:"password"` Password serial.StringLiteral `json:"password"`
} }
jsonConfig := new(JsonConfig) jsonConfig := new(JsonConfig)
if err := json.Unmarshal(data, jsonConfig); err != nil { if err := json.Unmarshal(data, jsonConfig); err != nil {
return err return err
} }
if this.Password == nil { if len(jsonConfig.Password) == 0 {
log.Error("Shadowsocks: Password is not specified.") log.Error("Shadowsocks: Password is not specified.")
return internal.ErrorBadConfiguration return internal.ErrorBadConfiguration
} }
this.Password = jsonConfig.Password.String() this.Password = jsonConfig.Password.String()
if this.Cipher == nil { if this.Cipher == nil {
log.Error("Shadowsocks: Cipher method is not specified.") log.Error("Shadowsocks: Cipher method is not specified.")
return internal.ErrorBadConfiguration return internal.ErrorBadConfiguration
} }
jsonConfig.Cipher = jsonConfig.Cipher.ToLower() jsonConfig.Cipher = jsonConfig.Cipher.ToLower()
switch jsonConfig.Cipher.String() { switch jsonConfig.Cipher.String() {
case "aes-256-cfb": case "aes-256-cfb":
this.Cipher = &AesCfb { this.Cipher = &AesCfb{
KeyBytes: 32 KeyBytes: 32,
} }
case "aes-128-cfb": case "aes-128-cfb":
this.Cipher = &AesCfb { this.Cipher = &AesCfb{
KeyBytes: 32 KeyBytes: 32,
} }
default: default:
log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher) log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher)
return internal.ErrorBadConfiguration return internal.ErrorBadConfiguration
} }
return nil return nil
} }

Loading…
Cancel
Save