mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-18 23:00:12 +00:00
allow dynamic type of user accounts
This commit is contained in:
1 parent
87f664048b
commit
3f9cb1136a
18 files changed
+123
-49
No files matched your search
@@ -52,7 +52,7 @@ func NewClientSession(idHash protocol.IDHash) *ClientSession {
|
||||
|
||||
func (this *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writer io.Writer) {
|
||||
timestamp := protocol.NewTimestampGenerator(protocol.NowTime(), 30)()
|
||||
idHash := this.idHash(header.User.AnyValidID().Bytes())
|
||||
idHash := this.idHash(header.User.Account.(*protocol.VMessAccount).AnyValidID().Bytes())
|
||||
idHash.Write(timestamp.Bytes())
|
||||
writer.Write(idHash.Sum(nil))
|
||||
|
||||
@@ -87,7 +87,8 @@ func (this *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, w
|
||||
timestampHash := md5.New()
|
||||
timestampHash.Write(hashTimestamp(timestamp))
|
||||
iv := timestampHash.Sum(nil)
|
||||
aesStream := crypto.NewAesEncryptionStream(header.User.ID.CmdKey(), iv)
|
||||
account := header.User.Account.(*protocol.VMessAccount)
|
||||
aesStream := crypto.NewAesEncryptionStream(account.ID.CmdKey(), iv)
|
||||
aesStream.XORKeyStream(buffer.Value, buffer.Value)
|
||||
writer.Write(buffer.Value)
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ func TestRequestSerialization(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
user := protocol.NewUser(
|
||||
protocol.NewID(uuid.New()),
|
||||
nil,
|
||||
&protocol.VMessAccount{
|
||||
ID: protocol.NewID(uuid.New()),
|
||||
AlterIDs: nil,
|
||||
},
|
||||
protocol.UserLevelUntrusted,
|
||||
"test@v2ray.com")
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ func (this *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Requ
|
||||
timestampHash := md5.New()
|
||||
timestampHash.Write(hashTimestamp(timestamp))
|
||||
iv := timestampHash.Sum(nil)
|
||||
aesStream := crypto.NewAesDecryptionStream(user.ID.CmdKey(), iv)
|
||||
account := user.Account.(*protocol.VMessAccount)
|
||||
aesStream := crypto.NewAesDecryptionStream(account.ID.CmdKey(), iv)
|
||||
decryptor := crypto.NewCryptionReader(aesStream, reader)
|
||||
|
||||
nBytes, err := io.ReadFull(decryptor, buffer.Value[:41])
|
||||
|
||||
Reference in new issue
Block a user