Skip to content

Commit 4c2b03a

Browse files
committed
chore: make lint happy
1 parent 87a0848 commit 4c2b03a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+146
-145
lines changed

client/album.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"github.com/tidwall/gjson"
1616

1717
"github.com/LagrangeDev/LagrangeGo/client/packets/album"
18-
"github.com/LagrangeDev/LagrangeGo/utils"
1918
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
19+
lgrio "github.com/LagrangeDev/LagrangeGo/utils/io"
2020
)
2121

2222
const TimeLayout = "2006-01-02 15:04:05"
@@ -265,7 +265,7 @@ func (c *QQClient) getGroupAlbumUploadSession(param *uploadSessionParam) (*uploa
265265
}
266266

267267
func (c *QQClient) uploadGroupAlbumBlock(typ uploadTypeParam, session string, seq, offset, chunkSize, totalSize, gtk int, chunk []byte, latest bool) (rsp *uploadBlockRsp, err error) {
268-
uploadURLCmd := utils.Ternary[string](typ.ResourceType == ResourceTypeVideo, "FileUploadVideo", "FileUpload")
268+
uploadURLCmd := lgrio.Ternary[string](typ.ResourceType == ResourceTypeVideo, "FileUploadVideo", "FileUpload")
269269
body := &bytes.Buffer{}
270270
writer := multipart.NewWriter(body)
271271
_ = writer.WriteField("uin", strconv.Itoa(int(c.Uin)))
@@ -326,7 +326,7 @@ func (c *QQClient) uploadGroupAlbumBlock(typ uploadTypeParam, session string, se
326326
}
327327

328328
func (c *QQClient) doUploadGroupAlbumBlock(uos *uploadOptions, usp *uploadSessionParam, file io.ReadSeeker) (rsp *uploadBlockRsp, err error) {
329-
defer utils.CloseIO(file)
329+
defer lgrio.CloseIO(file)
330330
offset, seq, latest := 0, 0, false
331331
chunk := make([]byte, uos.BlockSize)
332332
for {

client/auth/device.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"os"
77
"strconv"
88

9-
"github.com/LagrangeDev/LagrangeGo/utils"
109
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
10+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1111
"github.com/LagrangeDev/LagrangeGo/utils/platform"
1212
)
1313

@@ -20,8 +20,8 @@ type DeviceInfo struct {
2020

2121
func NewDeviceInfo(uin int) *DeviceInfo {
2222
return &DeviceInfo{
23-
GUID: fmt.Sprintf("%X", crypto.MD5Digest(utils.S2B(strconv.Itoa(uin)))),
24-
DeviceName: fmt.Sprintf("Lagrange-%X", crypto.MD5Digest(utils.S2B(strconv.Itoa(uin)))[0:4]),
23+
GUID: fmt.Sprintf("%X", crypto.MD5Digest(io.S2B(strconv.Itoa(uin)))),
24+
DeviceName: fmt.Sprintf("Lagrange-%X", crypto.MD5Digest(io.S2B(strconv.Itoa(uin)))[0:4]),
2525
SystemKernel: fmt.Sprintf("%s %s", platform.System(), platform.Version()),
2626
KernelVersion: platform.Version(),
2727
}

client/client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"github.com/LagrangeDev/LagrangeGo/client/packets/tlv"
1616
"github.com/LagrangeDev/LagrangeGo/client/packets/wtlogin"
1717
"github.com/LagrangeDev/LagrangeGo/client/packets/wtlogin/qrcodestate"
18-
"github.com/LagrangeDev/LagrangeGo/utils"
1918
"github.com/LagrangeDev/LagrangeGo/utils/binary"
19+
lgrio "github.com/LagrangeDev/LagrangeGo/utils/io"
2020
)
2121

2222
func (c *QQClient) TokenLogin() (*LoginResponse, error) {
@@ -80,10 +80,10 @@ func (c *QQClient) FetchQRCode(size, margin, ecLevel uint32) ([]byte, string, er
8080
WriteU8(0).
8181
WriteTLV(
8282
tlv.T16(c.Version().AppID, c.Version().AppIDQrcode,
83-
utils.MustParseHexStr(c.Device().GUID), c.Version().PTVersion, c.Version().PackageName),
83+
lgrio.MustParseHexStr(c.Device().GUID), c.Version().PTVersion, c.Version().PackageName),
8484
tlv.T1b(0, 0, size, margin, 72, ecLevel, 2),
8585
tlv.T1d(c.Version().MiscBitmap),
86-
tlv.T33(utils.MustParseHexStr(c.Device().GUID)),
86+
tlv.T33(lgrio.MustParseHexStr(c.Device().GUID)),
8787
tlv.T35(c.Version().PTOSVersion),
8888
tlv.T66(c.Version().PTOSVersion),
8989
tlv.Td1(c.Version().OS, c.Device().DeviceName),
@@ -106,7 +106,7 @@ func (c *QQClient) FetchQRCode(size, margin, ecLevel uint32) ([]byte, string, er
106106
// 这样是不对的,调试后发现应该丢一个字节,然后读下一个字节才是数据的大小
107107
// string(binary.NewReader(tlvs[209]).ReadBytesWithLength("u16", true))
108108
urlreader.ReadU8()
109-
return tlvs[0x17], utils.B2S(urlreader.ReadBytesWithLength("u8", false)), nil
109+
return tlvs[0x17], lgrio.B2S(urlreader.ReadBytesWithLength("u8", false)), nil
110110
}
111111

112112
return nil, "", fmt.Errorf("err qr retcode %d", retCode)
@@ -285,7 +285,7 @@ func (c *QQClient) NewDeviceVerify(verifyURL string) error {
285285
query := func() []byte {
286286
data, _ := json.Marshal(&NTNewDeviceQrCodeQuery{
287287
Uint32Flag: 0,
288-
Token: base64.StdEncoding.EncodeToString(utils.S2B(original)),
288+
Token: base64.StdEncoding.EncodeToString(lgrio.S2B(original)),
289289
})
290290
return data
291291
}()
@@ -310,7 +310,7 @@ func (c *QQClient) NewDeviceVerify(verifyURL string) error {
310310
continue
311311
}
312312
if resp.StrNtSuccToken != "" {
313-
c.transport.Sig.TempPwd = utils.S2B(resp.StrNtSuccToken)
313+
c.transport.Sig.TempPwd = lgrio.S2B(resp.StrNtSuccToken)
314314
data, err := buildNtloginRequest(c.Uin, c.Version(), c.Device(), &c.transport.Sig, c.transport.Sig.TempPwd)
315315
if err != nil {
316316
return err
@@ -349,7 +349,7 @@ func (c *QQClient) QRCodeLogin() (*LoginResponse, error) {
349349
tlv.T144(c.transport.Sig.Tgtgt, app, device),
350350
tlv.T116(app.SubSigmap),
351351
tlv.T142(app.PackageName, 0),
352-
tlv.T145(utils.MustParseHexStr(device.GUID)),
352+
tlv.T145(lgrio.MustParseHexStr(device.GUID)),
353353
tlv.T18(0, app.AppClientVersion, int(c.Uin), 0, 5, 0),
354354
tlv.T141([]byte("Unknown"), nil),
355355
tlv.T177(app.WTLoginSDK, 0),

client/event/group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"regexp"
77

88
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/message"
9-
"github.com/LagrangeDev/LagrangeGo/utils"
9+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1010
)
1111

1212
type (
@@ -234,7 +234,7 @@ func ParseMemberIncreaseEvent(event *message.GroupChange) *GroupMemberIncrease {
234234
GroupUin: event.GroupUin,
235235
UserUID: event.MemberUid,
236236
},
237-
InvitorUID: utils.B2S(event.Operator),
237+
InvitorUID: io.B2S(event.Operator),
238238
JoinType: event.IncreaseType,
239239
}
240240
}
@@ -250,7 +250,7 @@ func ParseMemberDecreaseEvent(event *message.GroupChange) *GroupMemberDecrease {
250250
GroupUin: event.GroupUin,
251251
UserUID: event.MemberUid,
252252
},
253-
OperatorUID: utils.B2S(event.Operator),
253+
OperatorUID: io.B2S(event.Operator),
254254
ExitType: event.DecreaseType,
255255
}
256256
}

client/highway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
hw "github.com/LagrangeDev/LagrangeGo/client/internal/highway"
1616
highway2 "github.com/LagrangeDev/LagrangeGo/client/packets/highway"
1717
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/highway"
18-
"github.com/LagrangeDev/LagrangeGo/utils"
1918
"github.com/LagrangeDev/LagrangeGo/utils/binary"
2019
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
20+
lgrio "github.com/LagrangeDev/LagrangeGo/utils/io"
2121
)
2222

2323
func (c *QQClient) ensureHighwayServers() error {
@@ -54,7 +54,7 @@ func (c *QQClient) ensureHighwayServers() error {
5454

5555
func (c *QQClient) highwayUpload(commonID int, r io.Reader, fileSize uint64, md5 []byte, extendInfo []byte) error {
5656
// 能close的io就close
57-
defer utils.CloseIO(r)
57+
defer lgrio.CloseIO(r)
5858
err := c.ensureHighwayServers()
5959
if err != nil {
6060
return err

client/internal/network/transport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
"github.com/LagrangeDev/LagrangeGo/client/auth"
1111
"github.com/LagrangeDev/LagrangeGo/internal/proto"
12-
"github.com/LagrangeDev/LagrangeGo/utils"
1312
"github.com/LagrangeDev/LagrangeGo/utils/binary"
13+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1414
)
1515

1616
// Transport is a network transport.
@@ -23,7 +23,7 @@ type Transport struct {
2323
// PackPacket packs a packet.
2424
func (t *Transport) PackPacket(req *Request) []byte {
2525
head := proto.DynamicMessage{
26-
15: utils.NewTrace(),
26+
15: io.NewTrace(),
2727
16: t.Sig.UID,
2828
}
2929

@@ -44,7 +44,7 @@ func (t *Transport) PackPacket(req *Request) []byte {
4444
WritePacketBytes(t.Sig.Tgt, "u32", true).
4545
WritePacketString(req.CommandName, "u32", true).
4646
WritePacketBytes(nil, "u32", true).
47-
WritePacketBytes(utils.MustParseHexStr(t.Device.GUID), "u32", true).
47+
WritePacketBytes(io.MustParseHexStr(t.Device.GUID), "u32", true).
4848
WritePacketBytes(nil, "u32", true).
4949
WritePacketString(t.Version.CurrentVersion, "u16", true).
5050
WritePacketBytes(head.Encode(), "u32", true).

client/listener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/system"
1212
"github.com/LagrangeDev/LagrangeGo/internal/proto"
1313
msgConverter "github.com/LagrangeDev/LagrangeGo/message"
14-
"github.com/LagrangeDev/LagrangeGo/utils"
1514
"github.com/LagrangeDev/LagrangeGo/utils/binary"
15+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1616
)
1717

1818
// decoders https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/client.go#L150
@@ -94,7 +94,7 @@ func decodeOlPushServicePacket(c *QQClient, pkt *network.Packet) (any, error) {
9494
if err != nil {
9595
return nil, err
9696
}
97-
pb.Operator = utils.S2B(Operator.OperatorField1.OperatorUid)
97+
pb.Operator = io.S2B(Operator.OperatorField1.OperatorUid)
9898
}
9999
ev := eventConverter.ParseMemberDecreaseEvent(&pb)
100100
_ = c.ResolveUin(ev)

client/message.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/action"
99
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/message"
1010
message2 "github.com/LagrangeDev/LagrangeGo/message"
11-
"github.com/LagrangeDev/LagrangeGo/utils"
1211
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
12+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1313
)
1414

1515
func (c *QQClient) SendRawMessage(route *message.RoutingHead, body *message.MessageBody, random uint32) (*action.SendMessageResponse, uint32, error) {
@@ -27,7 +27,7 @@ func (c *QQClient) SendRawMessage(route *message.RoutingHead, body *message.Mess
2727
}
2828
// grp_id not null
2929
if (route.Grp != nil && route.Grp.GroupCode.IsSome()) || (route.GrpTmp != nil && route.GrpTmp.GroupUin.IsSome()) {
30-
msg.Ctrl = &message.MessageControl{MsgFlag: int32(utils.TimeStamp())}
30+
msg.Ctrl = &message.MessageControl{MsgFlag: int32(io.TimeStamp())}
3131
}
3232

3333
data, err := proto.Marshal(msg)
@@ -156,17 +156,17 @@ func (c *QQClient) BuildFakeMessage(msgElems []*message2.ForwardNode) []*message
156156
FromUin: elem.SenderID,
157157
},
158158
ContentHead: &message.ContentHead{
159-
Type: utils.Ternary[uint32](elem.GroupID != 0, 82, 9),
159+
Type: io.Ternary[uint32](elem.GroupID != 0, 82, 9),
160160
MsgId: proto.Uint32(crypto.RandU32()),
161161
Sequence: proto.Uint32(crypto.RandU32()),
162-
TimeStamp: proto.Uint32(uint32(utils.TimeStamp())),
162+
TimeStamp: proto.Uint32(uint32(io.TimeStamp())),
163163
Field7: proto.Uint64(1),
164164
Field8: proto.Uint32(0),
165165
Field9: proto.Uint32(0),
166166
Foward: &message.ForwardHead{
167167
Field1: proto.Uint32(0),
168168
Field2: proto.Uint32(0),
169-
Field3: proto.Uint32(utils.Ternary[uint32](elem.GroupID != 0, 0, 2)),
169+
Field3: proto.Uint32(io.Ternary[uint32](elem.GroupID != 0, 0, 2)),
170170
UnknownBase64: proto.String(avatar),
171171
Avatar: proto.String(avatar),
172172
},

client/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/LagrangeDev/LagrangeGo/client/internal/network"
1515
"github.com/LagrangeDev/LagrangeGo/client/internal/oicq"
1616
"github.com/LagrangeDev/LagrangeGo/message"
17-
"github.com/LagrangeDev/LagrangeGo/utils"
17+
nwutils "github.com/LagrangeDev/LagrangeGo/utils/network"
1818
)
1919

2020
// ConnectionQualityInfo 客户端连接质量测试结果
@@ -59,10 +59,10 @@ func (c *QQClient) ConnectionQualityTest() *ConnectionQualityInfo {
5959
}()
6060
go func() {
6161
defer wg.Done()
62-
res := utils.RunTCPPingLoop(currentServerAddr, 10)
62+
res := nwutils.RunTCPPingLoop(currentServerAddr, 10)
6363
r.ChatServerPacketLoss = res.PacketsLoss
6464
if c.highwaySession.AddrLength() > 0 {
65-
res = utils.RunTCPPingLoop(c.highwaySession.SsoAddr[0].String(), 10)
65+
res = nwutils.RunTCPPingLoop(c.highwaySession.SsoAddr[0].String(), 10)
6666
r.SrvServerPacketLoss = res.PacketsLoss
6767
}
6868
}()

client/ntlogin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/LagrangeDev/LagrangeGo/client/packets/pb/login"
1212
"github.com/LagrangeDev/LagrangeGo/client/packets/wtlogin/loginstate"
1313
"github.com/LagrangeDev/LagrangeGo/internal/proto"
14-
"github.com/LagrangeDev/LagrangeGo/utils"
1514
"github.com/LagrangeDev/LagrangeGo/utils/binary"
1615
"github.com/LagrangeDev/LagrangeGo/utils/crypto"
16+
"github.com/LagrangeDev/LagrangeGo/utils/io"
1717
)
1818

1919
func buildPasswordLoginRequest(uin uint32, app *auth.AppInfo, device *auth.DeviceInfo, sig *auth.SigInfo, passwordMD5 [16]byte) ([]byte, error) {
@@ -32,14 +32,14 @@ func buildPasswordLoginRequest(uin uint32, app *auth.AppInfo, device *auth.Devic
3232
WriteU32(8001).
3333
WriteU32(0).
3434
WriteU32(uin).
35-
WriteU32(uint32(utils.TimeStamp())).
35+
WriteU32(uint32(io.TimeStamp())).
3636
WriteU32(0).
3737
WriteU8(1).
3838
WriteBytes(passwordMD5[:]).
3939
WriteBytes(crypto.RandomBytes(16)).
4040
WriteU32(0).
4141
WriteU8(1).
42-
WriteBytes(utils.MustParseHexStr(device.GUID)).
42+
WriteBytes(io.MustParseHexStr(device.GUID)).
4343
WriteU32(1).
4444
WriteU32(1).
4545
WritePacketString(strconv.Itoa(int(uin)), "u16", false).
@@ -61,7 +61,7 @@ func buildNtloginRequest(uin uint32, app *auth.AppInfo, device *auth.DeviceInfo,
6161
OS: proto.Some(app.OS),
6262
DeviceName: proto.Some(device.DeviceName),
6363
Type: int32(app.NTLoginType),
64-
Guid: utils.MustParseHexStr(device.GUID),
64+
Guid: io.MustParseHexStr(device.GUID),
6565
},
6666
Version: &login.SsoNTLoginVersion{
6767
KernelVersion: proto.Some(device.KernelVersion),

0 commit comments

Comments
 (0)