mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
format errors
This commit is contained in:
parent
efb24a4d21
commit
e46bad3f18
@ -105,7 +105,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
|
||||
_, err = io.ReadFull(reader, buffer.Value[lenBuffer:lenBuffer+2])
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Failed to read port: " + err.Error())
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read port.")
|
||||
}
|
||||
|
||||
request.Port = v2net.PortFromBytes(buffer.Value[lenBuffer : lenBuffer+2])
|
||||
@ -115,7 +115,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
||||
authBytes := buffer.Value[lenBuffer : lenBuffer+AuthSize]
|
||||
_, err = io.ReadFull(reader, authBytes)
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("Shadowsocks|TCP: Failed to read OTA: " + err.Error())
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read OTA.")
|
||||
}
|
||||
|
||||
actualAuth := authenticator.Authenticate(nil, buffer.Value[0:lenBuffer])
|
||||
@ -199,19 +199,19 @@ func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (v2io.Wr
|
||||
func ReadTCPResponse(user *protocol.User, reader io.Reader) (v2io.Reader, error) {
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to parse account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
iv := make([]byte, account.Cipher.IVSize())
|
||||
_, err = io.ReadFull(reader, iv)
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to read IV: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to read IV.")
|
||||
}
|
||||
|
||||
stream, err := account.Cipher.NewDecodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to initialize decoding stream: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to initialize decoding stream.")
|
||||
}
|
||||
return v2io.NewAdaptiveReader(crypto.NewCryptionReader(stream, reader)), nil
|
||||
}
|
||||
@ -220,7 +220,7 @@ func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (v2io.W
|
||||
user := request.User
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to parse account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to parse account.")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@ -228,12 +228,12 @@ func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (v2io.W
|
||||
rand.Read(iv)
|
||||
_, err = writer.Write(iv)
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to write IV: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to write IV.")
|
||||
}
|
||||
|
||||
stream, err := account.Cipher.NewEncodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to create encoding stream: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to create encoding stream.")
|
||||
}
|
||||
|
||||
return v2io.NewAdaptiveWriter(crypto.NewCryptionWriter(stream, writer)), nil
|
||||
@ -243,7 +243,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *alloc.Buffer) (*a
|
||||
user := request.User
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|UDP: Failed to parse account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to parse account.")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@ -264,7 +264,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *alloc.Buffer) (*a
|
||||
buffer.AppendBytes(AddrTypeDomain, byte(len(request.Address.Domain())))
|
||||
buffer.Append([]byte(request.Address.Domain()))
|
||||
default:
|
||||
return nil, errors.New("Shadowsocks|UDP: Unsupported address type. ")
|
||||
return nil, errors.New("Shadowsocks|UDP: Unsupported address type: ", request.Address.Family())
|
||||
}
|
||||
|
||||
buffer.AppendUint16(uint16(request.Port))
|
||||
@ -279,7 +279,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *alloc.Buffer) (*a
|
||||
|
||||
stream, err := account.Cipher.NewEncodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|TCP: Failed to create encoding stream: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|TCP: Failed to create encoding stream.")
|
||||
}
|
||||
|
||||
stream.XORKeyStream(buffer.Value[ivLen:], buffer.Value[ivLen:])
|
||||
@ -289,7 +289,7 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload *alloc.Buffer) (*a
|
||||
func DecodeUDPPacket(user *protocol.User, payload *alloc.Buffer) (*protocol.RequestHeader, *alloc.Buffer, error) {
|
||||
rawAccount, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Failed to parse account: " + err.Error())
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to parse account.")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
@ -299,7 +299,7 @@ func DecodeUDPPacket(user *protocol.User, payload *alloc.Buffer) (*protocol.Requ
|
||||
|
||||
stream, err := account.Cipher.NewDecodingStream(account.Key, iv)
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Failed to initialize decoding stream: " + err.Error())
|
||||
return nil, nil, errors.Base(err).Message("Shadowsocks|UDP: Failed to initialize decoding stream.")
|
||||
}
|
||||
stream.XORKeyStream(payload.Value, payload.Value)
|
||||
|
||||
@ -349,7 +349,7 @@ func DecodeUDPPacket(user *protocol.User, payload *alloc.Buffer) (*protocol.Requ
|
||||
request.Address = v2net.DomainAddress(string(payload.Value[1 : 1+domainLength]))
|
||||
payload.SliceFrom(1 + domainLength)
|
||||
default:
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Unknown address type")
|
||||
return nil, nil, errors.New("Shadowsocks|UDP: Unknown address type: ", addrType)
|
||||
}
|
||||
|
||||
request.Port = v2net.PortFromBytes(payload.Value[:2])
|
||||
|
@ -36,7 +36,7 @@ func NewServer(config *ServerConfig, space app.Space, meta *proxy.InboundHandler
|
||||
|
||||
rawAccount, err := config.User.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.New("Shadowsocks|Server: Failed to get user account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Shadowsocks|Server: Failed to get user account.")
|
||||
}
|
||||
account := rawAccount.(*ShadowsocksAccount)
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
||||
iv := timestampHash.Sum(nil)
|
||||
account, err := user.GetTypedAccount()
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to get user account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to get user account.")
|
||||
}
|
||||
|
||||
aesStream := crypto.NewAesDecryptionStream(account.(*vmess.InternalAccount).ID.CmdKey(), iv)
|
||||
@ -68,7 +68,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
||||
|
||||
nBytes, err := io.ReadFull(decryptor, buffer[:41])
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to read request header: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to read request header.")
|
||||
}
|
||||
bufferLen := nBytes
|
||||
|
||||
@ -78,8 +78,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
||||
}
|
||||
|
||||
if request.Version != Version {
|
||||
log.Info("VMess|Server: Invalid protocol version ", request.Version)
|
||||
return nil, protocol.ErrInvalidVersion
|
||||
return nil, errors.New("VMess|Server: Invalid protocol version ", request.Version)
|
||||
}
|
||||
|
||||
v.requestBodyIV = append([]byte(nil), buffer[1:17]...) // 16 bytes
|
||||
@ -95,28 +94,28 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
||||
_, err = io.ReadFull(decryptor, buffer[41:45]) // 4 bytes
|
||||
bufferLen += 4
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to read IPv4: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to read IPv4.")
|
||||
}
|
||||
request.Address = v2net.IPAddress(buffer[41:45])
|
||||
case AddrTypeIPv6:
|
||||
_, err = io.ReadFull(decryptor, buffer[41:57]) // 16 bytes
|
||||
bufferLen += 16
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to read IPv6 address: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to read IPv6 address.")
|
||||
}
|
||||
request.Address = v2net.IPAddress(buffer[41:57])
|
||||
case AddrTypeDomain:
|
||||
_, err = io.ReadFull(decryptor, buffer[41:42])
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess:Server: Failed to read domain: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess:Server: Failed to read domain.")
|
||||
}
|
||||
domainLength := int(buffer[41])
|
||||
if domainLength == 0 {
|
||||
return nil, errors.New("VMess|Server: Zero domain length.")
|
||||
return nil, errors.New("VMess|Server: Zero length domain.")
|
||||
}
|
||||
_, err = io.ReadFull(decryptor, buffer[42:42+domainLength])
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to read domain: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to read domain.")
|
||||
}
|
||||
bufferLen += 1 + domainLength
|
||||
request.Address = v2net.DomainAddress(string(buffer[42 : 42+domainLength]))
|
||||
@ -124,7 +123,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
||||
|
||||
_, err = io.ReadFull(decryptor, buffer[bufferLen:bufferLen+4])
|
||||
if err != nil {
|
||||
return nil, errors.New("VMess|Server: Failed to read checksum: " + err.Error())
|
||||
return nil, errors.Base(err).Message("VMess|Server: Failed to read checksum.")
|
||||
}
|
||||
|
||||
fnv1a := fnv.New32a()
|
||||
|
@ -28,7 +28,7 @@ func (v *BlackholeConfig) Build() (*loader.TypedSettings, error) {
|
||||
if v.Response != nil {
|
||||
response, _, err := configLoader.Load(v.Response)
|
||||
if err != nil {
|
||||
return nil, errors.New("Blackhole: Failed to parse response config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Blackhole: Failed to parse response config.")
|
||||
}
|
||||
responseSettings, err := response.(Buildable).Build()
|
||||
if err != nil {
|
||||
|
@ -79,11 +79,11 @@ func (v *SocksClientConfig) Build() (*loader.TypedSettings, error) {
|
||||
for _, rawUser := range serverConfig.Users {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||
return nil, errors.New("Socks|Client: Failed to parse user: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Socks|Client: Failed to parse user.")
|
||||
}
|
||||
account := new(SocksAccount)
|
||||
if err := json.Unmarshal(rawUser, account); err != nil {
|
||||
return nil, errors.New("Socks|Client: Failed to parse socks account: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Socks|Client: Failed to parse socks account.")
|
||||
}
|
||||
user.Account = loader.NewTypedSettings(account.Build())
|
||||
server.User = append(server.User, user)
|
||||
|
@ -19,7 +19,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
||||
if v.TCPConfig != nil {
|
||||
ts, err := v.TCPConfig.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build TCP config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build TCP config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_TCP,
|
||||
@ -30,7 +30,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
||||
if v.KCPConfig != nil {
|
||||
ts, err := v.KCPConfig.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build KCP config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build mKCP config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_KCP,
|
||||
@ -41,7 +41,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
||||
if v.WSConfig != nil {
|
||||
ts, err := v.WSConfig.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build WebSocket config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build WebSocket config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_WebSocket,
|
||||
|
@ -84,11 +84,11 @@ func (v *KCPConfig) Build() (*loader.TypedSettings, error) {
|
||||
if len(v.HeaderConfig) > 0 {
|
||||
headerConfig, _, err := kcpHeaderLoader.Load(v.HeaderConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("KCP|Config: Failed to parse header config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid mKCP header config.")
|
||||
}
|
||||
ts, err := headerConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to get KCP authenticator config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid mKCP header config.")
|
||||
}
|
||||
config.HeaderConfig = ts
|
||||
}
|
||||
@ -111,11 +111,11 @@ func (v *TCPConfig) Build() (*loader.TypedSettings, error) {
|
||||
if len(v.HeaderConfig) > 0 {
|
||||
headerConfig, _, err := tcpHeaderLoader.Load(v.HeaderConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("TCP|Config: Failed to parse header config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid TCP header config.")
|
||||
}
|
||||
ts, err := headerConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to get TCP authenticator config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid TCP header config.")
|
||||
}
|
||||
config.HeaderSettings = ts
|
||||
}
|
||||
@ -155,11 +155,11 @@ func (v *TLSConfig) Build() (*loader.TypedSettings, error) {
|
||||
for idx, certConf := range v.Certs {
|
||||
cert, err := ioutil.ReadFile(certConf.CertFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("TLS: Failed to load certificate file: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to load TLS certificate file: ", certConf.CertFile)
|
||||
}
|
||||
key, err := ioutil.ReadFile(certConf.KeyFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("TLS: Failed to load key file: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to load TLS key file: ", certConf.KeyFile)
|
||||
}
|
||||
config.Certificate[idx] = &tls.Certificate{
|
||||
Key: key,
|
||||
@ -193,14 +193,14 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
}
|
||||
ts, err := tlsSettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build TLS config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build TLS config.")
|
||||
}
|
||||
config.SecuritySettings = append(config.SecuritySettings, ts)
|
||||
}
|
||||
if v.TCPSettings != nil {
|
||||
ts, err := v.TCPSettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build TCP config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build TCP config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_TCP,
|
||||
@ -210,7 +210,7 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
if v.KCPSettings != nil {
|
||||
ts, err := v.KCPSettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build KCP config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build mKCP config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_KCP,
|
||||
@ -220,7 +220,7 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
if v.WSSettings != nil {
|
||||
ts, err := v.WSSettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to build WebSocket config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to build WebSocket config.")
|
||||
}
|
||||
config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{
|
||||
Network: v2net.Network_WebSocket,
|
||||
|
@ -60,7 +60,7 @@ func (v *InboundConnectionConfig) Build() (*core.InboundConnectionConfig, error)
|
||||
|
||||
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to load inbound config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to load inbound config.")
|
||||
}
|
||||
ts, err := jsonConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
@ -86,7 +86,7 @@ func (v *OutboundConnectionConfig) Build() (*core.OutboundConnectionConfig, erro
|
||||
config := new(core.OutboundConnectionConfig)
|
||||
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to parse outbound config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to parse outbound config.")
|
||||
}
|
||||
ts, err := rawConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
@ -97,7 +97,7 @@ func (v *OutboundConnectionConfig) Build() (*core.OutboundConnectionConfig, erro
|
||||
if v.SendThrough != nil {
|
||||
address := v.SendThrough
|
||||
if address.Family().IsDomain() {
|
||||
return nil, errors.New("Point: Unable to send through: " + address.String())
|
||||
return nil, errors.New("Invalid sendThrough address: " + address.String())
|
||||
}
|
||||
config.SendThrough = address.Build()
|
||||
}
|
||||
@ -111,7 +111,7 @@ func (v *OutboundConnectionConfig) Build() (*core.OutboundConnectionConfig, erro
|
||||
if v.ProxySettings != nil {
|
||||
ps, err := v.ProxySettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("Outbound: invalid proxy settings: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid outbound proxy settings.")
|
||||
}
|
||||
config.ProxySettings = ps
|
||||
}
|
||||
@ -137,7 +137,7 @@ func (v *InboundDetourAllocationConfig) Build() (*core.AllocationStrategy, error
|
||||
case "external":
|
||||
config.Type = core.AllocationStrategy_External
|
||||
default:
|
||||
return nil, errors.New("Unknown allocation strategy: " + v.Strategy)
|
||||
return nil, errors.New("Unknown allocation strategy: ", v.Strategy)
|
||||
}
|
||||
if v.Concurrency != nil {
|
||||
config.Concurrency = &core.AllocationStrategyConcurrency{
|
||||
@ -168,13 +168,13 @@ type InboundDetourConfig struct {
|
||||
func (v *InboundDetourConfig) Build() (*core.InboundConnectionConfig, error) {
|
||||
config := new(core.InboundConnectionConfig)
|
||||
if v.PortRange == nil {
|
||||
return nil, errors.New("Point: Port range not specified in InboundDetour.")
|
||||
return nil, errors.New("Port range not specified in InboundDetour.")
|
||||
}
|
||||
config.PortRange = v.PortRange.Build()
|
||||
|
||||
if v.ListenOn != nil {
|
||||
if v.ListenOn.Family().IsDomain() {
|
||||
return nil, errors.New("Point: Unable to listen on domain address: " + v.ListenOn.Domain())
|
||||
return nil, errors.New("Unable to listen on domain address: ", v.ListenOn.Domain())
|
||||
}
|
||||
config.ListenOn = v.ListenOn.Build()
|
||||
}
|
||||
@ -197,7 +197,7 @@ func (v *InboundDetourConfig) Build() (*core.InboundConnectionConfig, error) {
|
||||
|
||||
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to load inbound detour config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to load inbound detour config.")
|
||||
}
|
||||
ts, err := rawConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
@ -238,7 +238,7 @@ func (v *OutboundDetourConfig) Build() (*core.OutboundConnectionConfig, error) {
|
||||
|
||||
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to parse to outbound detour config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Failed to parse to outbound detour config.")
|
||||
}
|
||||
ts, err := rawConfig.(Buildable).Build()
|
||||
if err != nil {
|
||||
@ -248,7 +248,7 @@ func (v *OutboundDetourConfig) Build() (*core.OutboundConnectionConfig, error) {
|
||||
if v.ProxySettings != nil {
|
||||
ps, err := v.ProxySettings.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("OutboundDetour: invalid proxy settings: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid outbound detour proxy settings.")
|
||||
}
|
||||
config.ProxySettings = ps
|
||||
}
|
||||
@ -340,7 +340,7 @@ func init() {
|
||||
decoder := json.NewDecoder(input)
|
||||
err := decoder.Decode(jsonConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("Point: Failed to load server config: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid V2Ray config.")
|
||||
}
|
||||
|
||||
return jsonConfig.Build()
|
||||
|
@ -77,11 +77,11 @@ func (v *VMessInboundConfig) Build() (*loader.TypedSettings, error) {
|
||||
for idx, rawData := range v.Users {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawData, user); err != nil {
|
||||
return nil, errors.New("VMess|Inbound: Invalid user: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid VMess user.")
|
||||
}
|
||||
account := new(VMessAccount)
|
||||
if err := json.Unmarshal(rawData, account); err != nil {
|
||||
return nil, errors.New("VMess|Inbound: Invalid user: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid VMess user.")
|
||||
}
|
||||
user.Account = loader.NewTypedSettings(account.Build())
|
||||
config.User[idx] = user
|
||||
@ -123,11 +123,11 @@ func (v *VMessOutboundConfig) Build() (*loader.TypedSettings, error) {
|
||||
for _, rawUser := range rec.Users {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||
return nil, errors.New("VMess|Outbound: Invalid user: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid VMess user.")
|
||||
}
|
||||
account := new(VMessAccount)
|
||||
if err := json.Unmarshal(rawUser, account); err != nil {
|
||||
return nil, errors.New("VMess|Outbound: Invalid user: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Invalid VMess user.")
|
||||
}
|
||||
user.Account = loader.NewTypedSettings(account.Build())
|
||||
spec.User = append(spec.User, user)
|
||||
|
@ -55,11 +55,11 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
|
||||
if tcpSettings.HeaderSettings != nil {
|
||||
headerConfig, err := tcpSettings.HeaderSettings.GetInstance()
|
||||
if err != nil {
|
||||
return nil, errors.New("TCP: Failed to get header settings: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Interent|TCP: Failed to get header settings.")
|
||||
}
|
||||
auth, err := internet.CreateConnectionAuthenticator(tcpSettings.HeaderSettings.Type, headerConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("TCP: Failed to create header authenticator: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Internet|TCP: Failed to create header authenticator.")
|
||||
}
|
||||
conn = auth.Client(conn)
|
||||
}
|
||||
|
@ -66,11 +66,11 @@ func ListenTCP(address v2net.Address, port v2net.Port, options internet.ListenOp
|
||||
if tcpSettings.HeaderSettings != nil {
|
||||
headerConfig, err := tcpSettings.HeaderSettings.GetInstance()
|
||||
if err != nil {
|
||||
return nil, errors.New("TCP: Failed to get header settings: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Internet|TCP: Invalid header settings.")
|
||||
}
|
||||
auth, err := internet.CreateConnectionAuthenticator(tcpSettings.HeaderSettings.Type, headerConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("TCP: Failed to create header authenticator: " + err.Error())
|
||||
return nil, errors.Base(err).Message("Internet|TCP: Invalid header settings.")
|
||||
}
|
||||
l.authConfig = auth
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func (ws *wsconn) read(b []byte) (n int, err error) {
|
||||
func (ws *wsconn) getNewReadBuffer() error {
|
||||
_, r, err := ws.wsc.NextReader()
|
||||
if err != nil {
|
||||
log.Warning("WS transport: ws connection NewFrameReader return " + err.Error())
|
||||
log.Warning("WS transport: ws connection NewFrameReader return ", err)
|
||||
ws.connClosing = true
|
||||
ws.Close()
|
||||
return err
|
||||
@ -90,7 +90,7 @@ func (ws *wsconn) Write(b []byte) (n int, err error) {
|
||||
func (ws *wsconn) write(b []byte) (n int, err error) {
|
||||
wr, err := ws.wsc.NextWriter(websocket.BinaryMessage)
|
||||
if err != nil {
|
||||
log.Warning("WS transport: ws connection NewFrameReader return " + err.Error())
|
||||
log.Warning("WS transport: ws connection NewFrameReader return ", err)
|
||||
ws.connClosing = true
|
||||
ws.Close()
|
||||
return 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user