4 Commits
Author SHA1 Message Date
zimonianhua 476e42b919 fix(channel): 增加HTTP客户端超时时间并改进SOCKS5代理处理
Publish Docker image (amd64) / Push Docker image to multiple registries (push) Has been cancelled
Publish Docker image (arm64) / Push Docker image to multiple registries (push) Has been cancelled
Linux Release / release (push) Has been cancelled
macOS Release / release (push) Has been cancelled
Windows Release / release (push) Has been cancelled
- 将Telegram和微信企业号通道的HTTP客户端超时统一延长至30秒,避免因网络延迟导致请求失败
- 修复SOCKS5代理连接未正确处理上下文取消的问题,现在支持带认证的SOCKS5代理
- 当无法获取默认HTTP传输时,提供完整的传输配置而非空结构
2026-02-11 11:25:42 +08:00
zimonianhua f395e4c951 build: 将 Docker 镜像源从 justsong 更改为 zimonianhua
更新 docker-compose.yml 和 GitHub Actions 工作流文件中的镜像名称,以使用新的镜像仓库源。
2026-02-11 10:16:21 +08:00
zimonianhua 52b9439a14 build: 升级 Node.js 版本至 18 并启用 corepack
- 将 Docker 基础镜像从 node:16 升级至 node:18。
- 在 Dockerfile 中启用 corepack 并准备指定版本的 yarn。
- 更新所有 GitHub Actions 工作流中的 node-version 为 18。
2026-02-11 10:09:40 +08:00
zimonianhua 3044db38bb ci: 改进版本信息获取以支持无标签提交
修改所有 GitHub Actions 工作流,在检出代码时获取完整历史记录和标签,并将 `git describe` 命令统一添加 `--always` 参数,确保在无标签的提交上也能生成有效的版本信息。
2026-02-11 09:58:46 +08:00
10 changed files with 70 additions and 28 deletions
+6 -3
View File
@@ -19,10 +19,13 @@ jobs:
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Save version info - name: Save version info
run: | run: |
git describe --tags > VERSION git describe --tags --always > VERSION
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v2
@@ -42,7 +45,7 @@ jobs:
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
images: | images: |
justsong/message-pusher zimonianhua/message-pusher
ghcr.io/${{ github.repository }} ghcr.io/${{ github.repository }}
- name: Build and push Docker images - name: Build and push Docker images
@@ -51,4 +54,4 @@ jobs:
context: . context: .
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
+6 -3
View File
@@ -19,10 +19,13 @@ jobs:
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Save version info - name: Save version info
run: | run: |
git describe --tags > VERSION git describe --tags --always > VERSION
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
@@ -48,7 +51,7 @@ jobs:
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
images: | images: |
justsong/message-pusher zimonianhua/message-pusher
ghcr.io/${{ github.repository }} ghcr.io/${{ github.repository }}
- name: Build and push Docker images - name: Build and push Docker images
@@ -58,4 +61,4 @@ jobs:
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
+5 -5
View File
@@ -16,14 +16,14 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags --always) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
@@ -32,12 +32,12 @@ jobs:
- name: Build Backend (amd64) - name: Build Backend (amd64)
run: | run: |
go mod download go mod download
go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)' -extldflags '-static'" -o message-pusher go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)' -extldflags '-static'" -o message-pusher
- name: Build Backend (arm64) - name: Build Backend (arm64)
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu sudo apt-get install gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)' -extldflags '-static'" -o message-pusher-arm64 CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)' -extldflags '-static'" -o message-pusher-arm64
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
@@ -48,4 +48,4 @@ jobs:
draft: true draft: true
generate_release_notes: true generate_release_notes: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+3 -3
View File
@@ -16,14 +16,14 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags --always) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
@@ -32,7 +32,7 @@ jobs:
- name: Build Backend - name: Build Backend
run: | run: |
go mod download go mod download
go build -ldflags "-X 'message-pusher/common.Version=$(git describe --tags)'" -o message-pusher-macos go build -ldflags "-X 'message-pusher/common.Version=$(git describe --tags --always)'" -o message-pusher-macos
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
+4 -4
View File
@@ -19,14 +19,14 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags --always) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
@@ -35,7 +35,7 @@ jobs:
- name: Build Backend - name: Build Backend
run: | run: |
go mod download go mod download
go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)'" -o message-pusher.exe go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)'" -o message-pusher.exe
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
@@ -44,4 +44,4 @@ jobs:
draft: true draft: true
generate_release_notes: true generate_release_notes: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+2 -1
View File
@@ -1,8 +1,9 @@
FROM node:16 as builder FROM node:18 AS builder
WORKDIR /build WORKDIR /build
COPY ./web . COPY ./web .
COPY ./VERSION . COPY ./VERSION .
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
RUN yarn install RUN yarn install
RUN REACT_APP_VERSION=$(cat VERSION) yarn build RUN REACT_APP_VERSION=$(cat VERSION) yarn build
+40 -5
View File
@@ -26,7 +26,17 @@ func newHTTPClient(proxyAddress string, timeout time.Duration) (*http.Client, er
func newHTTPTransport(proxyAddress string) (*http.Transport, error) { func newHTTPTransport(proxyAddress string) (*http.Transport, error) {
base, ok := http.DefaultTransport.(*http.Transport) base, ok := http.DefaultTransport.(*http.Transport)
if !ok { if !ok {
return &http.Transport{}, nil return &http.Transport{
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}, nil
} }
transport := base.Clone() transport := base.Clone()
proxyAddress = strings.TrimSpace(proxyAddress) proxyAddress = strings.TrimSpace(proxyAddress)
@@ -46,15 +56,40 @@ func newHTTPTransport(proxyAddress string) (*http.Transport, error) {
transport.Proxy = http.ProxyURL(u) transport.Proxy = http.ProxyURL(u)
return transport, nil return transport, nil
case "socks5", "socks5h": case "socks5", "socks5h":
normalized := *u var auth *proxy.Auth
normalized.Scheme = "socks5" if u.User != nil {
dialer, err := proxy.FromURL(&normalized, proxy.Direct) auth = &proxy.Auth{
User: u.User.Username(),
Password: "",
}
if password, ok := u.User.Password(); ok {
auth.Password = password
}
}
dialer, err := proxy.SOCKS5("tcp", u.Host, auth, &net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 30 * time.Second,
})
if err != nil { if err != nil {
return nil, err return nil, err
} }
transport.Proxy = nil transport.Proxy = nil
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return dialer.Dial(network, addr) type dialResult struct {
conn net.Conn
err error
}
ch := make(chan dialResult, 1)
go func() {
conn, err := dialer.Dial(network, addr)
ch <- dialResult{conn: conn, err: err}
}()
select {
case <-ctx.Done():
return nil, ctx.Err()
case r := <-ch:
return r.conn, r.err
}
} }
return transport, nil return transport, nil
default: default:
+1 -1
View File
@@ -25,7 +25,7 @@ type telegramMessageResponse struct {
func SendTelegramMessage(message *model.Message, user *model.User, channel_ *model.Channel) error { func SendTelegramMessage(message *model.Message, user *model.User, channel_ *model.Channel) error {
// https://core.telegram.org/bots/api#sendmessage // https://core.telegram.org/bots/api#sendmessage
client, err := newHTTPClient(channel_.URL, 10*time.Second) client, err := newHTTPClient(channel_.URL, 30*time.Second)
if err != nil { if err != nil {
return err return err
} }
+2 -2
View File
@@ -49,7 +49,7 @@ func (i *WeChatCorpAccountTokenStoreItem) Token() string {
func (i *WeChatCorpAccountTokenStoreItem) Refresh() { func (i *WeChatCorpAccountTokenStoreItem) Refresh() {
// https://work.weixin.qq.com/api/doc/90000/90135/91039 // https://work.weixin.qq.com/api/doc/90000/90135/91039
client, err := newHTTPClient(i.Proxy, 5*time.Second) client, err := newHTTPClient(i.Proxy, 30*time.Second)
if err != nil { if err != nil {
common.SysError("failed to create http client: " + err.Error()) common.SysError("failed to create http client: " + err.Error())
return return
@@ -159,7 +159,7 @@ func SendWeChatCorpMessage(message *model.Message, user *model.User, channel_ *m
Proxy: proxyAddress, Proxy: proxyAddress,
} }
accessToken := TokenStoreGetToken(tokenItem.Key()) accessToken := TokenStoreGetToken(tokenItem.Key())
client, err := newHTTPClient(proxyAddress, 10*time.Second) client, err := newHTTPClient(proxyAddress, 30*time.Second)
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -2,7 +2,7 @@ version: "3"
services: services:
message-pusher: message-pusher:
image: justsong/message-pusher image: zimonianhua/message-pusher
restart: unless-stopped restart: unless-stopped
ports: ports:
- 3000:3000 - 3000:3000