From 9b6c4ddf2fb5aa0c3435df0adce54b10f39f828b Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Sat, 18 Jun 2022 23:53:35 +0800 Subject: [PATCH] client: hoist highway input in uploading forward message --- client/multimsg.go | 16 ++++++++-------- internal/proto/wrapper.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/multimsg.go b/client/multimsg.go index cb56249b..605688ce 100644 --- a/client/multimsg.go +++ b/client/multimsg.go @@ -293,16 +293,16 @@ func (builder *ForwardMessageBuilder) Main(m *message.ForwardMessage) *message.F return nil } content := forwardDisplay(rsp.MsgResid, utils.RandomString(32), m.Preview(), fmt.Sprintf("查看 %d 条转发消息", m.Length())) + bodyHash := md5.Sum(body) + input := highway.Transaction{ + CommandID: 27, + Ticket: rsp.MsgSig, + Body: bytes.NewReader(body), + Sum: bodyHash[:], + Size: int64(len(body)), + } for i, ip := range rsp.Uint32UpIp { addr := highway.Addr{IP: uint32(ip), Port: int(rsp.Uint32UpPort[i])} - hash := md5.Sum(body) - input := highway.Transaction{ - CommandID: 27, - Ticket: rsp.MsgSig, - Body: bytes.NewReader(body), - Sum: hash[:], - Size: int64(len(body)), - } err := c.highwaySession.Upload(addr, input) if err != nil { continue diff --git a/internal/proto/wrapper.go b/internal/proto/wrapper.go index ffb4772e..b71046b5 100644 --- a/internal/proto/wrapper.go +++ b/internal/proto/wrapper.go @@ -7,7 +7,7 @@ import ( ) // TODO: move to a new package -const debug = true +const debug = false type Message = any