mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 09:56:18 -05:00
apply user settings to shadowsocks
This commit is contained in:
parent
2147ba5ab3
commit
2932d23b32
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/v2ray/v2ray-core/common/crypto"
|
"github.com/v2ray/v2ray-core/common/crypto"
|
||||||
|
"github.com/v2ray/v2ray-core/common/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cipher interface {
|
type Cipher interface {
|
||||||
@ -48,6 +49,7 @@ type Config struct {
|
|||||||
Cipher Cipher
|
Cipher Cipher
|
||||||
Key []byte
|
Key []byte
|
||||||
UDP bool
|
UDP bool
|
||||||
|
Level protocol.UserLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
func PasswordToCipherKey(password string, keySize int) []byte {
|
func PasswordToCipherKey(password string, keySize int) []byte {
|
||||||
|
@ -6,6 +6,7 @@ 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/protocol"
|
||||||
"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"
|
||||||
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
||||||
@ -16,6 +17,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
Cipher serial.StringLiteral `json:"method"`
|
Cipher serial.StringLiteral `json:"method"`
|
||||||
Password serial.StringLiteral `json:"password"`
|
Password serial.StringLiteral `json:"password"`
|
||||||
UDP bool `json:"udp"`
|
UDP bool `json:"udp"`
|
||||||
|
Level byte `json:"level"`
|
||||||
}
|
}
|
||||||
jsonConfig := new(JsonConfig)
|
jsonConfig := new(JsonConfig)
|
||||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||||
@ -44,6 +46,8 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
this.Key = PasswordToCipherKey(jsonConfig.Password.String(), this.Cipher.KeySize())
|
this.Key = PasswordToCipherKey(jsonConfig.Password.String(), this.Cipher.KeySize())
|
||||||
|
|
||||||
|
this.Level = protocol.UserLevel(jsonConfig.Level)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
v2io "github.com/v2ray/v2ray-core/common/io"
|
v2io "github.com/v2ray/v2ray-core/common/io"
|
||||||
"github.com/v2ray/v2ray-core/common/log"
|
"github.com/v2ray/v2ray-core/common/log"
|
||||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
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/common/serial"
|
||||||
"github.com/v2ray/v2ray-core/proxy"
|
"github.com/v2ray/v2ray-core/proxy"
|
||||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||||
@ -179,7 +180,8 @@ func (this *Shadowsocks) handleConnection(conn *hub.TCPConn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
timedReader.SetTimeOut(300)
|
userSettings := protocol.GetUserSettings(this.config.Level)
|
||||||
|
timedReader.SetTimeOut(userSettings.PayloadReadTimeout)
|
||||||
|
|
||||||
dest := v2net.TCPDestination(request.Address, request.Port)
|
dest := v2net.TCPDestination(request.Address, request.Port)
|
||||||
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, serial.StringLiteral(""))
|
log.Access(conn.RemoteAddr(), dest, log.AccessAccepted, serial.StringLiteral(""))
|
||||||
|
Loading…
Reference in New Issue
Block a user