Skip to content

Commit

Permalink
if-else -> switch 空行 引入不规范 等问题的修复
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmr-bot committed Aug 16, 2023
1 parent 52c5fe8 commit 54554d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
17 changes: 9 additions & 8 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s Service) CheckToken(user string, token string, timestamp int64, stk stri
}

// CheckProxy 校验客户端代理
func (s Service) CheckProxy(user string, pMsg *msg.NewProxy, timestamp int64, stk string, LoginMsg *msg.Login) (ok bool, err error) {
func (s Service) CheckProxy(user string, pMsg *msg.NewProxy, timestamp int64, stk string, loginMsg *msg.Login) (ok bool, err error) {

domains, err := json.Marshal(pMsg.CustomDomains)
if err != nil {
Expand All @@ -86,20 +86,21 @@ func (s Service) CheckProxy(user string, pMsg *msg.NewProxy, timestamp int64, st
values.Set("proxy_type", pMsg.ProxyType)

// Proxies login info
values.Set("run_id", LoginMsg.RunID)
values.Set("run_id", loginMsg.RunID)

// Load balance
values.Set("group", pMsg.Group)
values.Set("group_key", pMsg.GroupKey)

if pMsg.ProxyType == "http" || pMsg.ProxyType == "https" {
// Http Proxies
switch pMsg.ProxyType {
case "http", "https":
// Http代理
values.Set("domain", string(domains))
} else if pMsg.ProxyType == "tcp" || pMsg.ProxyType == "udp" {
// Tcp & Udp
case "tcp", "udp":
// Tcp和Udp
values.Set("remote_port", strconv.Itoa(pMsg.RemotePort))
} else if pMsg.ProxyType == "stcp" || pMsg.ProxyType == "xtcp" {
// Stcp & Xtcp
case "stcp", "xtcp":
// Stcp和Xtcp
values.Set("remote_port", strconv.Itoa(pMsg.RemotePort))
values.Set("sk", pMsg.Sk)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/util/net/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package net
import (
"context"
"errors"
"github.com/quic-go/quic-go"
"github.com/fatedier/frp/pkg/util/xlog"

Check failure on line 6 in pkg/util/net/conn.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/fatedier/frp/) (gci)
quic "github.com/quic-go/quic-go"
"io"
"net"
"sync/atomic"
"time"

Check failure on line 11 in pkg/util/net/conn.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/fatedier/frp/) (gci)

"github.com/fatedier/frp/pkg/util/xlog"
)

type ContextGetter interface {
Expand Down
23 changes: 10 additions & 13 deletions server/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,11 @@ package server
import (
"context"
"fmt"

Check failure on line 5 in server/control.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/fatedier/frp/) (gci)
"github.com/fatedier/frp/pkg/api"
"github.com/fatedier/frp/pkg/limit"
"io"
"net"
"runtime/debug"
"sync"
"time"

"github.com/fatedier/golib/control/shutdown"
"github.com/fatedier/golib/crypto"
"github.com/fatedier/golib/errors"

api "github.com/fatedier/frp/pkg/api"
"github.com/fatedier/frp/pkg/auth"
"github.com/fatedier/frp/pkg/config"
pkgerr "github.com/fatedier/frp/pkg/errors"
"github.com/fatedier/frp/pkg/limit"
"github.com/fatedier/frp/pkg/msg"
plugin "github.com/fatedier/frp/pkg/plugin/server"
"github.com/fatedier/frp/pkg/transport"
Expand All @@ -27,6 +17,14 @@ import (
"github.com/fatedier/frp/server/controller"
"github.com/fatedier/frp/server/metrics"
"github.com/fatedier/frp/server/proxy"
"github.com/fatedier/golib/control/shutdown"
"github.com/fatedier/golib/crypto"
"github.com/fatedier/golib/errors"
"io"
"net"
"runtime/debug"
"sync"
"time"
)

type ControlManager struct {
Expand Down Expand Up @@ -686,6 +684,5 @@ func (ctl *Control) CloseProxy(closeMsg *msg.CloseProxy) (err error) {
go func() {
_ = ctl.pluginManager.CloseProxy(notifyContent)
}()

return
}
24 changes: 11 additions & 13 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,8 @@ import (
"context"
"crypto/tls"
"fmt"

Check failure on line 7 in server/service.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/fatedier/frp/) (gci)
"github.com/fatedier/frp/pkg/api"
"io"
"net"
"net/http"
"regexp"
"sort"
"strconv"
"time"

"github.com/fatedier/golib/net/mux"
fmux "github.com/hashicorp/yamux"
"github.com/quic-go/quic-go"

"github.com/fatedier/frp/assets"
api "github.com/fatedier/frp/pkg/api"
"github.com/fatedier/frp/pkg/auth"
"github.com/fatedier/frp/pkg/config"
modelmetrics "github.com/fatedier/frp/pkg/metrics"
Expand All @@ -39,6 +27,16 @@ import (
"github.com/fatedier/frp/server/ports"
"github.com/fatedier/frp/server/proxy"
"github.com/fatedier/frp/server/visitor"
"github.com/fatedier/golib/net/mux"

Check failure on line 30 in server/service.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/fatedier/frp/) (gci)
fmux "github.com/hashicorp/yamux"
quic "github.com/quic-go/quic-go"
"io"
"net"
"net/http"
"regexp"
"sort"
"strconv"
"time"
)

const (
Expand Down

0 comments on commit 54554d4

Please sign in to comment.