Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ptt #11

Merged
merged 8 commits into from
Aug 5, 2020
Merged

Ptt #11

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Temporary] Changed Dial to TCPDial to prevent useless conversion
  • Loading branch information
LXY1226 committed Aug 2, 2020
commit 53b3f814cf7958dfaa95d54e84e49a9f13db08b6
13 changes: 6 additions & 7 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"math"
"math/rand"
"net"
"strconv"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -339,8 +338,7 @@ func (c *QQClient) sendGroupLongOrForwardMessage(groupCode int64, isLong bool, m
},
})
for i, ip := range rsp.Uint32UpIp {
updServer := binary.UInt32ToIPV4Address(uint32(ip))
err := c.highwayUploadImage(updServer+":"+strconv.FormatInt(int64(rsp.Uint32UpPort[i]), 10), rsp.MsgSig, body, 27)
err := c.highwayUploadImage(uint32(ip), int(rsp.Uint32UpPort[i]), rsp.MsgSig, body, 27)
if err == nil {
if !isLong {
var pv string
Expand Down Expand Up @@ -382,17 +380,18 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.Group
return nil, errors.New(rsp.Message)
}
if rsp.IsExists {
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:]), nil
goto ok
}
for i, ip := range rsp.UploadIp {
updServer := binary.UInt32ToIPV4Address(uint32(ip))
err := c.highwayUploadImage(updServer+":"+strconv.FormatInt(int64(rsp.UploadPort[i]), 10), rsp.UploadKey, img, 2)
err := c.highwayUploadImage(uint32(ip), int(rsp.UploadPort[i]), rsp.UploadKey, img, 2)
if err != nil {
continue
}
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:]), nil
goto ok
}
return nil, errors.New("upload failed")
ok:
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:]), nil
}

func (c *QQClient) UploadPrivateImage(target int64, img []byte) (*message.FriendImageElement, error) {
Expand Down
9 changes: 7 additions & 2 deletions client/highway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (
"time"
)

func (c *QQClient) highwayUploadImage(ser string, updKey, img []byte, cmdId int32) error {
conn, err := net.DialTimeout("tcp", ser, time.Second*5)
func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, cmdId int32) error {
addr := net.TCPAddr{
IP: make([]byte, 4),
Port: port,
}
conn, err := net.DialTCP("tcp", nil, &addr)
println("connected")
if err != nil {
return err
}
Expand Down