mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 14:57:44 -05:00
fix coding style issue
This commit is contained in:
parent
8a3e90c11f
commit
d7ad10ff14
@ -7,7 +7,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context {
|
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{} {
|
func EnvironmentFromContext(ctx context.Context) interface{} {
|
||||||
|
@ -2,6 +2,7 @@ package environment
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v5/common/platform/filesystem/fsifce"
|
"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/features/extension/storage"
|
||||||
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
||||||
|
@ -4,9 +4,10 @@ package transientstorageimpl
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewScopedTransientStorageImpl() storage.ScopedTransientStorage {
|
func NewScopedTransientStorageImpl() storage.ScopedTransientStorage {
|
||||||
@ -44,7 +45,7 @@ func (s *scopedTransientStorageImpl) List(ctx context.Context, keyPrefix string)
|
|||||||
s.access.Lock()
|
s.access.Lock()
|
||||||
defer s.access.Unlock()
|
defer s.access.Unlock()
|
||||||
var ret []string
|
var ret []string
|
||||||
for key, _ := range s.values {
|
for key := range s.values {
|
||||||
if strings.HasPrefix(key, keyPrefix) {
|
if strings.HasPrefix(key, keyPrefix) {
|
||||||
ret = append(ret, key)
|
ret = append(ret, key)
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
|
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
|
||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v5/common"
|
"github.com/v2fly/v2ray-core/v5/common"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package inbound
|
package inbound
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/v2fly/v2ray-core/v5/common/buf"
|
|
||||||
"github.com/v2fly/v2ray-core/v5/common/signal/done"
|
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"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 {
|
func newUDPConnAdaptor(conn net.Conn, done *done.Instance) net.Conn {
|
||||||
|
@ -2,7 +2,11 @@ package inbound
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/mustafaturan/bus"
|
"io"
|
||||||
|
gonet "net"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v5/common"
|
"github.com/v2fly/v2ray-core/v5/common"
|
||||||
"github.com/v2fly/v2ray-core/v5/common/environment"
|
"github.com/v2fly/v2ray-core/v5/common/environment"
|
||||||
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
|
"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/common/signal/done"
|
||||||
"github.com/v2fly/v2ray-core/v5/features/routing"
|
"github.com/v2fly/v2ray-core/v5/features/routing"
|
||||||
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
||||||
|
|
||||||
|
"github.com/mustafaturan/bus"
|
||||||
"github.com/xiaokangwang/VLite/interfaces"
|
"github.com/xiaokangwang/VLite/interfaces"
|
||||||
"github.com/xiaokangwang/VLite/interfaces/ibus"
|
"github.com/xiaokangwang/VLite/interfaces/ibus"
|
||||||
"github.com/xiaokangwang/VLite/transport"
|
"github.com/xiaokangwang/VLite/transport"
|
||||||
@ -20,10 +26,6 @@ import (
|
|||||||
"github.com/xiaokangwang/VLite/transport/udp/udpuni/udpunis"
|
"github.com/xiaokangwang/VLite/transport/udp/udpuni/udpunis"
|
||||||
"github.com/xiaokangwang/VLite/transport/uni/uniserver"
|
"github.com/xiaokangwang/VLite/transport/uni/uniserver"
|
||||||
"github.com/xiaokangwang/VLite/workers/server"
|
"github.com/xiaokangwang/VLite/workers/server"
|
||||||
"io"
|
|
||||||
gonet "net"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
|
//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
|
||||||
@ -60,17 +62,17 @@ type status struct {
|
|||||||
access sync.Mutex
|
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 {
|
func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Context { //nolint:revive
|
||||||
S_S2CTraffic := make(chan server.UDPServerTxToClientTraffic, 8)
|
S_S2CTraffic := make(chan server.UDPServerTxToClientTraffic, 8) //nolint:revive
|
||||||
S_S2CDataTraffic := make(chan server.UDPServerTxToClientDataTraffic, 8)
|
S_S2CDataTraffic := make(chan server.UDPServerTxToClientDataTraffic, 8) //nolint:revive
|
||||||
S_C2STraffic := make(chan server.UDPServerRxFromClientTraffic, 8)
|
S_C2STraffic := make(chan server.UDPServerRxFromClientTraffic, 8) //nolint:revive
|
||||||
|
|
||||||
S_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
S_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
S_S2CDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
S_S2CDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
S_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
S_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
for {
|
for {
|
||||||
@ -92,7 +94,6 @@ func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Co
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}(connctx)
|
}(connctx)
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
@ -104,7 +105,6 @@ func (s *status) Connection(conn gonet.Conn, connctx context.Context) context.Co
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}(connctx)
|
}(connctx)
|
||||||
|
|
||||||
if !s.config.EnableStabilization || !s.config.EnableRenegotiation {
|
if !s.config.EnableStabilization || !s.config.EnableRenegotiation {
|
||||||
@ -126,21 +126,21 @@ func createStatusFromConfig(config *UDPProtocolConfig) (*status, error) {
|
|||||||
s.password = []byte(config.Password)
|
s.password = []byte(config.Password)
|
||||||
|
|
||||||
s.msgbus = ibus.NewMessageBus()
|
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 {
|
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 {
|
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 {
|
if config.HandshakeMaskingPaddingSize != 0 {
|
||||||
ctxv := &interfaces.ExtraOptionsUsePacketArmorValue{PacketArmorPaddingTo: int(config.HandshakeMaskingPaddingSize), UsePacketArmor: true}
|
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
|
return s, nil
|
||||||
|
@ -3,7 +3,20 @@ package outbound
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mustafaturan/bus"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v5/common/environment"
|
"github.com/v2fly/v2ray-core/v5/common/environment"
|
||||||
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
||||||
"github.com/v2fly/v2ray-core/v5/transport/internet/udp"
|
"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"
|
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 {
|
if packetConn, err := packetaddr.ToPacketAddrConn(link, destination); err == nil {
|
||||||
requestDone := func() error {
|
requestDone := func() error {
|
||||||
|
|
||||||
return udp.CopyPacketConn(packetConnOut, packetConn, udp.UpdateActivity(timer))
|
return udp.CopyPacketConn(packetConnOut, packetConn, udp.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
responseDone := func() error {
|
responseDone := func() error {
|
||||||
|
|
||||||
return udp.CopyPacketConn(packetConn, packetConnOut, udp.UpdateActivity(timer))
|
return udp.CopyPacketConn(packetConn, packetConnOut, udp.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
responseDoneAndCloseWriter := task.OnSuccess(responseDone, task.Close(link.Writer))
|
responseDoneAndCloseWriter := task.OnSuccess(responseDone, task.Close(link.Writer))
|
||||||
@ -122,21 +122,21 @@ func createStatusFromConfig(config *UDPProtocolConfig) (*status, error) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
s.msgbus = ibus.NewMessageBus()
|
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 {
|
if config.EnableFec {
|
||||||
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPFECEnabled, true)
|
ctx = context.WithValue(ctx, interfaces.ExtraOptionsUDPFECEnabled, true) //nolint:revive
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.ScramblePacket {
|
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 {
|
if config.HandshakeMaskingPaddingSize != 0 {
|
||||||
ctxv := &interfaces.ExtraOptionsUsePacketArmorValue{PacketArmorPaddingTo: int(config.HandshakeMaskingPaddingSize), UsePacketArmor: true}
|
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)
|
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)
|
return newError("unable to connect to remote").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
C_C2STraffic := make(chan client2.UDPClientTxToServerTraffic, 8)
|
C_C2STraffic := make(chan client2.UDPClientTxToServerTraffic, 8) //nolint:revive
|
||||||
C_C2SDataTraffic := make(chan client2.UDPClientTxToServerDataTraffic, 8)
|
C_C2SDataTraffic := make(chan client2.UDPClientTxToServerDataTraffic, 8) //nolint:revive
|
||||||
C_S2CTraffic := make(chan client2.UDPClientRxFromServerTraffic, 8)
|
C_S2CTraffic := make(chan client2.UDPClientRxFromServerTraffic, 8) //nolint:revive
|
||||||
|
|
||||||
C_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
C_C2STraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
C_C2SDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
C_C2SDataTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
C_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8)
|
C_S2CTraffic2 := make(chan interfaces.TrafficWithChannelTag, 8) //nolint:revive
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
for {
|
for {
|
||||||
@ -173,7 +173,6 @@ func enableInterface(s *status) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}(connctx)
|
}(connctx)
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
@ -185,7 +184,6 @@ func enableInterface(s *status) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}(connctx)
|
}(connctx)
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
@ -197,7 +195,6 @@ func enableInterface(s *status) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}(connctx)
|
}(connctx)
|
||||||
|
|
||||||
TunnelTxToTun := make(chan interfaces.UDPPacket)
|
TunnelTxToTun := make(chan interfaces.UDPPacket)
|
||||||
|
Loading…
Reference in New Issue
Block a user