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:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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{} {
|
||||
|
||||
@@ -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.Tfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user