Skip to content

Commit

Permalink
fix: panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Fripine committed Oct 10, 2024
1 parent 874c848 commit c1f5386
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
45 changes: 45 additions & 0 deletions client/highway.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package client

import (
"fmt"

highway2 "github.com/LagrangeDev/LagrangeGo/client/packets/highway"
"github.com/pkg/errors"
"github.com/sealdice/MiraiGo/binary"
)

func (c *QQClient) ensureHighwayServers() error {
if c.highwaySession.SsoAddr == nil || c.highwaySession.SigSession == nil || c.highwaySession.SessionKey == nil {
fmt.Println(c.highwaySession.SsoAddr)
packet, err := highway2.BuildHighWayUrlReq(c.sig.TGT)
if err != nil {
return err
}
payload, err := c.sendAndWaitDynamic(c.uniPacket("HttpConn.0x6ff_501", packet))
if err != nil {
return fmt.Errorf("get highway server: %v", err)
}
resp, err := highway2.ParseHighWayUrlReq(payload)
if err != nil {
return fmt.Errorf("parse highway server: %v", err)
}
c.highwaySession.SigSession = resp.HttpConn.SigSession
c.highwaySession.SessionKey = resp.HttpConn.SessionKey
for _, info := range resp.HttpConn.ServerInfos {
if info.ServiceType != 1 {
continue
}
for _, addr := range info.ServerAddrs {

fmt.Println(fmt.Sprintf("add highway server %s:%d", binary.UInt32ToIPV4Address(addr.IP), addr.Port))
c.highwaySession.AppendAddr(addr.IP, addr.Port)
}
}
}
if c.highwaySession.SsoAddr == nil || c.highwaySession.SigSession == nil || c.highwaySession.SessionKey == nil {
fmt.Println(c.highwaySession.SsoAddr)
fmt.Println("empty highway servers")
return errors.New("empty highway servers")
}
return nil
}
8 changes: 8 additions & 0 deletions client/richmedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (c *QQClient) RecordUploadPrivate(targetUid string, recordRaw *message.Voic
if err != nil {
return nil, err
}
err = c.ensureHighwayServers()
if err != nil {
return nil, err
}
input := highway2.Transaction{
CommandID: 1007,
Body: record.Stream,
Expand Down Expand Up @@ -156,6 +160,10 @@ func (c *QQClient) RecordUploadGroup(groupUin uint32, recordRaw *message.VoiceEl
if err != nil {
return nil, err
}
err = c.ensureHighwayServers()
if err != nil {
return nil, err
}
input := highway2.Transaction{
CommandID: 1008,
Body: record.Stream,
Expand Down

0 comments on commit c1f5386

Please sign in to comment.