mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Style: format code by gofumpt (#761)
This commit is contained in:
parent
d77be80b40
commit
e286cdcaa8
111 changed files with 293 additions and 291 deletions
|
@ -28,9 +28,7 @@ type Dialer interface {
|
|||
// dialFunc is an interface to dial network connection to a specific destination.
|
||||
type dialFunc func(ctx context.Context, dest net.Destination, streamSettings *MemoryStreamConfig) (stat.Connection, error)
|
||||
|
||||
var (
|
||||
transportDialerCache = make(map[string]dialFunc)
|
||||
)
|
||||
var transportDialerCache = make(map[string]dialFunc)
|
||||
|
||||
// RegisterTransportDialer registers a Dialer with given name.
|
||||
func RegisterTransportDialer(protocol string, dialer dialFunc) error {
|
||||
|
@ -81,7 +79,7 @@ func lookupIP(domain string, strategy DomainStrategy, localAddr net.Address) ([]
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
var option = dns.IPOption{
|
||||
option := dns.IPOption{
|
||||
IPv4Enable: true,
|
||||
IPv6Enable: true,
|
||||
FakeEnable: false,
|
||||
|
|
|
@ -6,8 +6,10 @@ import (
|
|||
"github.com/xtls/xray-core/transport/internet"
|
||||
)
|
||||
|
||||
const protocolName = "domainsocket"
|
||||
const sizeofSunPath = 108
|
||||
const (
|
||||
protocolName = "domainsocket"
|
||||
sizeofSunPath = 108
|
||||
)
|
||||
|
||||
func (c *Config) GetUnixAddr() (*net.UnixAddr, error) {
|
||||
path := c.Path
|
||||
|
|
|
@ -49,7 +49,6 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
|
|||
grpcSettings := streamSettings.ProtocolSettings.(*Config)
|
||||
|
||||
conn, err := getGrpcClient(ctx, dest, streamSettings)
|
||||
|
||||
if err != nil {
|
||||
return nil, newError("Cannot dial gRPC").Base(err)
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|||
return client, nil
|
||||
}
|
||||
|
||||
var dialOptions = []grpc.DialOption{
|
||||
dialOptions := []grpc.DialOption{
|
||||
grpc.WithConnectParams(grpc.ConnectParams{
|
||||
Backoff: backoff.Config{
|
||||
BaseDelay: 500 * time.Millisecond,
|
||||
|
|
|
@ -92,7 +92,7 @@ func (h *MultiHunkReaderWriter) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var mb = make(buf.MultiBuffer, 0, len(h.buf))
|
||||
mb := make(buf.MultiBuffer, 0, len(h.buf))
|
||||
for _, b := range h.buf {
|
||||
if len(b) == 0 {
|
||||
continue
|
||||
|
|
|
@ -16,9 +16,7 @@ import (
|
|||
"github.com/xtls/xray-core/transport/internet/xtls"
|
||||
)
|
||||
|
||||
var (
|
||||
globalConv = uint32(dice.RollUint16())
|
||||
)
|
||||
var globalConv = uint32(dice.RollUint16())
|
||||
|
||||
func fetchInput(_ context.Context, input io.Reader, reader PacketReader, conn *Connection) {
|
||||
cache := make(chan *buf.Buffer, 1024)
|
||||
|
|
|
@ -97,7 +97,6 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
}, streamSettings.SocketSettings)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ import (
|
|||
//
|
||||
//
|
||||
|
||||
const protocolName = "quic"
|
||||
const internalDomain = "quic.internal.example.com"
|
||||
const (
|
||||
protocolName = "quic"
|
||||
internalDomain = "quic.internal.example.com"
|
||||
)
|
||||
|
||||
func init() {
|
||||
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
|
||||
|
|
|
@ -45,6 +45,7 @@ func ioctl(s uintptr, ioc int, b []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nl *pfiocNatlook) rdPort() int {
|
||||
return int(binary.BigEndian.Uint16((*[2]byte)(unsafe.Pointer(&nl.Rdport))[:]))
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -11,9 +11,7 @@ import (
|
|||
"github.com/xtls/xray-core/features/outbound"
|
||||
)
|
||||
|
||||
var (
|
||||
effectiveSystemDialer SystemDialer = &DefaultSystemDialer{}
|
||||
)
|
||||
var effectiveSystemDialer SystemDialer = &DefaultSystemDialer{}
|
||||
|
||||
type SystemDialer interface {
|
||||
Dial(ctx context.Context, source net.Address, destination net.Destination, sockopt *SocketConfig) (net.Conn, error)
|
||||
|
|
|
@ -11,9 +11,7 @@ import (
|
|||
"github.com/xtls/xray-core/common/session"
|
||||
)
|
||||
|
||||
var (
|
||||
effectiveListener = DefaultListener{}
|
||||
)
|
||||
var effectiveListener = DefaultListener{}
|
||||
|
||||
type controller func(network, address string, fd uintptr) error
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe
|
|||
}
|
||||
var listener net.Listener
|
||||
var err error
|
||||
if port == net.Port(0) { //unix
|
||||
if port == net.Port(0) { // unix
|
||||
listener, err = internet.ListenSystem(ctx, &net.UnixAddr{
|
||||
Name: address.Domain(),
|
||||
Net: "unix",
|
||||
|
|
|
@ -8,9 +8,7 @@ import (
|
|||
"github.com/xtls/xray-core/common/net"
|
||||
)
|
||||
|
||||
var (
|
||||
transportListenerCache = make(map[string]ListenFunc)
|
||||
)
|
||||
var transportListenerCache = make(map[string]ListenFunc)
|
||||
|
||||
func RegisterTransportListener(protocol string, listener ListenFunc) error {
|
||||
if _, found := transportListenerCache[protocol]; found {
|
||||
|
@ -50,6 +48,7 @@ func ListenUnix(ctx context.Context, address net.Address, settings *MemoryStream
|
|||
}
|
||||
return listener, nil
|
||||
}
|
||||
|
||||
func ListenTCP(ctx context.Context, address net.Address, port net.Port, settings *MemoryStreamConfig, handler ConnHandler) (Listener, error) {
|
||||
if settings == nil {
|
||||
s, err := ToMemoryStreamConfig(nil)
|
||||
|
|
|
@ -14,9 +14,7 @@ import (
|
|||
"github.com/xtls/xray-core/transport/internet"
|
||||
)
|
||||
|
||||
var (
|
||||
globalSessionCache = tls.NewLRUClientSessionCache(128)
|
||||
)
|
||||
var globalSessionCache = tls.NewLRUClientSessionCache(128)
|
||||
|
||||
// ParseCertificate converts a cert.Certificate to Certificate.
|
||||
func ParseCertificate(c *cert.Certificate) *Certificate {
|
||||
|
|
|
@ -11,9 +11,7 @@ import (
|
|||
|
||||
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
||||
|
||||
var (
|
||||
_ buf.Writer = (*Conn)(nil)
|
||||
)
|
||||
var _ buf.Writer = (*Conn)(nil)
|
||||
|
||||
type Conn struct {
|
||||
*tls.Conn
|
||||
|
|
|
@ -12,9 +12,7 @@ import (
|
|||
"github.com/xtls/xray-core/common/serial"
|
||||
)
|
||||
|
||||
var (
|
||||
_ buf.Writer = (*connection)(nil)
|
||||
)
|
||||
var _ buf.Writer = (*connection)(nil)
|
||||
|
||||
// connection is a wrapper for net.Conn over WebSocket connection.
|
||||
type connection struct {
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
//go:embed dialer.html
|
||||
var webpage []byte
|
||||
|
||||
var conns chan *websocket.Conn
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -44,7 +44,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
|
|||
}
|
||||
|
||||
var extraReader io.Reader
|
||||
var responseHeader = http.Header{}
|
||||
responseHeader := http.Header{}
|
||||
if str := request.Header.Get("Sec-WebSocket-Protocol"); str != "" {
|
||||
if ed, err := base64.RawURLEncoding.DecodeString(replacer.Replace(str)); err == nil && len(ed) > 0 {
|
||||
extraReader = bytes.NewReader(ed)
|
||||
|
@ -94,7 +94,7 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet
|
|||
}
|
||||
var listener net.Listener
|
||||
var err error
|
||||
if port == net.Port(0) { //unix
|
||||
if port == net.Port(0) { // unix
|
||||
listener, err = internet.ListenSystem(ctx, &net.UnixAddr{
|
||||
Name: address.Domain(),
|
||||
Net: "unix",
|
||||
|
@ -107,7 +107,7 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet
|
|||
if locker != nil {
|
||||
l.locker = locker.(*internet.FileLocker)
|
||||
}
|
||||
} else { //tcp
|
||||
} else { // tcp
|
||||
listener, err = internet.ListenSystem(ctx, &net.TCPAddr{
|
||||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
|
|
|
@ -15,9 +15,7 @@ import (
|
|||
"github.com/xtls/xray-core/transport/internet"
|
||||
)
|
||||
|
||||
var (
|
||||
globalSessionCache = xtls.NewLRUClientSessionCache(128)
|
||||
)
|
||||
var globalSessionCache = xtls.NewLRUClientSessionCache(128)
|
||||
|
||||
// ParseCertificate converts a cert.Certificate to Certificate.
|
||||
func ParseCertificate(c *cert.Certificate) *Certificate {
|
||||
|
|
|
@ -40,8 +40,10 @@ type pipe struct {
|
|||
state state
|
||||
}
|
||||
|
||||
var errBufferFull = errors.New("buffer full")
|
||||
var errSlowDown = errors.New("slow down")
|
||||
var (
|
||||
errBufferFull = errors.New("buffer full")
|
||||
errSlowDown = errors.New("slow down")
|
||||
)
|
||||
|
||||
func (p *pipe) getState(forRead bool) error {
|
||||
switch p.state {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue