forked from Mrs4s/MiraiGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters