Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
476e42b919 | ||
|
|
f395e4c951 | ||
|
|
52b9439a14 | ||
|
|
3044db38bb |
@@ -19,10 +19,13 @@ jobs:
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Save version info
|
||||
run: |
|
||||
git describe --tags > VERSION
|
||||
git describe --tags --always > VERSION
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
@@ -42,7 +45,7 @@ jobs:
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
justsong/message-pusher
|
||||
zimonianhua/message-pusher
|
||||
ghcr.io/${{ github.repository }}
|
||||
|
||||
- name: Build and push Docker images
|
||||
@@ -51,4 +54,4 @@ jobs:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -19,10 +19,13 @@ jobs:
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Save version info
|
||||
run: |
|
||||
git describe --tags > VERSION
|
||||
git describe --tags --always > VERSION
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
@@ -48,7 +51,7 @@ jobs:
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
justsong/message-pusher
|
||||
zimonianhua/message-pusher
|
||||
ghcr.io/${{ github.repository }}
|
||||
|
||||
- name: Build and push Docker images
|
||||
@@ -58,4 +61,4 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -16,14 +16,14 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 18
|
||||
- name: Build Frontend
|
||||
env:
|
||||
CI: ""
|
||||
run: |
|
||||
cd web
|
||||
npm install
|
||||
REACT_APP_VERSION=$(git describe --tags) npm run build
|
||||
REACT_APP_VERSION=$(git describe --tags --always) npm run build
|
||||
cd ..
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
@@ -32,12 +32,12 @@ jobs:
|
||||
- name: Build Backend (amd64)
|
||||
run: |
|
||||
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)
|
||||
run: |
|
||||
sudo apt-get update
|
||||
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
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
@@ -48,4 +48,4 @@ jobs:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -16,14 +16,14 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 18
|
||||
- name: Build Frontend
|
||||
env:
|
||||
CI: ""
|
||||
run: |
|
||||
cd web
|
||||
npm install
|
||||
REACT_APP_VERSION=$(git describe --tags) npm run build
|
||||
REACT_APP_VERSION=$(git describe --tags --always) npm run build
|
||||
cd ..
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Build Backend
|
||||
run: |
|
||||
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
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
@@ -19,14 +19,14 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 18
|
||||
- name: Build Frontend
|
||||
env:
|
||||
CI: ""
|
||||
run: |
|
||||
cd web
|
||||
npm install
|
||||
REACT_APP_VERSION=$(git describe --tags) npm run build
|
||||
REACT_APP_VERSION=$(git describe --tags --always) npm run build
|
||||
cd ..
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
- name: Build Backend
|
||||
run: |
|
||||
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
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
@@ -44,4 +44,4 @@ jobs:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
FROM node:16 as builder
|
||||
FROM node:18 AS builder
|
||||
|
||||
WORKDIR /build
|
||||
COPY ./web .
|
||||
COPY ./VERSION .
|
||||
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
|
||||
RUN yarn install
|
||||
RUN REACT_APP_VERSION=$(cat VERSION) yarn build
|
||||
|
||||
|
||||
+40
-5
@@ -26,7 +26,17 @@ func newHTTPClient(proxyAddress string, timeout time.Duration) (*http.Client, er
|
||||
func newHTTPTransport(proxyAddress string) (*http.Transport, error) {
|
||||
base, ok := http.DefaultTransport.(*http.Transport)
|
||||
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()
|
||||
proxyAddress = strings.TrimSpace(proxyAddress)
|
||||
@@ -46,15 +56,40 @@ func newHTTPTransport(proxyAddress string) (*http.Transport, error) {
|
||||
transport.Proxy = http.ProxyURL(u)
|
||||
return transport, nil
|
||||
case "socks5", "socks5h":
|
||||
normalized := *u
|
||||
normalized.Scheme = "socks5"
|
||||
dialer, err := proxy.FromURL(&normalized, proxy.Direct)
|
||||
var auth *proxy.Auth
|
||||
if u.User != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
transport.Proxy = nil
|
||||
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
|
||||
default:
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ type telegramMessageResponse struct {
|
||||
|
||||
func SendTelegramMessage(message *model.Message, user *model.User, channel_ *model.Channel) error {
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (i *WeChatCorpAccountTokenStoreItem) Token() string {
|
||||
|
||||
func (i *WeChatCorpAccountTokenStoreItem) Refresh() {
|
||||
// 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 {
|
||||
common.SysError("failed to create http client: " + err.Error())
|
||||
return
|
||||
@@ -159,7 +159,7 @@ func SendWeChatCorpMessage(message *model.Message, user *model.User, channel_ *m
|
||||
Proxy: proxyAddress,
|
||||
}
|
||||
accessToken := TokenStoreGetToken(tokenItem.Key())
|
||||
client, err := newHTTPClient(proxyAddress, 10*time.Second)
|
||||
client, err := newHTTPClient(proxyAddress, 30*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ version: "3"
|
||||
|
||||
services:
|
||||
message-pusher:
|
||||
image: justsong/message-pusher
|
||||
image: zimonianhua/message-pusher
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 3000:3000
|
||||
|
||||
Reference in New Issue
Block a user