Skip to content

Commit

Permalink
chore: upgrade MiraiGo version
Browse files Browse the repository at this point in the history
  • Loading branch information
MisakaTAT committed Oct 10, 2023
2 parents e09a33e + 517d323 commit 9e0f7ec
Show file tree
Hide file tree
Showing 33 changed files with 777 additions and 266 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ body:
label: 使用协议
description: 选择使用的协议
options:
- 0 | iPad
- 0 | Default
- 1 | Android Phone
- 2 | Android Watch
- 3 | MacOS
- 4 | 企点
- 5 | iPad
- 6 | aPad
validations:
required: true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ jobs:
- name: Checkout
run: |
git version
<<<<<<< HEAD
git clone https://github.com/CodeLaboratory/go-cqhttp.git /home/runner/work/go-cqhttp/go-cqhttp
=======
git clone "${{ github.event.repository.html_url }}" /home/runner/work/go-cqhttp/go-cqhttp
git checkout "${{ github.ref }}"
>>>>>>> 517d32395391103dafafb60572530e3f05f29bb3

- name: Set up Go
uses: actions/setup-go@v3
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ RUN chmod +x /docker-entrypoint.sh && \
ffmpeg \
coreutils \
shadow \
su-exec && \
su-exec \
tzdata && \
rm -rf /var/cache/apk/* && \
mkdir -p /app && \
mkdir -p /data && \
Expand Down
50 changes: 0 additions & 50 deletions cmd/gocq/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ package gocq
import (
"bufio"
"bytes"
"encoding/hex"
"fmt"
"image"
"image/png"
"net/http"
"os"
"strings"
"time"

"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/Mrs4s/go-cqhttp/internal/base"
"github.com/mattn/go-colorable"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
"gopkg.ilharper.com/x/isatty"

"github.com/Mrs4s/go-cqhttp/global"
Expand Down Expand Up @@ -264,49 +260,3 @@ func fetchCaptcha(id string) string {
}
return ""
}

func energy(uin uint64, id string, appVersion string, salt []byte) ([]byte, error) {
signServer := base.SignServer
if !strings.HasSuffix(signServer, "/") {
signServer += "/"
}
response, err := download.Request{
Method: http.MethodGet,
URL: signServer + "custom_energy" + fmt.Sprintf("?data=%v&salt=%v", id, hex.EncodeToString(salt)),
}.Bytes()
if err != nil {
log.Warnf("获取T544 sign时出现错误: %v server: %v", err, signServer)
return nil, err
}
data, err := hex.DecodeString(gjson.GetBytes(response, "data").String())
if err != nil {
log.Warnf("获取T544 sign时出现错误: %v", err)
return nil, err
}
if len(data) == 0 {
log.Warnf("获取T544 sign时出现错误: %v", "data is empty")
return nil, errors.New("data is empty")
}
return data, nil
}

func sign(seq uint64, uin string, cmd string, qua string, buff []byte) (sign []byte, extra []byte, token []byte, err error) {
signServer := base.SignServer
if !strings.HasSuffix(signServer, "/") {
signServer += "/"
}
response, err := download.Request{
Method: http.MethodPost,
URL: signServer + "sign",
Header: map[string]string{"Content-Type": "application/x-www-form-urlencoded"},
Body: bytes.NewReader([]byte(fmt.Sprintf("uin=%v&qua=%s&cmd=%s&seq=%v&buffer=%v", uin, qua, cmd, seq, hex.EncodeToString(buff)))),
}.Bytes()
if err != nil {
log.Warnf("获取sso sign时出现错误: %v server: %v", err, signServer)
return nil, nil, nil, err
}
sign, _ = hex.DecodeString(gjson.GetBytes(response, "data.sign").String())
extra, _ = hex.DecodeString(gjson.GetBytes(response, "data.extra").String())
token, _ = hex.DecodeString(gjson.GetBytes(response, "data.token").String())
return sign, extra, token, nil
}
24 changes: 19 additions & 5 deletions cmd/gocq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,27 @@ func LoginInteract() {
log.Fatalf("加载设备信息失败: %v", err)
}
}

if base.SignServer != "-" && base.SignServer != "" {
log.Infof("使用服务器 %s 进行数据包签名", base.SignServer)
signServer, err := getAvaliableSignServer() // 获取可用签名服务器
if err != nil {
log.Warn(err)
}
if signServer != nil && len(signServer.URL) > 1 {
log.Infof("使用签名服务器:%v", signServer.URL)
go signStartRefreshToken(base.Account.RefreshInterval) // 定时刷新 token
wrapper.DandelionEnergy = energy
wrapper.FekitGetSign = sign
if !base.IsBelow110 {
if !base.Account.AutoRegister {
log.Warn("自动注册实例已关闭,请配置 sign-server 端自动注册实例以保持正常签名")
}
if !base.Account.AutoRefreshToken {
log.Info("自动刷新 token 已关闭,token 过期后获取签名时将不会立即尝试刷新获取新 token")
}
} else {
log.Warn("签名服务器版本 <= 1.1.0 ,无法使用刷新 token 等操作,建议使用 1.1.6 版本及以上签名服务器")
}
} else {
log.Warnf("警告: 未配置签名服务器, 这可能会导致登录 45 错误码或发送消息被风控")
log.Warnf("警告: 未配置签名服务器或签名服务器不可用, 这可能会导致登录 45 错误码或发送消息被风控")
}

if base.Account.Encrypt {
Expand Down Expand Up @@ -287,6 +301,7 @@ func LoginInteract() {
cli.Uin = base.Account.Uin
cli.PasswordMd5 = base.PasswordHash
}
download.SetTimeout(time.Duration(base.HTTPTimeout) * time.Second)
if !base.FastStart {
log.Infof("正在检查协议更新...")
currentVersionName := device.Protocol.Version().SortVersionName
Expand Down Expand Up @@ -373,7 +388,6 @@ func LoginInteract() {
})
saveToken()
cli.AllowSlider = true
download.SetTimeout(time.Duration(base.HTTPTimeout) * time.Second) // 在登录完成后设置, 防止在堵塞协议更新
log.Infof("登录成功 欢迎使用: %v", cli.Nickname)
log.Info("开始加载好友列表...")
global.Check(cli.ReloadFriendList(), true)
Expand Down
Loading

0 comments on commit 9e0f7ec

Please sign in to comment.