Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
476e42b919 | ||
|
|
f395e4c951 | ||
|
|
52b9439a14 | ||
|
|
3044db38bb |
@@ -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 }}
|
||||||
|
|||||||
@@ -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 }}
|
||||||
|
|||||||
@@ -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 }}
|
||||||
|
|||||||
@@ -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/')
|
||||||
|
|||||||
@@ -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
@@ -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
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user