1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-18 03:29:12 -04:00

Style: format code by gofumpt (#1022)

This commit is contained in:
Loyalsoldier
2021-05-20 05:28:52 +08:00
committed by GitHub
parent cf009a4ba2
commit 6f8979d017
87 changed files with 249 additions and 270 deletions

View File

@@ -20,9 +20,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) (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 {

View File

@@ -8,8 +8,10 @@ import (
"github.com/v2fly/v2ray-core/v4/transport/internet"
)
const protocolName = "domainsocket"
const sizeofSunPath = 108
const (
protocolName = "domainsocket"
sizeofSunPath = 108
)
func (c *Config) GetUnixAddr() (*net.UnixAddr, error) {
path := c.Path

View File

@@ -44,14 +44,13 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
grpcSettings := streamSettings.ProtocolSettings.(*Config)
config := tls.ConfigFromStreamSettings(streamSettings)
var dialOption = grpc.WithInsecure()
dialOption := grpc.WithInsecure()
if config != nil {
dialOption = grpc.WithTransportCredentials(credentials.NewTLS(config.GetTLSConfig()))
}
conn, err := getGrpcClient(ctx, dest, dialOption)
if err != nil {
return nil, newError("Cannot dial grpc").Base(err)
}

View File

@@ -15,9 +15,7 @@ import (
"github.com/v2fly/v2ray-core/v4/transport/internet/tls"
)
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)

View File

@@ -99,7 +99,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
}

View File

@@ -15,8 +15,10 @@ import (
//
//
const protocolName = "quic"
const internalDomain = "quic.internal.v2fly.org"
const (
protocolName = "quic"
internalDomain = "quic.internal.v2fly.org"
)
func init() {
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {

View File

@@ -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))[:]))
}

View File

@@ -25,7 +25,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
if err := setTFO(syscall.Handle(fd), config.Tfo); err != nil {
return err
}
}
return nil

View File

@@ -9,9 +9,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/session"
)
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)

View File

@@ -11,9 +11,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/session"
)
var (
effectiveListener = DefaultListener{}
)
var effectiveListener = DefaultListener{}
type controller func(network, address string, fd uintptr) error

View File

@@ -6,9 +6,7 @@ import (
"github.com/v2fly/v2ray-core/v4/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 {
@@ -48,6 +46,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)

View File

@@ -16,9 +16,7 @@ import (
"github.com/v2fly/v2ray-core/v4/transport/internet"
)
var (
globalSessionCache = tls.NewLRUClientSessionCache(128)
)
var globalSessionCache = tls.NewLRUClientSessionCache(128)
const exp8357 = "experiment:8357"

View File

@@ -11,9 +11,7 @@ import (
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
var (
_ buf.Writer = (*Conn)(nil)
)
var _ buf.Writer = (*Conn)(nil)
type Conn struct {
*tls.Conn

View File

@@ -15,9 +15,7 @@ import (
"github.com/v2fly/v2ray-core/v4/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 {

View File

@@ -142,8 +142,8 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet
}
l.listener = listener
var useEarlyData = false
var earlyDataHeaderName = ""
useEarlyData := false
earlyDataHeaderName := ""
if wsSettings.MaxEarlyData != 0 {
useEarlyData = true
earlyDataHeaderName = wsSettings.EarlyDataHeaderName

View File

@@ -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 {