mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2026-01-22 23:11:19 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62a22c697d | ||
|
|
be497a5aa7 | ||
|
|
fc3e16bc63 | ||
|
|
df35912461 | ||
|
|
0ddc66a854 | ||
|
|
716d557d66 | ||
|
|
f9edcb9d47 | ||
|
|
d4623c5bc9 | ||
|
|
02ba4a3330 | ||
|
|
a72d4eaf78 | ||
|
|
4d3abb2dc0 | ||
|
|
ad6a8d1f7a | ||
|
|
a5c8c2ac97 | ||
|
|
1237004cb1 | ||
|
|
c2bcd17df7 | ||
|
|
bb49cbdd50 | ||
|
|
6ad770a824 | ||
|
|
593eeb3ac3 | ||
|
|
6a7be3ef84 |
38
.github/workflows/docker.yml
vendored
Normal file
38
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*' # 仅当推送标签(例如 v1.0.0)时触发
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: vars
|
||||||
|
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: lejianwen/rustdesk-api:latest, lejianwen/rustdesk-api:${{ env.TAG }}
|
||||||
27
.github/workflows/go.yml
vendored
Normal file
27
.github/workflows/go.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# This workflow will build a golang project
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
||||||
|
|
||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
- name: mod tidy
|
||||||
|
run: go mod tidy
|
||||||
|
- name: Build
|
||||||
|
run: go build -v -o release/apimain cmd/apimain.go
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v cmd/apimain.go
|
||||||
95
.github/workflows/release.yml
vendored
Normal file
95
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*' # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流
|
||||||
|
#on:
|
||||||
|
# push:
|
||||||
|
# branches: [ "master" ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
goos: [ linux, windows ] # 指定要构建的操作系统
|
||||||
|
goarch: [ amd64 ] # 指定架构
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go environment
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.22' # 选择 Go 版本
|
||||||
|
|
||||||
|
- name: Set up npm
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: install gcc zip musl
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||||
|
sudo apt-get install gcc-mingw-w64-x86-64 zip -y
|
||||||
|
else
|
||||||
|
sudo apt-get install musl musl-dev musl-tools -y
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
- name: build rustdesk-api-web
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/lejianwen/rustdesk-api-web
|
||||||
|
cd rustdesk-api-web
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
mkdir ../resources/admin/ -p
|
||||||
|
cp -ar dist/* ../resources/admin/
|
||||||
|
|
||||||
|
- name: tidy
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
|
||||||
|
- name: swag
|
||||||
|
run: |
|
||||||
|
go install github.com/swaggo/swag/cmd/swag@latest
|
||||||
|
swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin
|
||||||
|
swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api
|
||||||
|
|
||||||
|
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
|
run: |
|
||||||
|
mkdir release -p
|
||||||
|
cp -ar resources release/
|
||||||
|
cp -ar docs release/
|
||||||
|
cp -ar conf release/
|
||||||
|
mkdir -p release/data
|
||||||
|
mkdir -p release/runtime
|
||||||
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||||
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain.exe ./cmd/apimain.go
|
||||||
|
zip -r ${{ matrix.goos}}-${{ matrix.goarch }}.zip ./release
|
||||||
|
else
|
||||||
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CC=musl-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go
|
||||||
|
tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ./release
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
|
path: |
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.zip
|
||||||
|
|
||||||
|
- name: Upload to GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.zip
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -17,11 +17,7 @@ RUN set -eux; \
|
|||||||
swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin; \
|
swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin; \
|
||||||
swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api; \
|
swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api; \
|
||||||
go env -w GO111MODULE=on;\
|
go env -w GO111MODULE=on;\
|
||||||
go env -w CGO_ENABLED=1;\
|
CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go; \
|
||||||
go env -w GOOS=linux;\
|
|
||||||
go env -w GOARCH=amd64;\
|
|
||||||
go env -w CGO_LDFLAGS="-static"; \
|
|
||||||
go build -o release/apimain cmd/apimain.go; \
|
|
||||||
cp -ar resources release/; \
|
cp -ar resources release/; \
|
||||||
mkdir -p release/resources/public; \
|
mkdir -p release/resources/public; \
|
||||||
cp -ar docs release/; \
|
cp -ar docs release/; \
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<img src="https://img.shields.io/badge/gin-v1.9.0-lightBlue"/>
|
<img src="https://img.shields.io/badge/gin-v1.9.0-lightBlue"/>
|
||||||
<img src="https://img.shields.io/badge/gorm-v1.25.7-green"/>
|
<img src="https://img.shields.io/badge/gorm-v1.25.7-green"/>
|
||||||
<img src="https://img.shields.io/badge/swag-v1.16.3-yellow"/>
|
<img src="https://img.shields.io/badge/swag-v1.16.3-yellow"/>
|
||||||
|
<img src="https://github.com/lejianwen/rustdesk-api/actions/workflows/release.yml/badge.svg"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## 使用前准备
|
## 使用前准备
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ func (i *Index) ConfigJs(c *gin.Context) {
|
|||||||
apiServer := global.Config.Rustdesk.ApiServer
|
apiServer := global.Config.Rustdesk.ApiServer
|
||||||
|
|
||||||
tmp := `
|
tmp := `
|
||||||
|
function stringToUint8Array(str){
|
||||||
|
var arr = [];
|
||||||
|
for (var i = 0, j = str.length; i < j; ++i) {
|
||||||
|
arr.push(str.charCodeAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmpUint8Array = new Uint8Array(arr);
|
||||||
|
return tmpUint8Array
|
||||||
|
}
|
||||||
window._gwen = {}
|
window._gwen = {}
|
||||||
window._gwen.kv = {}
|
window._gwen.kv = {}
|
||||||
function getQueryVariable() {
|
function getQueryVariable() {
|
||||||
@@ -53,13 +62,26 @@ const autoWriteServer = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res.data.peers) {
|
if (res.data.peers) {
|
||||||
oldPeers = JSON.parse(localStorage.getItem('peers')) || {}
|
oldPeers = JSON.parse(localStorage.getItem('peers')) || {}
|
||||||
|
let needUpdate = false
|
||||||
Object.keys(res.data.peers).forEach(k => {
|
Object.keys(res.data.peers).forEach(k => {
|
||||||
if(!oldPeers[k]) {
|
if(!oldPeers[k]) {
|
||||||
oldPeers[k] = res.data.peers[k]
|
oldPeers[k] = res.data.peers[k]
|
||||||
|
needUpdate = true
|
||||||
|
}else{
|
||||||
|
oldPeers[k].info = res.data.peers[k].info
|
||||||
}
|
}
|
||||||
|
if (oldPeers[k].info && oldPeers[k].info.hash&&!oldPeers[k].password ) {
|
||||||
|
let p1 = window.atob(oldPeers[k].info.hash)
|
||||||
|
const pwd = stringToUint8Array(p1)
|
||||||
|
oldPeers[k].password = pwd.toString()
|
||||||
|
oldPeers[k].remember = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
localStorage.setItem('peers', JSON.stringify(oldPeers))
|
localStorage.setItem('peers', JSON.stringify(oldPeers))
|
||||||
|
if(needUpdate) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type WebClientPeerInfoPayload struct {
|
|||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
Platform string `json:"platform"`
|
Platform string `json:"platform"`
|
||||||
|
Hash string `json:"hash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wcpp *WebClientPeerPayload) FromAddressBook(a *model.AddressBook) {
|
func (wcpp *WebClientPeerPayload) FromAddressBook(a *model.AddressBook) {
|
||||||
@@ -25,5 +26,6 @@ func (wcpp *WebClientPeerPayload) FromAddressBook(a *model.AddressBook) {
|
|||||||
Username: a.Username,
|
Username: a.Username,
|
||||||
Hostname: a.Hostname,
|
Hostname: a.Hostname,
|
||||||
Platform: a.Platform,
|
Platform: a.Platform,
|
||||||
|
Hash: a.Hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user