From cca7d63e20035098329b6ccb6dc5f908202cead1 Mon Sep 17 00:00:00 2001 From: Artem Titoulenko Date: Sun, 19 Dec 2021 02:23:43 -0500 Subject: [PATCH] fix TLV construction in message delivery. users can now chat --- 0x01_generic_service_controls.go | 6 +++--- message_delivery_routine.go | 18 +++++++++--------- online_routine.go | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/0x01_generic_service_controls.go b/0x01_generic_service_controls.go index 8f05a37..660ada4 100644 --- a/0x01_generic_service_controls.go +++ b/0x01_generic_service_controls.go @@ -60,8 +60,8 @@ func (g *GenericServiceControls) HandleSNAC(ctx context.Context, db *bun.DB, sna onlineSnac.Data.WriteUint16(0) // TODO: user warning level tlvs := []*oscar.TLV{ - oscar.NewTLV(1, util.Word(0x80)), // TODO: user class - oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status + oscar.NewTLV(1, util.Word(0)), // TODO: user class + oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time @@ -142,7 +142,7 @@ func (g *GenericServiceControls) HandleSNAC(ctx context.Context, db *bun.DB, sna tlvs := []*oscar.TLV{ oscar.NewTLV(0x01, util.Dword(0x80)), // User Class - oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status + oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time diff --git a/message_delivery_routine.go b/message_delivery_routine.go index 0ce75d7..4fd1667 100644 --- a/message_delivery_routine.go +++ b/message_delivery_routine.go @@ -34,10 +34,10 @@ func MessageDelivery() (chan *models.Message, routineFn) { messageSnac.Data.WriteUint16(0) // TODO: sender's warning level tlvs := []*oscar.TLV{ - oscar.NewTLV(1, util.Word(0x80)), // TODO: user class - oscar.NewTLV(6, util.Dword(0x0001|0x0100)), // TODO: user status - oscar.NewTLV(0xf, util.Dword(0)), // TODO: user idle time - oscar.NewTLV(3, util.Dword(0)), // TODO: user creation time + oscar.NewTLV(1, util.Word(0)), // TODO: user class + oscar.NewTLV(6, util.Dword(0)), // TODO: user status + oscar.NewTLV(0xf, util.Dword(0)), // TODO: user idle time + oscar.NewTLV(3, util.Dword(0)), // TODO: user creation time // oscar.NewTLV(4, []byte{}), // TODO: this TLV appears in automated responses like away messages } @@ -50,14 +50,14 @@ func MessageDelivery() (chan *models.Message, routineFn) { } frag := oscar.Buffer{} - frag.Write([]byte{5, 1, 0, 4, 1, 1, 1, 1}) // TODO: first fragment [id, version, len, len, (cap * len)... ] - frag.Write([]byte{1, 1}) // message text fragment start (this is a busted "TLV") - frag.Write(util.Word(uint16(len(message.Contents) + 4))) // length of TLV - frag.Write([]byte{0, 0, 0, 0}) // TODO: message charset number, message charset subset + frag.Write([]byte{5, 1, 0, 4, 1, 1, 1, 2}) // TODO: first fragment [id, version, len, len, (cap * len)... ] + frag.Write([]byte{1, 1}) // message text fragment start (this is a busted "TLV") + frag.WriteUint16(uint16(len(message.Contents) + 4)) // length of TLV + frag.Write([]byte{0, 0, 0, 0}) // TODO: message charset number, message charset subset frag.WriteString(message.Contents) // Append the fragments - messageSnac.Data.Write(frag.Bytes()) + messageSnac.Data.WriteBinary(oscar.NewTLV(2, frag.Bytes())) messageFlap := oscar.NewFLAP(2) messageFlap.Data.WriteBinary(messageSnac) diff --git a/online_routine.go b/online_routine.go index 0542135..e839882 100644 --- a/online_routine.go +++ b/online_routine.go @@ -43,8 +43,8 @@ func OnlineNotification() (chan *models.User, routineFn) { onlineSnac.Data.WriteUint16(0) // TODO: user warning level tlvs := []*oscar.TLV{ - oscar.NewTLV(1, util.Word(0x80)), // TODO: user class - oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status + oscar.NewTLV(1, util.Word(0)), // TODO: user class + oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time