Skip to content

Commit 9cdcf77

Browse files
fit2botLeeEirc
andauthored
perf: update api and deps (#58)
* perf: update api and deps * perf: fix status * perf: update json date * perf: add Dockerfile --------- Co-authored-by: Eric <xplzv@126.com>
1 parent 94f1656 commit 9cdcf77

23 files changed

Lines changed: 3579 additions & 1767 deletions

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
vendor
2+
build/*
3+
logs/*
4+
data/*
5+
release/*
6+
node_modules/
7+
Dockerfile

.github/workflows/build-image.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to build'
10+
required: true
11+
default: 'latest'
12+
type: string
13+
14+
15+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
21+
jobs:
22+
build-and-push-image:
23+
runs-on: ubuntu-latest
24+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
25+
permissions:
26+
contents: read
27+
packages: write
28+
attestations: write
29+
id-token: write
30+
#
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
- name: Extract metadata (tags, labels) for Docker
46+
id: meta
47+
uses: docker/metadata-action@v5
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
tags: |
51+
type=raw, value=${{ inputs.tag }}
52+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
53+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
54+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
55+
- name: Build and push Docker image
56+
id: push
57+
uses: docker/build-push-action@v6
58+
with:
59+
platforms: linux/amd64,linux/arm64
60+
context: .
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
prerelease: false
4040
- uses: actions/setup-go@v2
4141
with:
42-
go-version: '1.23.x' # The Go version to download (if necessary) and use.
42+
go-version: 'stable' # The Go version to download (if necessary) and use.
4343
- name: Make Build
4444
id: make_build
4545
env:

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM golang:1.24-bullseye AS stage-build
2+
ARG TARGETARCH
3+
ENV CGO_ENABLED=0
4+
ENV GO111MODULE=on
5+
6+
WORKDIR /opt/wisp
7+
8+
COPY go.mod go.sum ./
9+
10+
RUN go mod download -x
11+
12+
COPY . .
13+
14+
RUN make build
15+
16+
FROM debian:bullseye-slim
17+
18+
ARG TARGETARCH
19+
ENV LANG=en_US.UTF-8
20+
ARG APT_MIRROR=http://deb.debian.org
21+
ARG DEPENDENCIES=" \
22+
bash-completion \
23+
jq \
24+
less \
25+
ca-certificates"
26+
27+
RUN set -ex \
28+
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
29+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
30+
&& apt-get update \
31+
&& apt-get install -y --no-install-recommends ${DEPENDENCIES} \
32+
&& apt-get clean all \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
WORKDIR /opt/wisp
36+
37+
COPY --from=stage-build /opt/wisp/build/wisp .
38+
39+
CMD ["./wisp"]

cmd/common/beat_service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ func (b *BeatService) KeepCheckTokens() {
176176
sessions := b.GetSessions()
177177
tokens := make(map[string]model.TokenCheckStatus, len(sessions))
178178
for _, s := range sessions {
179+
if s.TokenId == "" {
180+
logger.Infof("Check session %s token id empty", s.ID)
181+
continue
182+
}
179183
ret, ok := tokens[s.TokenId]
180184
if ok {
181185
b.handleTokenCheck(s, &ret)

cmd/impl/convert_model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
)
88

99
var modelLoginFrom = map[pb.Session_LoginFrom]model.LabelField{
10-
pb.Session_WT: model.LoginFromWT,
11-
pb.Session_ST: model.LoginFromST,
10+
pb.Session_WT: model.LoginFromWeb,
11+
pb.Session_ST: model.LoginFromSSH,
1212
pb.Session_RT: model.LoginFromRT,
1313
pb.Session_DT: model.LoginFromDT,
1414
}

cmd/impl/convert_pb.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ func ConvertToPbLoginFrom(s model.LabelField) pb.Session_LoginFrom {
198198
}
199199

200200
var pbLoginFrom = map[model.LabelField]pb.Session_LoginFrom{
201-
model.LoginFromWT: pb.Session_WT,
202-
model.LoginFromST: pb.Session_ST,
203-
model.LoginFromRT: pb.Session_RT,
204-
model.LoginFromDT: pb.Session_DT,
201+
model.LoginFromWeb: pb.Session_WT,
202+
model.LoginFromSSH: pb.Session_ST,
203+
model.LoginFromRT: pb.Session_RT,
204+
model.LoginFromDT: pb.Session_DT,
205205
}
206206

207207
func ConvertToPbTicketInfo(info *model.TicketInfo) *pb.TicketInfo {

cmd/impl/jms_chat.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package impl
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
7+
"github.com/jumpserver/wisp/pkg/logger"
8+
pb "github.com/jumpserver/wisp/protobuf-go/protobuf"
9+
"google.golang.org/protobuf/types/known/structpb"
10+
)
11+
12+
func (j *JMServer) GetAccountChat(ctx context.Context, req *pb.Empty) (*pb.AccountDetailResponse, error) {
13+
var (
14+
status pb.Status
15+
)
16+
accountChatDetail, err := j.apiClient.GetAccountsChat()
17+
if err != nil {
18+
logger.Errorf("GetAccountChat: %v", err)
19+
status.Err = err.Error()
20+
return &pb.AccountDetailResponse{
21+
Status: &status,
22+
}, nil
23+
}
24+
var m map[string]any
25+
jsonBytes, err := json.Marshal(accountChatDetail)
26+
if err != nil {
27+
logger.Errorf("Encode accountChatDetail failed: %v", err)
28+
status.Err = err.Error()
29+
return &pb.AccountDetailResponse{
30+
Status: &status,
31+
}, nil
32+
}
33+
if err = json.Unmarshal(jsonBytes, &m); err != nil {
34+
logger.Errorf("Unmarshal to map failed: %v", err)
35+
status.Err = err.Error()
36+
return &pb.AccountDetailResponse{
37+
Status: &status,
38+
}, nil
39+
}
40+
st, err1 := structpb.NewStruct(m)
41+
if err1 != nil {
42+
status.Err = err1.Error()
43+
return &pb.AccountDetailResponse{
44+
Status: &status,
45+
}, nil
46+
}
47+
status.Ok = true
48+
return &pb.AccountDetailResponse{Status: &status, Payload: st}, nil
49+
}

docker-compose.yaml.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "3.0"
2+
3+
networks:
4+
wisp:
5+
driver: bridge
6+
7+
services:
8+
wisp:
9+
image: ghcr.io/jumpserver/wisp:latest
10+
container_name: jms_wisp
11+
ports:
12+
- "9090:9090"
13+
environment:
14+
LOG_LEVEL: DEBUG
15+
CORE_HOST: http://docker.host.internal:8080
16+
BOOTSTRAP_TOKEN: PleaseChangeMe
17+
networks:
18+
- guacd
19+
restart: always
20+
volumes:
21+
- ./data/:/opt/wisp/data/:rw # /opt/wisp/-> 本地项目路径, 修改 ./data 目录权限为777

go.mod

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
module github.com/jumpserver/wisp
22

3-
go 1.23
3+
go 1.24.6
44

55
require (
6-
github.com/Azure/azure-storage-blob-go v0.14.0
7-
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
6+
github.com/Azure/azure-storage-blob-go v0.15.0
7+
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
88
github.com/aws/aws-sdk-go v1.44.306
99
github.com/elastic/go-elasticsearch/v6 v6.8.5
1010
github.com/elastic/go-elasticsearch/v8 v8.14.0
1111
github.com/gorilla/websocket v1.5.3
12-
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.12+incompatible
13-
github.com/jumpserver-dev/sdk-go v0.0.0-20250708045559-e0977dde0649
14-
github.com/sirupsen/logrus v1.8.1
15-
github.com/spf13/cobra v1.6.1
16-
github.com/spf13/viper v1.14.0
17-
golang.org/x/crypto v0.27.0
12+
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible
13+
github.com/jumpserver-dev/sdk-go v0.0.0-20250925081620-d22b2b8e24d1
14+
github.com/sirupsen/logrus v1.9.3
15+
github.com/spf13/cobra v1.10.1
16+
github.com/spf13/viper v1.21.0
17+
golang.org/x/crypto v0.42.0
1818
google.golang.org/grpc v1.65.0
1919
google.golang.org/protobuf v1.34.2
2020
gopkg.in/natefinch/lumberjack.v2 v2.2.1
@@ -25,40 +25,35 @@ require (
2525
github.com/LeeEirc/httpsig v1.2.1 // indirect
2626
github.com/dlclark/regexp2 v1.11.4 // indirect
2727
github.com/elastic/elastic-transport-go/v8 v8.6.0 // indirect
28-
github.com/fsnotify/fsnotify v1.6.0 // indirect
28+
github.com/fsnotify/fsnotify v1.9.0 // indirect
2929
github.com/go-logr/logr v1.4.1 // indirect
3030
github.com/go-logr/stdr v1.2.2 // indirect
3131
github.com/go-ole/go-ole v1.2.6 // indirect
32+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
3233
github.com/google/uuid v1.6.0 // indirect
33-
github.com/hashicorp/hcl v1.0.0 // indirect
3434
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3535
github.com/jmespath/go-jmespath v0.4.0 // indirect
3636
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
37-
github.com/magiconair/properties v1.8.6 // indirect
3837
github.com/mattn/go-ieproxy v0.0.1 // indirect
39-
github.com/mitchellh/mapstructure v1.5.0 // indirect
40-
github.com/pelletier/go-toml v1.9.5 // indirect
41-
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
38+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
4239
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
40+
github.com/sagikazarmark/locafero v0.12.0 // indirect
4341
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
4442
github.com/shoenig/go-m1cpu v0.1.6 // indirect
45-
github.com/spf13/afero v1.9.3 // indirect
46-
github.com/spf13/cast v1.5.0 // indirect
47-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
48-
github.com/spf13/pflag v1.0.5 // indirect
49-
github.com/subosito/gotenv v1.4.1 // indirect
43+
github.com/spf13/afero v1.15.0 // indirect
44+
github.com/spf13/cast v1.10.0 // indirect
45+
github.com/spf13/pflag v1.0.10 // indirect
46+
github.com/subosito/gotenv v1.6.0 // indirect
5047
github.com/tklauser/go-sysconf v0.3.12 // indirect
5148
github.com/tklauser/numcpus v0.6.1 // indirect
5249
github.com/yusufpapurcu/wmi v1.2.4 // indirect
5350
go.opentelemetry.io/otel v1.24.0 // indirect
5451
go.opentelemetry.io/otel/metric v1.24.0 // indirect
5552
go.opentelemetry.io/otel/trace v1.24.0 // indirect
56-
golang.org/x/net v0.29.0 // indirect
57-
golang.org/x/sys v0.25.0 // indirect
58-
golang.org/x/text v0.18.0 // indirect
59-
golang.org/x/time v0.6.0 // indirect
53+
go.yaml.in/yaml/v3 v3.0.4 // indirect
54+
golang.org/x/net v0.43.0 // indirect
55+
golang.org/x/sys v0.36.0 // indirect
56+
golang.org/x/text v0.29.0 // indirect
57+
golang.org/x/time v0.12.0 // indirect
6058
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
61-
gopkg.in/ini.v1 v1.67.0 // indirect
62-
gopkg.in/yaml.v2 v2.4.0 // indirect
63-
gopkg.in/yaml.v3 v3.0.1 // indirect
6459
)

0 commit comments

Comments
 (0)