Skip to content

Commit 6d387b5

Browse files
committed
chore: Remove some unused code
1 parent 3d20238 commit 6d387b5

File tree

12 files changed

+4
-171
lines changed

12 files changed

+4
-171
lines changed

core/app/api/v2/auth.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ func (b *BaseApi) Captcha(c *gin.Context) {
118118
helper.SuccessWithData(c, captcha)
119119
}
120120

121-
func (b *BaseApi) GetResponsePage(c *gin.Context) {
122-
pageCode, err := authService.GetResponsePage()
123-
if err != nil {
124-
helper.InternalServer(c, err)
125-
return
126-
}
127-
helper.SuccessWithData(c, pageCode)
128-
}
129-
130121
func (b *BaseApi) GetWelcomePage(c *gin.Context) {
131122
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
132123
if count != 1 {

core/app/api/v2/helper/helper.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package helper
22

33
import (
4-
"errors"
54
"fmt"
6-
"github.com/1Panel-dev/1Panel/core/cmd/server/res"
75
"net/http"
8-
"strconv"
6+
7+
"github.com/1Panel-dev/1Panel/core/cmd/server/res"
98

109
"github.com/1Panel-dev/1Panel/core/app/dto"
1110
"github.com/1Panel-dev/1Panel/core/global"
@@ -91,12 +90,3 @@ func ErrWithHtml(ctx *gin.Context, code int, scope string) {
9190
ctx.Data(code, "text/html; charset=utf-8", data)
9291
ctx.Abort()
9392
}
94-
95-
func GetParamID(c *gin.Context) (uint, error) {
96-
idParam, ok := c.Params.Get("id")
97-
if !ok {
98-
return 0, errors.New("error id in path")
99-
}
100-
intNum, _ := strconv.Atoi(idParam)
101-
return uint(intNum), nil
102-
}

core/app/api/v2/upgrade.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,3 @@ func (b *BaseApi) Upgrade(c *gin.Context) {
7979
}
8080
helper.Success(c)
8181
}
82-
83-
// @Tags System Setting
84-
// @Summary Upgrade
85-
// @Accept json
86-
// @Param request body dto.OperateByID true "request"
87-
// @Success 200
88-
// @Security ApiKeyAuth
89-
// @Security Timestamp
90-
// @Router /core/settings/rollback [post]
91-
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"upgrade_logs","output_column":"old_version","output_value":"version"}],"formatZH":"回滚系统 => [version]","formatEN":"rollback system => [version]"}
92-
func (b *BaseApi) Rollback(c *gin.Context) {
93-
var req dto.OperateByID
94-
if err := helper.CheckBindAndValidate(&req, c); err != nil {
95-
return
96-
}
97-
98-
if err := upgradeService.Rollback(req); err != nil {
99-
helper.InternalServer(c, err)
100-
return
101-
}
102-
helper.Success(c)
103-
}

core/app/repo/common.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ func WithByName(name string) global.DBOption {
2929
return g.Where("`name` = ?", name)
3030
}
3131
}
32-
func WithoutByName(name string) global.DBOption {
33-
return func(g *gorm.DB) *gorm.DB {
34-
return g.Where("`name` != ?", name)
35-
}
36-
}
3732

