𐲓𐳛𐳪𐳂𐳐 𐲀𐳢𐳦𐳫𐳢 𐲥𐳔𐳛𐳪𐳌𐳑𐳖𐳇
2026-05-29 23:04:59 +08:00
committed by GitHub
parent ca4b156b57
commit d43a808ea5
114 changed files with 736 additions and 378 deletions
+5 -3
View File
@@ -190,9 +190,11 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st
}
}
if err := dispatcher.DispatchLink(ctx, dest, &transport.Link{
Reader: reader,
Writer: writer},
if err := dispatcher.DispatchLink(
ctx, dest, &transport.Link{
Reader: reader,
Writer: writer,
},
); err != nil {
return errors.New("failed to dispatch request").Base(err)
}
+9 -7
View File
@@ -30,10 +30,12 @@ import (
"github.com/xtls/xray-core/transport/internet/stat"
)
var useSplice bool
var allNetworks [8]bool
var defaultBlockPrivateRule *FinalRule
var defaultBlockAllRule *FinalRule
var (
useSplice bool
allNetworks [8]bool
defaultBlockPrivateRule *FinalRule
defaultBlockAllRule *FinalRule
)
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
@@ -677,7 +679,7 @@ type NoisePacketWriter struct {
func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
if w.firstWrite {
w.firstWrite = false
//Do not send Noise for dns requests(just to be safe)
// Do not send Noise for dns requests(just to be safe)
if w.UDPOverride.Port == 53 {
return w.Writer.WriteMultiBuffer(mb)
}
@@ -700,11 +702,11 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
default:
panic("unreachable, applyTo is ip/ipv4/ipv6")
}
//User input string or base64 encoded string or hex string
// User input string or base64 encoded string or hex string
if n.Packet != nil {
noise = n.Packet
} else {
//Random noise
// Random noise
noise, err = GenerateRandomBytes(crypto.RandBetween(int64(n.LengthMin),
int64(n.LengthMax)))
}
+5 -3
View File
@@ -192,9 +192,11 @@ func (s *Server) handleConnect(ctx context.Context, _ *http.Request, buffer *buf
if inbound.CanSpliceCopy == 2 {
inbound.CanSpliceCopy = 1
}
if err := dispatcher.DispatchLink(ctx, dest, &transport.Link{
Reader: reader,
Writer: buf.NewWriter(conn)},
if err := dispatcher.DispatchLink(
ctx, dest, &transport.Link{
Reader: reader,
Writer: buf.NewWriter(conn),
},
); err != nil {
return errors.New("failed to dispatch request").Base(err)
}
+1 -1
View File
@@ -113,7 +113,7 @@ func (v *Validator) GetAll() []*protocol.MemoryUser {
v.mutex.Lock()
defer v.mutex.Unlock()
var users = make([]*protocol.MemoryUser, 0, len(v.users))
users := make([]*protocol.MemoryUser, 0, len(v.users))
for _, user := range v.users {
users = append(users, user)
}
+1 -1
View File
@@ -743,7 +743,7 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net
for {
inbound := session.InboundFromContext(ctx)
outbounds := session.OutboundsFromContext(ctx)
var splice = inbound.CanSpliceCopy == 1
splice := inbound.CanSpliceCopy == 1
for _, ob := range outbounds {
if ob.CanSpliceCopy != 1 {
splice = false
+5 -3
View File
@@ -153,9 +153,11 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche
if inbound.CanSpliceCopy == 2 {
inbound.CanSpliceCopy = 1
}
if err := dispatcher.DispatchLink(ctx, dest, &transport.Link{
Reader: reader,
Writer: buf.NewWriter(conn)},
if err := dispatcher.DispatchLink(
ctx, dest, &transport.Link{
Reader: reader,
Writer: buf.NewWriter(conn),
},
); err != nil {
return errors.New("failed to dispatch request").Base(err)
}
+1
View File
@@ -4,6 +4,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"google.golang.org/protobuf/proto"
"github.com/xtls/xray-core/common"
-1
View File
@@ -312,7 +312,6 @@ func (s *Server) handleUDPPayload(ctx context.Context, sessionPolicy policy.Sess
}
}
}
}
if err := task.Run(ctx, requestDone); err != nil {
+1 -1
View File
@@ -63,7 +63,7 @@ func (v *Validator) GetByEmail(email string) *protocol.MemoryUser {
// Get all users
func (v *Validator) GetAll() []*protocol.MemoryUser {
var u = make([]*protocol.MemoryUser, 0, 100)
u := make([]*protocol.MemoryUser, 0, 100)
v.email.Range(func(key, value interface{}) bool {
u = append(u, value.(*protocol.MemoryUser))
return true
+1 -1
View File
@@ -69,7 +69,7 @@ func (t *stackGVisor) Start() error {
tcpForwarder := tcp.NewForwarder(ipStack, 0, 65535, func(r *tcp.ForwarderRequest) {
go func(r *tcp.ForwarderRequest) {
var wq waiter.Queue
var id = r.ID()
id := r.ID()
// Perform a TCP three-way handshake.
ep, err := r.CreateEndpoint(&wq)
-2
View File
@@ -68,7 +68,6 @@ func (e *LinkEndpoint) IsAttached() bool {
}
func (e *LinkEndpoint) Wait() {
}
func (e *LinkEndpoint) ARPHardwareType() header.ARPHardwareType {
@@ -91,7 +90,6 @@ func (e *LinkEndpoint) Close() {
}
func (e *LinkEndpoint) SetOnCloseAction(_ func()) {
}
func (e *LinkEndpoint) WritePackets(packetBufferList stack.PacketBufferList) (int, tcpip.Error) {
+4 -2
View File
@@ -44,8 +44,10 @@ type DarwinTun struct {
ownsFd bool // true for macOS (we created the fd), false for iOS (fd from system)
}
var _ Tun = (*DarwinTun)(nil)
var _ GVisorDevice = (*DarwinTun)(nil)
var (
_ Tun = (*DarwinTun)(nil)
_ GVisorDevice = (*DarwinTun)(nil)
)
func NewTun(options *Config) (Tun, error) {
// Check if fd is provided via environment (iOS mode)
+1 -2
View File
@@ -9,8 +9,7 @@ import (
"gvisor.dev/gvisor/pkg/tcpip/stack"
)
type DefaultTun struct {
}
type DefaultTun struct{}
// DefaultTun implements Tun
var _ Tun = (*DefaultTun)(nil)
+4 -2
View File
@@ -27,8 +27,10 @@ type FreeBSDTun struct {
mtu uint32
}
var _ Tun = (*FreeBSDTun)(nil)
var _ GVisorDevice = (*FreeBSDTun)(nil)
var (
_ Tun = (*FreeBSDTun)(nil)
_ GVisorDevice = (*FreeBSDTun)(nil)
)
// NewTun builds new tun interface handler
func NewTun(options *Config) (Tun, error) {
+2 -2
View File
@@ -53,7 +53,7 @@ func TestRequestSerialization(t *testing.T) {
}
addonsComparer := func(x, y *Addons) bool {
return (x.Flow == y.Flow) && (cmp.Equal(x.Seed, y.Seed))
return (x.Flow == y.Flow) && cmp.Equal(x.Seed, y.Seed)
}
if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(addonsComparer)); r != "" {
t.Error(r)
@@ -125,7 +125,7 @@ func TestMuxRequest(t *testing.T) {
}
addonsComparer := func(x, y *Addons) bool {
return (x.Flow == y.Flow) && (cmp.Equal(x.Seed, y.Seed))
return (x.Flow == y.Flow) && cmp.Equal(x.Seed, y.Seed)
}
if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(addonsComparer)); r != "" {
t.Error(r)
+1 -1
View File
@@ -79,7 +79,7 @@ func (i *ClientInstance) Handshake(conn net.Conn) (*CommonConn, error) {
var nfsKey []byte
var lastCTR cipher.Stream
for j, k := range i.NfsPKeys {
var index = 32
index := 32
if k, ok := k.(*ecdh.PublicKey); ok {
privateKey, _ := ecdh.X25519().GenerateKey(rand.Reader)
copy(relays, privateKey.PublicKey().Bytes())
+1 -1
View File
@@ -135,7 +135,7 @@ func (i *ServerInstance) Handshake(conn net.Conn, fallback *[]byte) (*CommonConn
if lastCTR != nil {
lastCTR.XORKeyStream(relays, relays[:32]) // recover this relay
}
var index = 32
index := 32
if _, ok := k.(*mlkem.DecapsulationKey768); ok {
index = 1088
}
+5 -3
View File
@@ -630,9 +630,11 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
return r.NewMux(ctx, dispatcher.WrapLink(ctx, h.policyManager, h.stats, &transport.Link{Reader: clientReader, Writer: clientWriter}), h.observer)
}
if err := dispatch.DispatchLink(ctx, request.Destination(), &transport.Link{
Reader: clientReader,
Writer: clientWriter},
if err := dispatch.DispatchLink(
ctx, request.Destination(), &transport.Link{
Reader: clientReader,
Writer: clientWriter,
},
); err != nil {
return errors.New("failed to dispatch request").Base(err)
}
+1 -1
View File
@@ -79,7 +79,7 @@ func (v *MemoryValidator) GetByEmail(email string) *protocol.MemoryUser {
// Get all users
func (v *MemoryValidator) GetAll() []*protocol.MemoryUser {
var u = make([]*protocol.MemoryUser, 0, 100)
u := make([]*protocol.MemoryUser, 0, 100)
v.email.Range(func(key, value interface{}) bool {
u = append(u, value.(*protocol.MemoryUser))
return true
+3 -2
View File
@@ -1,9 +1,10 @@
package vmess
import (
"google.golang.org/protobuf/proto"
"strings"
"google.golang.org/protobuf/proto"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/uuid"
@@ -30,7 +31,7 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool {
}
func (a *MemoryAccount) ToProto() proto.Message {
var test = ""
test := ""
if a.AuthenticatedLengthExperiment {
test = "AuthenticatedLength|"
}
+2 -1
View File
@@ -138,7 +138,8 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
func (h *Handler) Close() error {
return errors.Combine(
h.sessionHistory.Close(),
common.Close(h.usersByEmail))
common.Close(h.usersByEmail),
)
}
// Network implements proxy.Inbound.Network().
-1
View File
@@ -1,7 +1,6 @@
package outbound
import (
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"
)
+1 -3
View File
@@ -224,9 +224,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
return nil
}
var (
enablePadding = false
)
var enablePadding = false
func shouldEnablePadding(s protocol.SecurityType) bool {
return enablePadding || s == protocol.SecurityType_AES128_GCM || s == protocol.SecurityType_CHACHA20_POLY1305 || s == protocol.SecurityType_AUTO
-1
View File
@@ -134,7 +134,6 @@ func (bind *netBindClient) connectTo(endpoint *netEndpoint) error {
for {
buff := buf.NewWithSize(device.MaxMessageSize)
n, err := buff.ReadFrom(c)
if err != nil {
buff.Release()
endpoint.conn = nil
-1
View File
@@ -162,7 +162,6 @@ func (s *Server) forwardConnection(dest net.Destination, conn net.Conn) {
Reader: buf.NewReader(conn),
Writer: buf.NewWriter(conn),
})
if err != nil {
errors.LogInfoInner(ctx, err, "connection ends")
}
+2 -1
View File
@@ -2,10 +2,11 @@ package wireguard_test
import (
"context"
"github.com/stretchr/testify/assert"
"runtime/debug"
"testing"
"github.com/stretchr/testify/assert"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/proxy/wireguard"
)
+1 -1
View File
@@ -156,7 +156,7 @@ func createGVisorTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo
tcpForwarder := tcp.NewForwarder(gstack, 0, 65535, func(r *tcp.ForwarderRequest) {
go func(r *tcp.ForwarderRequest) {
var wq waiter.Queue
var id = r.ID()
id := r.ID()
ep, err := r.CreateEndpoint(&wq)
if err != nil {