mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
[Temporary] Changed Dial to TCPDial to prevent useless conversion
This commit is contained in:
parent
1da6a89f82
commit
53b3f814cf
@ -17,7 +17,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -339,8 +338,7 @@ func (c *QQClient) sendGroupLongOrForwardMessage(groupCode int64, isLong bool, m
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
for i, ip := range rsp.Uint32UpIp {
|
for i, ip := range rsp.Uint32UpIp {
|
||||||
updServer := binary.UInt32ToIPV4Address(uint32(ip))
|
err := c.highwayUploadImage(uint32(ip), int(rsp.Uint32UpPort[i]), rsp.MsgSig, body, 27)
|
||||||
err := c.highwayUploadImage(updServer+":"+strconv.FormatInt(int64(rsp.Uint32UpPort[i]), 10), rsp.MsgSig, body, 27)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !isLong {
|
if !isLong {
|
||||||
var pv string
|
var pv string
|
||||||
@ -382,17 +380,18 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.Group
|
|||||||
return nil, errors.New(rsp.Message)
|
return nil, errors.New(rsp.Message)
|
||||||
}
|
}
|
||||||
if rsp.IsExists {
|
if rsp.IsExists {
|
||||||
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:]), nil
|
goto ok
|
||||||
}
|
}
|
||||||
for i, ip := range rsp.UploadIp {
|
for i, ip := range rsp.UploadIp {
|
||||||
updServer := binary.UInt32ToIPV4Address(uint32(ip))
|
err := c.highwayUploadImage(uint32(ip), int(rsp.UploadPort[i]), rsp.UploadKey, img, 2)
|
||||||
err := c.highwayUploadImage(updServer+":"+strconv.FormatInt(int64(rsp.UploadPort[i]), 10), rsp.UploadKey, img, 2)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:]), nil
|
goto ok
|
||||||
}
|
}
|
||||||
return nil, errors.New("upload failed")
|
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) {
|
func (c *QQClient) UploadPrivateImage(target int64, img []byte) (*message.FriendImageElement, error) {
|
||||||
|
@ -10,8 +10,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *QQClient) highwayUploadImage(ser string, updKey, img []byte, cmdId int32) error {
|
func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, cmdId int32) error {
|
||||||
conn, err := net.DialTimeout("tcp", ser, time.Second*5)
|
addr := net.TCPAddr{
|
||||||
|
IP: make([]byte, 4),
|
||||||
|
Port: port,
|
||||||
|
}
|
||||||
|
conn, err := net.DialTCP("tcp", nil, &addr)
|
||||||
|
println("connected")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user