3833
func WithByType(ty string) global.DBOption {
3934
return func(g *gorm.DB) *gorm.DB {
@@ -60,11 +55,6 @@ func WithByNode(node string) global.DBOption {
6055
return g.Where("node = ?", node)
6156
}
6257
}
63-
func WithByGroupBelong(group string) global.DBOption {
64-
return func(g *gorm.DB) *gorm.DB {
65-
return g.Where("group_belong = ?", group)
66-
}
67-
}
6858

6959
func WithOrderBy(orderStr string) global.DBOption {
7060
if orderStr == "createdAt" {

core/app/repo/host.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type IHostRepo interface {
2020
WithByInfo(info string) global.DBOption
2121
WithByPort(port uint) global.DBOption
2222
WithByUser(user string) global.DBOption
23-
WithByAddr(addr string) global.DBOption
2423
}
2524

2625
func NewIHostRepo() IHostRepo {
@@ -79,11 +78,6 @@ func (h *HostRepo) WithByUser(user string) global.DBOption {
7978
return g.Where("user = ?", user)
8079
}
8180
}
82-
func (h *HostRepo) WithByAddr(addr string) global.DBOption {
83-
return func(g *gorm.DB) *gorm.DB {
84-
return g.Where("addr = ?", addr)
85-
}
86-
}
8781

8882
func (h *HostRepo) Create(host *model.Host) error {
8983
return global.DB.Create(host).Error

core/app/service/host.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (u *HostService) TestByInfo(req dto.HostConnTest) bool {
5050
req.PrivateKey = string(privateKey)
5151
}
5252
if len(req.Password) == 0 && len(req.PrivateKey) == 0 {
53-
host, err := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
53+
host, err := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
5454
if err != nil {
5555
return false
5656
}
@@ -235,7 +235,7 @@ func (u *HostService) GetHostByID(id uint) (*dto.HostInfo, error) {
235235
}
236236

237237
func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) {
238-
hostItem, _ := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
238+
hostItem, _ := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
239239
if hostItem.ID != 0 {
240240
return nil, buserr.New("ErrRecordExist")
241241
}

core/utils/cloud_storage/client/helper/webdav/auth.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
7272
return az
7373
}
7474

75-
func NewEmptyAuth() Authorizer {
76-
fmap := make([]authfactory, 0)
77-
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
78-
return az
79-
}
80-
81-
func NewPreemptiveAuth(auth Authenticator) Authorizer {
82-
return &preemptiveAuthorizer{auth: auth}
83-
}
84-
8575
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
8676
var retryBuf io.Reader = body
8777
if body != nil {
@@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
296286
func (n *nullAuth) String() string {
297287
return "NullAuth"
298288
}
299-
300-
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
301-
return b.auth.Clone(), body
302-
}
303-
304-
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
305-
panic("You're funny! A preemptive authorizer may only have a single authentication method")
306-
}

core/utils/cloud_storage/client/helper/webdav/utils.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package webdav
22

33
import (
4-
"bytes"
54
"encoding/xml"
65
"io"
76
"net/url"
@@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
6362
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
6463
}
6564

66-
func String(r io.Reader) string {
67-
buf := new(bytes.Buffer)
68-
// TODO - make String return an error as well
69-
_, _ = buf.ReadFrom(r)
70-
return buf.String()
71-
}
72-
7365
func parseInt64(s *string) int64 {
7466
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
7567
return n

core/utils/cmd/cmd.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package cmd
22

33
import (
4-
"bufio"
5-
"fmt"
6-
"io"
74
"os/exec"
85
"strings"
96
)
@@ -23,36 +20,3 @@ func Which(name string) bool {
2320
}
2421
return true
2522
}
26-
27-
func ExecWithStreamOutput(command string, outputCallback func(string)) error {
28-
cmd := exec.Command("bash", "-c", command)
29-
30-
stdout, err := cmd.StdoutPipe()
31-
if err != nil {
32-
return fmt.Errorf("failed to get stdout: %w", err)
33-
}
34-
35-
stderr, err := cmd.StderrPipe()
36-
if err != nil {
37-
return fmt.Errorf("failed to get stderr: %w", err)
38-
}
39-
40-
if err := cmd.Start(); err != nil {
41-
return fmt.Errorf("failed to start command: %w", err)
42-
}
43-
44-
go streamReader(stdout, outputCallback)
45-
go streamReader(stderr, outputCallback)
46-
47-
if err := cmd.Wait(); err != nil {
48-
return fmt.Errorf("command finished with error: %w", err)
49-
}
50-
return nil
51-
}
52-
53-
func streamReader(reader io.ReadCloser, callback func(string)) {
54-
scanner := bufio.NewScanner(reader)
55-
for scanner.Scan() {
56-
callback(scanner.Text())
57-
}
58-
}

core/utils/common/common.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ func ScanPort(port int) bool {
7272
return false
7373
}
7474

75-
func CheckPort(host string, port string, timeout time.Duration) bool {
76-
target := net.JoinHostPort(host, port)
77-
conn, err := net.DialTimeout("tcp", target, timeout)
78-
if err != nil {
79-
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
80-
return false
81-
}
82-
return strings.Contains(err.Error(), "connection refused")
83-
}
84-
defer conn.Close()
85-
return true
86-
}
87-
8875
func ComparePanelVersion(version1, version2 string) bool {
8976
if version1 == version2 {
9077
return false

0 commit comments

Comments
 (0)