mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-02 00:19:24 +00:00
Remove serial.String
This commit is contained in:
@@ -4,21 +4,21 @@ package shadowsocks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Cipher serial.StringT `json:"method"`
|
||||
Password serial.StringT `json:"password"`
|
||||
UDP bool `json:"udp"`
|
||||
Level byte `json:"level"`
|
||||
Email string `json:"email"`
|
||||
Cipher string `json:"method"`
|
||||
Password string `json:"password"`
|
||||
UDP bool `json:"udp"`
|
||||
Level byte `json:"level"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
@@ -26,8 +26,8 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
this.UDP = jsonConfig.UDP
|
||||
jsonConfig.Cipher = jsonConfig.Cipher.ToLower()
|
||||
switch jsonConfig.Cipher.String() {
|
||||
jsonConfig.Cipher = strings.ToLower(jsonConfig.Cipher)
|
||||
switch jsonConfig.Cipher {
|
||||
case "aes-256-cfb":
|
||||
this.Cipher = &AesCfb{
|
||||
KeyBytes: 32,
|
||||
@@ -53,7 +53,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
log.Error("Shadowsocks: Password is not specified.")
|
||||
return internal.ErrorBadConfiguration
|
||||
}
|
||||
this.Key = PasswordToCipherKey(jsonConfig.Password.String(), this.Cipher.KeySize())
|
||||
this.Key = PasswordToCipherKey(jsonConfig.Password, this.Cipher.KeySize())
|
||||
|
||||
this.Level = protocol.UserLevel(jsonConfig.Level)
|
||||
this.Email = jsonConfig.Email
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/transport/hub"
|
||||
@@ -106,14 +105,14 @@ func (this *Server) handlerUDPPayload(payload *alloc.Buffer, source v2net.Destin
|
||||
|
||||
request, err := ReadRequest(reader, NewAuthenticator(HeaderKeyGenerator(key, iv)), true)
|
||||
if err != nil {
|
||||
log.Access(source, serial.StringT(""), log.AccessRejected, serial.StringT(err.Error()))
|
||||
log.Access(source, "", log.AccessRejected, err)
|
||||
log.Warning("Shadowsocks: Invalid request from ", source, ": ", err)
|
||||
return
|
||||
}
|
||||
//defer request.Release()
|
||||
|
||||
dest := v2net.UDPDestination(request.Address, request.Port)
|
||||
log.Access(source, dest, log.AccessAccepted, serial.StringT(""))
|
||||
log.Access(source, dest, log.AccessAccepted, "")
|
||||
log.Info("Shadowsocks: Tunnelling request to ", dest)
|
||||
|
||||
this.udpServer.Dispatch(source, dest, request.DetachUDPPayload(), func(destination v2net.Destination, payload *alloc.Buffer) {
|
||||
@@ -172,7 +171,7 @@ func (this *Server) handleConnection(conn *hub.Connection) {
|
||||
ivLen := this.config.Cipher.IVSize()
|
||||
_, err := io.ReadFull(bufferedReader, buffer.Value[:ivLen])
|
||||
if err != nil {
|
||||
log.Access(conn.RemoteAddr(), serial.StringT(""), log.AccessRejected, serial.StringT(err.Error()))
|
||||
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
|
||||
log.Error("Shadowsocks: Failed to read IV: ", err)
|
||||
return
|
||||
}
|
||||
@@ -190,7 +189,7 @@ func (this *Server) handleConnection(conn *hub.Connection) {
|
||||
|
||||
request, err := ReadRequest(reader, NewAuthenticator(HeaderKeyGenerator(key, iv)), false)
|
||||
if err != nil {
|
||||
log.Access(conn.RemoteAddr(), serial.StringT(""), log.AccessRejected, serial.StringT(err.Error()))
|
||||
log.Access(conn.RemoteAddr(), "", log.AccessRejected, err)
|
||||
log.Warning("Shadowsocks: Invalid request from ", conn.RemoteAddr(), ": ", err)
|
||||
return
|
||||
}
|
||||
@@ -201,7 +200,7 @@ func (this *Server) handleConnection(conn *hub.Connection) {
|
||||
timedReader.SetTimeOut(userSettings.PayloadReadTimeout)
|
||||
|
||||
dest := v2net.TCPDestination(request.Address, request.Port)
|
||||
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, serial.StringT(""))
|
||||
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, "")
|
||||
log.Info("Shadowsocks: Tunnelling request to ", dest)
|
||||
|
||||
ray := this.packetDispatcher.DispatchToOutbound(dest)
|
||||
|
||||
Reference in New Issue
Block a user