Skip to content

Commit 673638b

Browse files
committed
perf: update sdk and deps
1 parent 97cc909 commit 673638b

11 files changed

Lines changed: 63 additions & 602 deletions

File tree

cmd/common/storage_backend.go

Lines changed: 5 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,15 @@
11
package common
22

33
import (
4-
"strings"
5-
64
"github.com/jumpserver-dev/sdk-go/model"
75
"github.com/jumpserver-dev/sdk-go/service"
8-
"github.com/jumpserver/wisp/pkg/storage"
6+
"github.com/jumpserver-dev/sdk-go/storage"
97
)
108

11-
type StorageType interface {
12-
TypeName() string
13-
}
14-
15-
type ReplayStorage interface {
16-
Upload(gZipFile, target string) error
17-
StorageType
18-
}
19-
20-
type CommandStorage interface {
21-
BulkSave(commands []*model.Command) error
22-
StorageType
23-
}
24-
25-
func NewCommandBackend(apiClient *service.JMService, cfg *model.CommandConfig) CommandStorage {
26-
switch cfg.TypeName {
27-
case "es", "elasticsearch":
28-
var hosts = cfg.Hosts
29-
var skipVerify bool
30-
index := cfg.Index
31-
docType := cfg.DocType
32-
if cfg.Other != nil {
33-
skipVerify = cfg.Other.IgnoreVerifyCerts
34-
}
35-
if index == "" {
36-
index = "jumpserver"
37-
}
38-
if docType == "" {
39-
docType = "_doc"
40-
}
41-
return storage.ESCommandStorage{
42-
Hosts: hosts,
43-
Index: index,
44-
DocType: docType,
45-
InsecureSkipVerify: skipVerify,
46-
}
47-
case "null":
48-
return storage.NewNullStorage()
49-
default:
50-
return storage.ServerStorage{StorageType: "server", JmsService: apiClient}
51-
}
9+
func NewCommandBackend(apiClient *service.JMService, cfg *model.TerminalConfig) storage.CommandStorage {
10+
return storage.NewCommandStorage(apiClient, cfg)
5211
}
5312

54-
func NewReplayBackend(apiClient *service.JMService, cfg *model.ReplayConfig) ReplayStorage {
55-
56-
switch cfg.TypeName {
57-
case "azure":
58-
var (
59-
accountName string
60-
accountKey string
61-
containerName string
62-
endpointSuffix string
63-
)
64-
endpointSuffix = cfg.EndpointSuffix
65-
accountName = cfg.AccountName
66-
accountKey = cfg.AccountKey
67-
containerName = cfg.ContainerName
68-
69-
if endpointSuffix == "" {
70-
endpointSuffix = "core.chinacloudapi.cn"
71-
}
72-
return storage.AzureReplayStorage{
73-
AccountName: accountName,
74-
AccountKey: accountKey,
75-
ContainerName: containerName,
76-
EndpointSuffix: endpointSuffix,
77-
}
78-
case "oss":
79-
var (
80-
endpoint string
81-
bucket string
82-
accessKey string
83-
secretKey string
84-
)
85-
86-
endpoint = cfg.Endpoint
87-
bucket = cfg.Bucket
88-
accessKey = cfg.AccessKey
89-
secretKey = cfg.SecretKey
90-
return storage.OSSReplayStorage{
91-
Endpoint: endpoint,
92-
Bucket: bucket,
93-
AccessKey: accessKey,
94-
SecretKey: secretKey,
95-
}
96-
case "s3", "swift", "cos":
97-
var (
98-
region string
99-
endpoint string
100-
bucket string
101-
accessKey string
102-
secretKey string
103-
)
104-
105-
bucket = cfg.Bucket
106-
endpoint = cfg.Endpoint
107-
region = cfg.Region
108-
accessKey = cfg.AccessKey
109-
secretKey = cfg.SecretKey
110-
111-
if region == "" && endpoint != "" {
112-
endpointArray := strings.Split(endpoint, ".")
113-
if len(endpointArray) >= 2 {
114-
region = endpointArray[1]
115-
}
116-
}
117-
if bucket == "" {
118-
bucket = "jumpserver"
119-
}
120-
return storage.S3ReplayStorage{
121-
Bucket: bucket,
122-
Region: region,
123-
AccessKey: accessKey,
124-
SecretKey: secretKey,
125-
Endpoint: endpoint,
126-
}
127-
case "obs":
128-
var (
129-
endpoint string
130-
bucket string
131-
accessKey string
132-
secretKey string
133-
)
134-
135-
endpoint = cfg.Endpoint
136-
bucket = cfg.Bucket
137-
accessKey = cfg.AccessKey
138-
secretKey = cfg.SecretKey
139-
return storage.OBSReplayStorage{
140-
Endpoint: endpoint,
141-
Bucket: bucket,
142-
AccessKey: accessKey,
143-
SecretKey: secretKey,
144-
}
145-
case "null":
146-
return storage.NewNullStorage()
147-
default:
148-
return storage.ServerStorage{StorageType: "server", JmsService: apiClient}
149-
}
13+
func NewReplayBackend(apiClient *service.JMService, cfg *model.ReplayConfig) storage.ReplayStorage {
14+
return storage.NewReplayStorage(apiClient, *cfg)
15015
}

cmd/common/uploader_service.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
modelCommon "github.com/jumpserver-dev/sdk-go/common"
1313
"github.com/jumpserver-dev/sdk-go/model"
1414
"github.com/jumpserver-dev/sdk-go/service"
15+
"github.com/jumpserver-dev/sdk-go/storage"
1516
"github.com/jumpserver/wisp/pkg/logger"
1617
)
1718

@@ -71,12 +72,12 @@ func (u *UploaderService) updateBackendCfg(termCfg *model.TerminalConfig) {
7172
u.terminalCfg.Store(termCfg)
7273
}
7374

74-
func (u *UploaderService) getCommandBackend() CommandStorage {
75-
cfg := u.commandCfg.Load().(model.CommandConfig)
75+
func (u *UploaderService) getCommandBackend() storage.CommandStorage {
76+
cfg := u.terminalCfg.Load().(model.TerminalConfig)
7677
return NewCommandBackend(u.apiClient, &cfg)
7778
}
7879

79-
func (u *UploaderService) getReplayBackend() ReplayStorage {
80+
func (u *UploaderService) getReplayBackend() storage.ReplayStorage {
8081
cfg := u.replayCfg.Load().(model.ReplayConfig)
8182
return NewReplayBackend(u.apiClient, &cfg)
8283
}

go.mod

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,61 @@ module github.com/jumpserver/wisp
33
go 1.24.6
44

55
require (
6-
github.com/Azure/azure-storage-blob-go v0.15.0
7-
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
8-
github.com/aws/aws-sdk-go v1.44.306
9-
github.com/elastic/go-elasticsearch/v6 v6.8.5
10-
github.com/elastic/go-elasticsearch/v8 v8.14.0
116
github.com/gorilla/websocket v1.5.3
12-
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible
13-
github.com/jumpserver-dev/sdk-go v0.0.0-20251007162206-113f4e3fdde6
7+
github.com/jumpserver-dev/sdk-go v0.0.0-20260130073417-a608248623a4
148
github.com/sirupsen/logrus v1.9.3
159
github.com/spf13/cobra v1.10.1
1610
github.com/spf13/viper v1.21.0
1711
golang.org/x/crypto v0.42.0
1812
google.golang.org/grpc v1.65.0
1913
google.golang.org/protobuf v1.34.2
2014
gopkg.in/natefinch/lumberjack.v2 v2.2.1
21-
2215
)
2316

2417
require (
2518
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
19+
github.com/Azure/azure-storage-blob-go v0.15.0 // indirect
2620
github.com/LeeEirc/httpsig v1.2.1 // indirect
21+
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect
22+
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
23+
github.com/aws/aws-sdk-go v1.44.306 // indirect
2724
github.com/dlclark/regexp2 v1.11.4 // indirect
2825
github.com/elastic/elastic-transport-go/v8 v8.6.0 // indirect
26+
github.com/elastic/go-elasticsearch/v6 v6.8.5 // indirect
27+
github.com/elastic/go-elasticsearch/v8 v8.14.0 // indirect
2928
github.com/fsnotify/fsnotify v1.9.0 // indirect
3029
github.com/go-logr/logr v1.4.1 // indirect
3130
github.com/go-logr/stdr v1.2.2 // indirect
32-
github.com/go-ole/go-ole v1.2.6 // indirect
31+
github.com/go-ole/go-ole v1.3.0 // indirect
3332
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
3433
github.com/google/uuid v1.6.0 // indirect
34+
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.25.4+incompatible // indirect
3535
github.com/inconshreveable/mousetrap v1.1.0 // indirect
36+
github.com/influxdata/influxdb-client-go/v2 v2.14.0 // indirect
37+
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
3638
github.com/jmespath/go-jmespath v0.4.0 // indirect
37-
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
39+
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
3840
github.com/mattn/go-ieproxy v0.0.1 // indirect
41+
github.com/oapi-codegen/runtime v1.1.1 // indirect
3942
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
40-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
43+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
4144
github.com/sagikazarmark/locafero v0.12.0 // indirect
4245
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
43-
github.com/shoenig/go-m1cpu v0.1.6 // indirect
46+
github.com/shoenig/go-m1cpu v0.1.7 // indirect
4447
github.com/spf13/afero v1.15.0 // indirect
4548
github.com/spf13/cast v1.10.0 // indirect
4649
github.com/spf13/pflag v1.0.10 // indirect
4750
github.com/subosito/gotenv v1.6.0 // indirect
48-
github.com/tklauser/go-sysconf v0.3.12 // indirect
49-
github.com/tklauser/numcpus v0.6.1 // indirect
51+
github.com/tklauser/go-sysconf v0.3.16 // indirect
52+
github.com/tklauser/numcpus v0.11.0 // indirect
5053
github.com/yusufpapurcu/wmi v1.2.4 // indirect
5154
go.opentelemetry.io/otel v1.24.0 // indirect
5255
go.opentelemetry.io/otel/metric v1.24.0 // indirect
5356
go.opentelemetry.io/otel/trace v1.24.0 // indirect
5457
go.yaml.in/yaml/v3 v3.0.4 // indirect
5558
golang.org/x/net v0.43.0 // indirect
56-
golang.org/x/sys v0.36.0 // indirect
57-
golang.org/x/text v0.29.0 // indirect
59+
golang.org/x/sys v0.40.0 // indirect
60+
golang.org/x/text v0.33.0 // indirect
5861
golang.org/x/time v0.12.0 // indirect
5962
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
6063
)

0 commit comments

Comments
 (0)