1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 23:47:07 -05:00

fix error messages for socks config

This commit is contained in:
Darien Raymond 2017-01-17 10:44:24 +01:00
parent 9be43f4bf3
commit b3aa3200ed
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -2,6 +2,7 @@ package conf
import ( import (
"encoding/json" "encoding/json"
"v2ray.com/core/common/errors" "v2ray.com/core/common/errors"
"v2ray.com/core/common/protocol" "v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial" "v2ray.com/core/common/serial"
@ -40,7 +41,7 @@ func (v *SocksServerConfig) Build() (*serial.TypedMessage, error) {
} else if v.AuthMethod == AuthMethodUserPass { } else if v.AuthMethod == AuthMethodUserPass {
config.AuthType = socks.AuthType_PASSWORD config.AuthType = socks.AuthType_PASSWORD
} else { } else {
return nil, errors.New("Unknown socks auth method: " + v.AuthMethod) return nil, errors.New("Config: Unknown socks auth method: " + v.AuthMethod)
} }
if len(v.Accounts) > 0 { if len(v.Accounts) > 0 {
@ -79,11 +80,11 @@ func (v *SocksClientConfig) Build() (*serial.TypedMessage, error) {
for _, rawUser := range serverConfig.Users { for _, rawUser := range serverConfig.Users {
user := new(protocol.User) user := new(protocol.User)
if err := json.Unmarshal(rawUser, user); err != nil { if err := json.Unmarshal(rawUser, user); err != nil {
return nil, errors.Base(err).Message("Socks|Client: Failed to parse user.") return nil, errors.Base(err).Message("Config: Failed to parse Socks user.")
} }
account := new(SocksAccount) account := new(SocksAccount)
if err := json.Unmarshal(rawUser, account); err != nil { if err := json.Unmarshal(rawUser, account); err != nil {
return nil, errors.Base(err).Message("Socks|Client: Failed to parse socks account.") return nil, errors.Base(err).Message("Config: Failed to parse socks account.")
} }
user.Account = serial.ToTypedMessage(account.Build()) user.Account = serial.ToTypedMessage(account.Build())
server.User = append(server.User, user) server.User = append(server.User, user)