mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
Revert "SpeedUP Rand"
This commit is contained in:
parent
340977eb20
commit
ecd5a7b430
@ -2,11 +2,9 @@ package binary
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
//"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func xorQ(a, b []byte, c []byte) { // MAGIC
|
func xorQ(a, b []byte, c []byte) { // MAGIC
|
||||||
|
@ -99,58 +99,6 @@ func BenchmarkTEAde16(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkTEAen200(b *testing.B) {
|
|
||||||
data := make([]byte, 200)
|
|
||||||
_, err := rand.Read(data)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
testTEA.Encrypt(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkTEAde200(b *testing.B) {
|
|
||||||
data := make([]byte, 200)
|
|
||||||
_, err := rand.Read(data)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
data = testTEA.Encrypt(data)
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
testTEA.Decrypt(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkTEAen200M(b *testing.B) {
|
|
||||||
b.RunParallel(func(pb *testing.PB) {
|
|
||||||
data := make([]byte, 200)
|
|
||||||
_, err := rand.Read(data)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
for pb.Next() {
|
|
||||||
testTEA.Encrypt(data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkTEAde200M(b *testing.B) {
|
|
||||||
b.RunParallel(func(pb *testing.PB) {
|
|
||||||
data := make([]byte, 200)
|
|
||||||
_, err := rand.Read(data)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
data = testTEA.Encrypt(data)
|
|
||||||
for pb.Next() {
|
|
||||||
testTEA.Decrypt(data)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkTEAen256(b *testing.B) {
|
func BenchmarkTEAen256(b *testing.B) {
|
||||||
data := make([]byte, 256)
|
data := make([]byte, 256)
|
||||||
_, err := rand.Read(data)
|
_, err := rand.Read(data)
|
||||||
|
@ -3,10 +3,11 @@ package client
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
@ -15,8 +16,6 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x352"
|
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x352"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
|
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
"github.com/Mrs4s/MiraiGo/protocol/crypto"
|
"github.com/Mrs4s/MiraiGo/protocol/crypto"
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary/jce"
|
"github.com/Mrs4s/MiraiGo/binary/jce"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
@ -149,9 +149,9 @@ var decoders = map[string]func(*QQClient, uint16, []byte) (interface{}, error){
|
|||||||
"PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500": decodePrivatePttStoreResponse,
|
"PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500": decodePrivatePttStoreResponse,
|
||||||
}
|
}
|
||||||
|
|
||||||
//func init() {
|
func init() {
|
||||||
// rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
//}
|
}
|
||||||
|
|
||||||
// NewClient create new qq client
|
// NewClient create new qq client
|
||||||
func NewClient(uin int64, password string) *QQClient {
|
func NewClient(uin int64, password string) *QQClient {
|
||||||
@ -167,7 +167,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
|||||||
OutGoingPacketSessionId: []byte{0x02, 0xB0, 0x5B, 0x8B},
|
OutGoingPacketSessionId: []byte{0x02, 0xB0, 0x5B, 0x8B},
|
||||||
sigInfo: &loginSigInfo{},
|
sigInfo: &loginSigInfo{},
|
||||||
requestPacketRequestId: 1921334513,
|
requestPacketRequestId: 1921334513,
|
||||||
groupSeq: rand.Int31n(20000),
|
groupSeq: int32(rand.Intn(20000)),
|
||||||
friendSeq: 22911,
|
friendSeq: 22911,
|
||||||
highwayApplyUpSeq: 77918,
|
highwayApplyUpSeq: 77918,
|
||||||
ksid: []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", SystemDeviceInfo.IMEI)),
|
ksid: []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", SystemDeviceInfo.IMEI)),
|
||||||
|
@ -6,13 +6,14 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/binary/jce"
|
"github.com/Mrs4s/MiraiGo/binary/jce"
|
||||||
devinfo "github.com/Mrs4s/MiraiGo/client/pb"
|
devinfo "github.com/Mrs4s/MiraiGo/client/pb"
|
||||||
@ -367,11 +368,11 @@ func GenIMEI() string {
|
|||||||
sum := 0 // the control sum of digits
|
sum := 0 // the control sum of digits
|
||||||
var final strings.Builder
|
var final strings.Builder
|
||||||
|
|
||||||
//randSrc := rand.NewSource(time.Now().UnixNano())
|
randSrc := rand.NewSource(time.Now().UnixNano())
|
||||||
//randGen := rand.New(randSrc)
|
randGen := rand.New(randSrc)
|
||||||
|
|
||||||
for i := 0; i < 14; i++ { // generating all the base digits
|
for i := 0; i < 14; i++ { // generating all the base digits
|
||||||
toAdd := rand.Intn(10)
|
toAdd := randGen.Intn(10)
|
||||||
if (i+1)%2 == 0 { // special proc for every 2nd one
|
if (i+1)%2 == 0 { // special proc for every 2nd one
|
||||||
toAdd *= 2
|
toAdd *= 2
|
||||||
if toAdd >= 10 {
|
if toAdd >= 10 {
|
||||||
|
@ -3,7 +3,6 @@ package client
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/longmsg"
|
"github.com/Mrs4s/MiraiGo/client/pb/longmsg"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/multimsg"
|
"github.com/Mrs4s/MiraiGo/client/pb/multimsg"
|
||||||
@ -14,6 +13,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
"math"
|
"math"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ func (c *QQClient) GetAtAllRemain(groupCode int64) (*AtAllRemainInfo, error) {
|
|||||||
|
|
||||||
func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.SendingMessage) *message.GroupMessage {
|
func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.SendingMessage) *message.GroupMessage {
|
||||||
eid := utils.RandomString(6)
|
eid := utils.RandomString(6)
|
||||||
mr := rand.Int31()
|
mr := int32(rand.Uint32())
|
||||||
ch := make(chan int32)
|
ch := make(chan int32)
|
||||||
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
||||||
if e.Rand == mr && !utils.IsChanClosed(ch) {
|
if e.Rand == mr && !utils.IsChanClosed(ch) {
|
||||||
@ -113,7 +113,7 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
|||||||
}
|
}
|
||||||
return ok || ok2 || ok3
|
return ok || ok2 || ok3
|
||||||
}) {
|
}) {
|
||||||
div := rand.Int31()
|
div := int32(rand.Uint32())
|
||||||
fragmented := m.ToFragmented()
|
fragmented := m.ToFragmented()
|
||||||
for i, elems := range fragmented {
|
for i, elems := range fragmented {
|
||||||
_, pkt := c.buildGroupSendingPacket(groupCode, mr, int32(len(fragmented)), int32(i), div, forward, elems)
|
_, pkt := c.buildGroupSendingPacket(groupCode, mr, int32(len(fragmented)), int32(i), div, forward, elems)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
"github.com/Mrs4s/MiraiGo/protocol/packets"
|
"github.com/Mrs4s/MiraiGo/protocol/packets"
|
||||||
|
1
go.mod
1
go.mod
@ -3,7 +3,6 @@ module github.com/Mrs4s/MiraiGo
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/LXY1226/fastrand v0.0.0-20210121160840-7a3db3e79031
|
|
||||||
github.com/golang/protobuf v1.4.3
|
github.com/golang/protobuf v1.4.3
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
2
go.sum
2
go.sum
@ -1,7 +1,5 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/LXY1226/fastrand v0.0.0-20210121160840-7a3db3e79031 h1:DnoCySrXUFvtngW2kSkuBeZoPfvOgctJXjTulCn7eV0=
|
|
||||||
github.com/LXY1226/fastrand v0.0.0-20210121160840-7a3db3e79031/go.mod h1:mEFi4jHUsE2sqQGSJ7eQfXnO8esMzEYcftiCGG+L/OE=
|
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package tlv
|
package tlv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package tlv
|
|||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
binary2 "encoding/binary"
|
binary2 "encoding/binary"
|
||||||
rand "github.com/LXY1226/fastrand"
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user