Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Mar 17, 2023
1 parent f57ec13 commit 55efac7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
3 changes: 1 addition & 2 deletions common/protocol/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package protocol
import (
"runtime"

"golang.org/x/sys/cpu"

"github.com/xtls/xray-core/common/bitmask"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/uuid"
"golang.org/x/sys/cpu"
)

// RequestCommand is a custom command in a proxy request.
Expand Down
4 changes: 2 additions & 2 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ type SocketConfig struct {
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
TCPCongestion string `json:"tcpCongestion"`
TCPWindowClamp int32 `json:"tcpWindowClamp"`
TCPWindowClamp int32 `json:"tcpWindowClamp"`
V6only bool `json:"v6only"`
Interface string `json:"interface"`
}
Expand Down Expand Up @@ -668,7 +668,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
TcpKeepAliveInterval: c.TCPKeepAliveInterval,
TcpKeepAliveIdle: c.TCPKeepAliveIdle,
TcpCongestion: c.TCPCongestion,
TcpWindowClamp: c.TCPWindowClamp,
TcpWindowClamp: c.TCPWindowClamp,
V6Only: c.V6only,
Interface: c.Interface,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion proxy/vless/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool
}
paddingLen = int32(l.Int64())
}
if paddingLen > buf.Size - 21 - contentLen {
if paddingLen > buf.Size-21-contentLen {
paddingLen = buf.Size - 21 - contentLen
}
newbuffer := buf.New()
Expand Down
2 changes: 1 addition & 1 deletion proxy/vless/outbound/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
counter = statConn.ReadCounter
}
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 {
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
Expand Down
1 change: 0 additions & 1 deletion transport/internet/headers/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) {
buf := make([]byte, 0x100)

off1, err := dns.PackDomainName(dns.Fqdn(config.(*Config).Domain), buf, 0, nil, false)

if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions transport/internet/kcp/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type ConnectionID struct {
// Listener defines a server listening for connections
type Listener struct {
sync.Mutex
sessions map[ConnectionID]*Connection
hub *udp.Hub
tlsConfig *gotls.Config
config *Config
reader PacketReader
header internet.PacketHeader
security cipher.AEAD
addConn internet.ConnHandler
sessions map[ConnectionID]*Connection
hub *udp.Hub
tlsConfig *gotls.Config
config *Config
reader PacketReader
header internet.PacketHeader
security cipher.AEAD
addConn internet.ConnHandler
}

func NewListener(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (*Listener, error) {
Expand Down
6 changes: 4 additions & 2 deletions transport/internet/reality/reality.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
return uConn, nil
}

var href = regexp.MustCompile(`href="([/h].*?)"`)
var dot = []byte(".")
var (
href = regexp.MustCompile(`href="([/h].*?)"`)
dot = []byte(".")
)

var maps struct {
sync.Mutex
Expand Down
22 changes: 11 additions & 11 deletions transport/internet/sockopt_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
}
}

if config.Interface != "" {
if err := syscall.BindToDevice(int(fd), config.Interface); err != nil {
return newError("failed to set Interface").Base(err)
}
}
if config.Interface != "" {
if err := syscall.BindToDevice(int(fd), config.Interface); err != nil {
return newError("failed to set Interface").Base(err)
}
}

if isTCPSocket(network) {
tfo := config.ParseTFOValue()
Expand Down Expand Up @@ -91,10 +91,10 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
}

if config.TcpWindowClamp > 0 {
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)
}
}
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)
}
}
}

if config.Tproxy.IsEnabled() {
Expand Down Expand Up @@ -148,8 +148,8 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)

if config.TcpWindowClamp > 0 {
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)
}
}
}

Expand Down

0 comments on commit 55efac7

Please sign in to comment.