1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

fix coding style issue

This commit is contained in:
Shelikhoo 2022-04-29 21:36:26 +01:00
parent 8a3e90c11f
commit d7ad10ff14
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
7 changed files with 53 additions and 52 deletions

View File

@ -7,7 +7,7 @@ const (
)
func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context {
return context.WithValue(ctx, environmentKey, environment)
return context.WithValue(ctx, environmentKey, environment) //nolint: revive
}
func EnvironmentFromContext(ctx context.Context) interface{} {

View File

@ -2,6 +2,7 @@ package environment
import (
"context"
"github.com/v2fly/v2ray-core/v5/common/platform/filesystem/fsifce"
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
"github.com/v2fly/v2ray-core/v5/transport/internet"

View File

@ -4,9 +4,10 @@ package transientstorageimpl
import (
"context"
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
"strings"
"sync"
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
)
func NewScopedTransientStorageImpl() storage.ScopedTransientStorage {
@ -44,7 +45,7 @@ func (s *scopedTransientStorageImpl) List(ctx context.Context, keyPrefix string)
s.access.Lock()
defer s.access.Unlock()
var ret []string
for key, _ := range s.values {
for key := range s.values {
if strings.HasPrefix(key, keyPrefix) {
ret = append(ret, key)
}

View File

@ -3,6 +3,7 @@ package core
import (
"bytes"
"context"
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
"github.com/v2fly/v2ray-core/v5/common"

View File

@ -1,10 +1,11 @@
package inbound
import (
"github.com/v2fly/v2ray-core/v5/common/buf"
"github.com/v2fly/v2ray-core/v5/common/signal/done"
"io"
"net"
"github.com/v2fly/v2ray-core/v5/common/buf"
"github.com/v2fly/v2ray-core/v5/common/signal/done"
)
func newUDPConnAdaptor(conn net.Conn, done *done.Instance) net.Conn {

View File

@ -2,7 +2,11 @@ package inbound
import (
"context"
"github.com/mustafaturan/bus"
"io"
gonet "net"
"strconv"
"sync"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/environment"
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
@ -11,6 +15,8 @@ import (
"github.com/v2fly/v2ray-core/v5/common/signal/done"
"github.com/v2fly/v2ray-core/v5/features/routing"
"github.com/v2fly/v2ray-core/v5/transport/internet"
"github.com/mustafaturan/bus"
"github.com/xiaokangwang/VLite/interfaces"
"github.com/xiaokangwang/VLite/interfaces/ibus"
"github.com/xiaokangwang/VLite/transport"
@ -20,10 +26,6 @@ import (
"github.com/xiaokangwang/VLite/transport/udp/udpuni/udpunis"
"github.com/xiaokangwang/VLite/transport/uni/uniserver"
"github.com/xiaokangwang/VLite/workers/server"
"io"
gonet "net"
"strconv"
"sync"
)
//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
@ -60,17 +62,17 @@ type status struct {
access sync.Mutex
}
func (s *status) RelayStream(conn io.ReadWriteCloser, ctx context.Context) {
func (s *status) RelayStream(conn io.ReadWriteCloser, ctx context.Context) { //nolint:revive
}
func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Context {
S_S2CTraffic := make(chan server.UDPServerTxToClientTraffic, 8)
S_S2CDataTraffic := make(chan server.UDPServerTxToClientDataTraffic, 8)
S_C2STraffic := make(chan server.UDPServerRxFromClientTraffic, 8)
func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Context { //nolint:revive
S_S2CTraffic := make(chan server.UDPServerTxToClientTraffic, 8) //nolint:revive
S_S2CDataTraffic := make(chan server.UDPServerTxToClientDataTraffic, 8) //nolint:revive
S_C2STraffic := make(chan server.UDPServerRxFromClientTraffic, 8) //nolint:revive
S_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
S_S2CDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
S_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
S_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
S_S2CDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
S_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
go func(ctx context.Context) {
for {
@ -92,7 +94,6 @@ func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Co
return
}
}
}(connctx)
go func(ctx context.Context) {
@ -104,7 +105,6 @@ func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Co
return
}
}
}(connctx)
if !s.config.EnableStabilization || !s.config.EnableRenegotiation {
@ -126,21 +126,21 @@ func createStatusFromConfig(config *UDPProtocolConfig) (*status, error) {
s.password = []byte(config.Password)
s.msgbus = ibus.NewMessageBus()
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsMessageBus, s.msgbus)
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsMessageBus, s.msgbus) //nolint:revive
if config.ScramblePacket {
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPShouldMask, true)
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPShouldMask, true) //nolint:revive
}
if s.config.EnableFec {
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPFECEnabled, true)
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPFECEnabled, true) //nolint:revive
}
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPMask, string(s.password))
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUDPMask, string(s.password)) //nolint:revive
if config.HandshakeMaskingPaddingSize != 0 {
ctxv := &interfaces.ExtraOptionsUsePacketArmorValue{PacketArmorPaddingTo: int(config.HandshakeMaskingPaddingSize), UsePacketArmor: true}
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUsePacketArmor, ctxv)
s.ctx = context.WithValue(s.ctx, interfaces.ExtraOptionsUsePacketArmor, ctxv) //nolint:revive
}
return s, nil

View File

@ -3,7 +3,20 @@ package outbound
import (
"context"
"fmt"
"sync"
"time"
"github.com/mustafaturan/bus"
"github.com/xiaokangwang/VLite/ass/udpconn2tun"
"github.com/xiaokangwang/VLite/interfaces"
"github.com/xiaokangwang/VLite/interfaces/ibus"
vltransport "github.com/xiaokangwang/VLite/transport"
udpsctpserver "github.com/xiaokangwang/VLite/transport/packetsctp/sctprelay"
"github.com/xiaokangwang/VLite/transport/packetuni/puniClient"
"github.com/xiaokangwang/VLite/transport/udp/udpClient"
"github.com/xiaokangwang/VLite/transport/udp/udpuni/udpunic"
"github.com/xiaokangwang/VLite/transport/uni/uniclient"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/environment"
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
@ -15,17 +28,6 @@ import (
"github.com/v2fly/v2ray-core/v5/transport"
"github.com/v2fly/v2ray-core/v5/transport/internet"
"github.com/v2fly/v2ray-core/v5/transport/internet/udp"
"github.com/xiaokangwang/VLite/ass/udpconn2tun"
"github.com/xiaokangwang/VLite/interfaces"
"github.com/xiaokangwang/VLite/interfaces/ibus"
vltransport "github.com/xiaokangwang/VLite/transport"
udpsctpserver "github.com/xiaokangwang/VLite/transport/packetsctp/sctprelay"
"github.com/xiaokangwang/VLite/transport/packetuni/puniClient"
"github.com/xiaokangwang/VLite/transport/udp/udpClient"
"github.com/xiaokangwang/VLite/transport/udp/udpuni/udpunic"
"github.com/xiaokangwang/VLite/transport/uni/uniclient"
"sync"
"time"
client2 "github.com/xiaokangwang/VLite/workers/client"
)
@ -70,11 +72,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
if packetConn, err := packetaddr.ToPacketAddrConn(link, destination); err == nil {
requestDone := func() error {
return udp.CopyPacketConn(packetConnOut, packetConn, udp.UpdateActivity(timer))
}
responseDone := func() error {
return udp.CopyPacketConn(packetConn, packetConnOut, udp.UpdateActivity(timer))
}
responseDoneAndCloseWriter := task.OnSuccess(responseDone, task.Close(link.Writer))
@ -122,21 +122,21 @@ func createStatusFromConfig(config *UDPProtocolConfig) (*status, error) {
ctx := context.Background()
s.msgbus = ibus.NewMessageBus()
ctx = context.WithValue(ctx, interfaces.ExtraOptionsMessageBus, s.msgbus)
ctx = context.WithValue(ctx, interfaces.ExtraOptionsMessageBus, s.msgbus) //nolint:revive
if config.EnableFec {
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPFECEnabled, true)
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPFECEnabled, true) //nolint:revive
}
if config.ScramblePacket {
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPShouldMask, true)
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPShouldMask, true) //nolint:revive
}
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPMask, string(s.password))
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPMask, string(s.password)) //nolint:revive
if config.HandshakeMaskingPaddingSize != 0 {
ctxv := &interfaces.ExtraOptionsUsePacketArmorValue{PacketArmorPaddingTo: int(config.HandshakeMaskingPaddingSize), UsePacketArmor: true}
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUsePacketArmor, ctxv)
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUsePacketArmor, ctxv) //nolint:revive
}
destinationString := fmt.Sprintf("%v:%v", config.Address.AsAddress().String(), config.Port)
@ -156,13 +156,13 @@ func enableInterface(s *status) error {
return newError("unable to connect to remote").Base(err)
}
C_C2STraffic := make(chan client2.UDPClientTxToServerTraffic, 8)
C_C2SDataTraffic := make(chan client2.UDPClientTxToServerDataTraffic, 8)
C_S2CTraffic := make(chan client2.UDPClientRxFromServerTraffic, 8)
C_C2STraffic := make(chan client2.UDPClientTxToServerTraffic, 8) //nolint:revive
C_C2SDataTraffic := make(chan client2.UDPClientTxToServerDataTraffic, 8) //nolint:revive
C_S2CTraffic := make(chan client2.UDPClientRxFromServerTraffic, 8) //nolint:revive
C_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
C_C2SDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
C_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
C_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
C_C2SDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
C_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
go func(ctx context.Context) {
for {
@ -173,7 +173,6 @@ func enableInterface(s *status) error {
return
}
}
}(connctx)
go func(ctx context.Context) {
@ -185,7 +184,6 @@ func enableInterface(s *status) error {
return
}
}
}(connctx)
go func(ctx context.Context) {
@ -197,7 +195,6 @@ func enableInterface(s *status) error {
return
}
}
}(connctx)
TunnelTxToTun := make(chan interfaces.UDPPacket)