1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-04 08:15:21 -05:00

accounts in protobuf

This commit is contained in:
Darien Raymond
2016-09-18 00:41:21 +02:00
parent 3423adaea4
commit d08cba000f
40 changed files with 790 additions and 224 deletions

View File

@@ -52,7 +52,12 @@ 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.Account.(*vmess.Account).AnyValidID().Bytes())
account, err := header.User.GetTypedAccount(&vmess.AccountPB{})
if err != nil {
log.Error("VMess: Failed to get user account: ", err)
return
}
idHash := this.idHash(account.(*vmess.Account).AnyValidID().Bytes())
idHash.Write(timestamp.Bytes(nil))
writer.Write(idHash.Sum(nil))
@@ -83,8 +88,7 @@ func (this *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, w
timestampHash := md5.New()
timestampHash.Write(hashTimestamp(timestamp))
iv := timestampHash.Sum(nil)
account := header.User.Account.(*vmess.Account)
aesStream := crypto.NewAesEncryptionStream(account.ID.CmdKey(), iv)
aesStream := crypto.NewAesEncryptionStream(account.(*vmess.Account).ID.CmdKey(), iv)
aesStream.XORKeyStream(buffer, buffer)
writer.Write(buffer)