Chore: Run gofmt (#3990)

This commit is contained in:
zonescape 2024-11-09 14:16:11 +03:00 committed by GitHub
parent bc4bf3d38f
commit 83bab5dd90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 272 additions and 273 deletions

View file

@ -30,9 +30,9 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
// Process implements OutboundHandler.Dispatch().
func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
outbounds := session.OutboundsFromContext(ctx)
ob := outbounds[len(outbounds) - 1]
ob := outbounds[len(outbounds)-1]
ob.Name = "blackhole"
nBytes := h.response.WriteTo(link.Writer)
if nBytes > 0 {
// Sleep a little here to make sure the response is sent to client.

View file

@ -49,7 +49,7 @@ type Handler struct {
server net.Destination
timeout time.Duration
nonIPQuery string
blockTypes []int32
blockTypes []int32
}
func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error {

View file

@ -78,7 +78,7 @@ type UserManager interface {
// RemoveUser removes a user by email.
RemoveUser(context.Context, string) error
// Get user by email.
GetUser(context.Context, string) *protocol.MemoryUser

View file

@ -22,7 +22,7 @@ import (
// MemoryAccount is an account type converted from Account.
type MemoryAccount struct {
Cipher Cipher
CipherType CipherType
CipherType CipherType
Key []byte
Password string
@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool {
func (a *MemoryAccount) ToProto() proto.Message {
return &Account{
CipherType: a.CipherType,
Password: a.Password,
IvCheck: a.replayFilter != nil,
Password: a.Password,
IvCheck: a.replayFilter != nil,
}
}
@ -117,10 +117,10 @@ func (a *Account) AsAccount() (protocol.Account, error) {
return nil, errors.New("failed to get cipher").Base(err)
}
return &MemoryAccount{
Cipher: Cipher,
Cipher: Cipher,
CipherType: a.CipherType,
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
Password: a.Password,
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
Password: a.Password,
replayFilter: func() antireplay.GeneralizedReplayFilter {
if a.IvCheck {
return antireplay.NewBloomRing()

View file

@ -10,9 +10,9 @@ import (
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/crypto"
"github.com/xtls/xray-core/common/drain"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"
)

View file

@ -8,13 +8,13 @@ import (
// MemoryAccount is an account type converted from Account.
type MemoryAccount struct {
Key string
Key string
}
// AsAccount implements protocol.AsAccount.
func (u *Account) AsAccount() (protocol.Account, error) {
return &MemoryAccount{
Key: u.GetKey(),
Key: u.GetKey(),
}, nil
}

View file

@ -155,7 +155,7 @@ func (i *MultiUserInbound) GetUser(ctx context.Context, email string) *protocol.
if email == "" {
return nil
}
i.Lock()
defer i.Unlock()

View file

@ -45,7 +45,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
serverPicker: protocol.NewRoundRobinServerPicker(serverList),
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
}
return c, nil
}

View file

@ -361,14 +361,14 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
cs := tlsConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
} else if realityConn, ok := iConn.(*reality.Conn); ok {
cs := realityConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
}
name = strings.ToLower(name)
alpn = strings.ToLower(alpn)
@ -418,7 +418,7 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
}
if k == '?' || k == ' ' {
path = string(firstBytes[i:j])
errors.LogInfo(ctx, "realPath = " + path)
errors.LogInfo(ctx, "realPath = "+path)
if pfb[path] == nil {
path = ""
}

View file

@ -51,7 +51,6 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser {
return nil
}
// Get a trojan user with hashed key, nil if user doesn't exist.
func (v *Validator) GetByEmail(email string) *protocol.MemoryUser {
u, _ := v.email.Load(email)

View file

@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool {
func (a *MemoryAccount) ToProto() proto.Message {
return &Account{
Id: a.ID.String(),
Flow: a.Flow,
Id: a.ID.String(),
Flow: a.Flow,
Encryption: a.Encryption,
}
}

View file

@ -38,8 +38,8 @@ func (a *MemoryAccount) ToProto() proto.Message {
test = test + "NoTerminationSignal"
}
return &Account{
Id: a.ID.String(),
TestsEnabled: test,
Id: a.ID.String(),
TestsEnabled: test,
SecuritySettings: &protocol.SecurityConfig{Type: a.Security},
}
}

View file

@ -29,8 +29,8 @@ import (
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/dice"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/log"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"