Reformat code

This commit is contained in:
世界 2023-03-17 13:17:01 +08:00
parent f57ec13880
commit 55efac7236
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
8 changed files with 28 additions and 28 deletions

View File

@ -3,11 +3,10 @@ package protocol
import ( import (
"runtime" "runtime"
"golang.org/x/sys/cpu"
"github.com/xtls/xray-core/common/bitmask" "github.com/xtls/xray-core/common/bitmask"
"github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/common/uuid"
"golang.org/x/sys/cpu"
) )
// RequestCommand is a custom command in a proxy request. // RequestCommand is a custom command in a proxy request.

View File

@ -616,7 +616,7 @@ type SocketConfig struct {
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
TCPCongestion string `json:"tcpCongestion"` TCPCongestion string `json:"tcpCongestion"`
TCPWindowClamp int32 `json:"tcpWindowClamp"` TCPWindowClamp int32 `json:"tcpWindowClamp"`
V6only bool `json:"v6only"` V6only bool `json:"v6only"`
Interface string `json:"interface"` Interface string `json:"interface"`
} }
@ -668,7 +668,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
TcpKeepAliveInterval: c.TCPKeepAliveInterval, TcpKeepAliveInterval: c.TCPKeepAliveInterval,
TcpKeepAliveIdle: c.TCPKeepAliveIdle, TcpKeepAliveIdle: c.TCPKeepAliveIdle,
TcpCongestion: c.TCPCongestion, TcpCongestion: c.TCPCongestion,
TcpWindowClamp: c.TCPWindowClamp, TcpWindowClamp: c.TCPWindowClamp,
V6Only: c.V6only, V6Only: c.V6only,
Interface: c.Interface, Interface: c.Interface,
}, nil }, nil

View File

@ -485,7 +485,7 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool
} }
paddingLen = int32(l.Int64()) paddingLen = int32(l.Int64())
} }
if paddingLen > buf.Size - 21 - contentLen { if paddingLen > buf.Size-21-contentLen {
paddingLen = buf.Size - 21 - contentLen paddingLen = buf.Size - 21 - contentLen
} }
newbuffer := buf.New() newbuffer := buf.New()

View File

@ -287,7 +287,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
counter = statConn.ReadCounter counter = statConn.ReadCounter
} }
err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(), err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(),
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
} else { } else {
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))

View File

@ -37,7 +37,6 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) {
buf := make([]byte, 0x100) buf := make([]byte, 0x100)
off1, err := dns.PackDomainName(dns.Fqdn(config.(*Config).Domain), buf, 0, nil, false) off1, err := dns.PackDomainName(dns.Fqdn(config.(*Config).Domain), buf, 0, nil, false)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -24,14 +24,14 @@ type ConnectionID struct {
// Listener defines a server listening for connections // Listener defines a server listening for connections
type Listener struct { type Listener struct {
sync.Mutex sync.Mutex
sessions map[ConnectionID]*Connection sessions map[ConnectionID]*Connection
hub *udp.Hub hub *udp.Hub
tlsConfig *gotls.Config tlsConfig *gotls.Config
config *Config config *Config
reader PacketReader reader PacketReader
header internet.PacketHeader header internet.PacketHeader
security cipher.AEAD security cipher.AEAD
addConn internet.ConnHandler addConn internet.ConnHandler
} }
func NewListener(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (*Listener, error) { func NewListener(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (*Listener, error) {

View File

@ -240,8 +240,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
return uConn, nil return uConn, nil
} }
var href = regexp.MustCompile(`href="([/h].*?)"`) var (
var dot = []byte(".") href = regexp.MustCompile(`href="([/h].*?)"`)
dot = []byte(".")
)
var maps struct { var maps struct {
sync.Mutex sync.Mutex

View File

@ -47,11 +47,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
} }
} }
if config.Interface != "" { if config.Interface != "" {
if err := syscall.BindToDevice(int(fd), config.Interface); err != nil { if err := syscall.BindToDevice(int(fd), config.Interface); err != nil {
return newError("failed to set Interface").Base(err) return newError("failed to set Interface").Base(err)
} }
} }
if isTCPSocket(network) { if isTCPSocket(network) {
tfo := config.ParseTFOValue() tfo := config.ParseTFOValue()
@ -91,10 +91,10 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
} }
if config.TcpWindowClamp > 0 { if config.TcpWindowClamp > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil { if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil {
return newError("failed to set TCP_WINDOW_CLAMP", err) return newError("failed to set TCP_WINDOW_CLAMP", err)
} }
} }
} }
if config.Tproxy.IsEnabled() { if config.Tproxy.IsEnabled() {
@ -148,8 +148,8 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
if config.TcpWindowClamp > 0 { if config.TcpWindowClamp > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil { if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil {
return newError("failed to set TCP_WINDOW_CLAMP", err) return newError("failed to set TCP_WINDOW_CLAMP", err)
} }
} }
} }