This commit is contained in:
MHSanaei 2024-07-12 00:20:06 +02:00 committed by GitHub
parent c69d38ae82
commit 16de0937a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 72 additions and 72 deletions

View file

@ -83,7 +83,7 @@ jobs:
- goarch: 386
goos: darwin
include:
# BEIGIN MacOS ARM64
# BEGIN MacOS ARM64
- goos: darwin
goarch: arm64
# END MacOS ARM64

View file

@ -3,13 +3,13 @@ NAME = xray
VERSION=$(shell git describe --always --dirty)
# NOTE: This MAKEFILE can be used to build Xray-core locally and in Automatic workflows. It is \
provided for convinience in automatic building and functions as a part of it.
provided for convenience in automatic building and functions as a part of it.
# NOTE: If you need to modify this file, please be aware that:\
- This file is not the main Makefile; it only accepts environment variables and builds the \
binary.\
- Automatic building expects the correct binaries to be built by this Makefile. If you \
intend to propose a change to this Makefile, carefully review the file below and ensure \
that the change will not accidently break the automatic building:\
that the change will not accidentally break the automatic building:\
.github/workflows/release.yml \
Otherwise it is recommended to contact the project maintainers.

View file

@ -85,7 +85,7 @@ func NewClient(
return errors.New("failed to create nameserver").Base(err).AtWarning()
}
// Priotize local domains with specific TLDs or without any dot to local DNS
// Prioritize local domains with specific TLDs or those without any dot for the local DNS
if _, isLocalDNS := server.(*LocalNameServer); isLocalDNS {
ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...)
ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule)

View file

@ -259,7 +259,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n
})
// forced to use mux for DOH
// dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
// dnsCtx = session.ContextWithMuxPreferred(dnsCtx, true)
var cancel context.CancelFunc
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)

View file

@ -30,8 +30,8 @@ func New(ctx context.Context, config *Config) (*Instance, error) {
}
log.RegisterHandler(g)
// start logger instantly on inited
// other modules would log during init
// Start logger instantly on initialization
// Other modules would log during initialization
if err := g.startInternal(); err != nil {
return nil, err
}

View file

@ -209,7 +209,7 @@ func (h *HealthPing) PutResult(tag string, rtt time.Duration) {
if !ok {
// validity is 2 times to sampling period, since the check are
// distributed in the time line randomly, in extreme cases,
// previous checks are distributed on the left, and latters
// Previous checks are distributed on the left, and later ones
// on the right
validity := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) * 2
r = NewHealthPingResult(h.Settings.SamplingCount, validity)

View file

@ -272,7 +272,7 @@ func TestServiceSubscribeSubsetOfFields(t *testing.T) {
}
}
func TestSerivceTestRoute(t *testing.T) {
func TestServiceTestRoute(t *testing.T) {
c := stats.NewChannel(&stats.ChannelConfig{
SubscriberLimit: 1,
BufferSize: 16,

View file

@ -95,7 +95,7 @@ func TestStatsChannel(t *testing.T) {
}
}
func TestStatsChannelUnsubcribe(t *testing.T) {
func TestStatsChannelUnsubscribe(t *testing.T) {
c := NewChannel(&ChannelConfig{Blocking: true})
common.Must(c.Start())
defer c.Close()

View file

@ -18,7 +18,7 @@ func TestStatsCounter(t *testing.T) {
common.Must(err)
if v := c.Add(1); v != 1 {
t.Fatal("unpexcted Add(1) return: ", v, ", wanted ", 1)
t.Fatal("unexpected Add(1) return: ", v, ", wanted ", 1)
}
if v := c.Set(0); v != 1 {

View file

@ -106,7 +106,7 @@ func TestMultiBufferReadAllToByte(t *testing.T) {
common.Must(err)
if l := len(b); l != 8*1024 {
t.Error("unexpceted length from ReadAllToBytes", l)
t.Error("unexpected length from ReadAllToBytes", l)
}
}
{
@ -139,7 +139,7 @@ func TestMultiBufferCopy(t *testing.T) {
mb.Copy(lbdst)
if d := cmp.Diff(lb, lbdst); d != "" {
t.Error("unexpceted different from MultiBufferCopy ", d)
t.Error("unexpected different from MultiBufferCopy ", d)
}
}

View file

@ -41,8 +41,8 @@ type BufferedReader struct {
Reader Reader
// Buffer is the internal buffer to be read from first
Buffer MultiBuffer
// Spliter is a function to read bytes from MultiBuffer
Spliter func(MultiBuffer, []byte) (MultiBuffer, int)
// Splitter is a function to read bytes from MultiBuffer
Splitter func(MultiBuffer, []byte) (MultiBuffer, int)
}
// BufferedBytes returns the number of bytes that is cached in this reader.
@ -59,7 +59,7 @@ func (r *BufferedReader) ReadByte() (byte, error) {
// Read implements io.Reader. It reads from internal buffer first (if available) and then reads from the underlying reader.
func (r *BufferedReader) Read(b []byte) (int, error) {
spliter := r.Spliter
spliter := r.Splitter
if spliter == nil {
spliter = SplitBytes
}

View file

@ -51,8 +51,8 @@ func ConnectionOutputMulti(reader buf.Reader) ConnectionOption {
func ConnectionOutputMultiUDP(reader buf.Reader) ConnectionOption {
return func(c *connection) {
c.reader = &buf.BufferedReader{
Reader: reader,
Spliter: buf.SplitFirstBytes,
Reader: reader,
Splitter: buf.SplitFirstBytes,
}
}
}

View file

@ -19,7 +19,7 @@ func GetToolLocation(file string) string {
return filepath.Join(toolPath, file+".exe")
}
// GetAssetLocation searches for `file` in the excutable dir
// GetAssetLocation searches for `file` in the executable dir
func GetAssetLocation(file string) string {
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
return filepath.Join(assetPath, file)

View file

@ -19,7 +19,7 @@ import (
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
type Certificate struct {
// Cerificate in ASN.1 DER format
// certificate in ASN.1 DER format
Certificate []byte
// Private key in ASN.1 DER format
PrivateKey []byte

View file

@ -147,7 +147,7 @@ func TestTLSHeaders(t *testing.T) {
header, err := SniffTLS(test.input)
if test.err {
if err == nil {
t.Errorf("Exepct error but nil in test %v", test)
t.Errorf("Expect error but nil in test %v", test)
}
} else {
if err != nil {

View file

@ -21,7 +21,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// User is a generic user for all procotols.
// User is a generic user for all protocols.
type User struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache

View file

@ -8,7 +8,7 @@ option java_multiple_files = true;
import "common/serial/typed_message.proto";
// User is a generic user for all procotols.
// User is a generic user for all protocols.
message User {
uint32 level = 1;
string email = 2;

View file

@ -13,16 +13,16 @@ import (
func IndependentCancelCtx(parent context.Context) context.Context
const (
inboundSessionKey ctx.SessionKey = 1
outboundSessionKey ctx.SessionKey = 2
contentSessionKey ctx.SessionKey = 3
muxPreferedSessionKey ctx.SessionKey = 4
sockoptSessionKey ctx.SessionKey = 5
inboundSessionKey ctx.SessionKey = 1
outboundSessionKey ctx.SessionKey = 2
contentSessionKey ctx.SessionKey = 3
muxPreferredSessionKey ctx.SessionKey = 4
sockoptSessionKey ctx.SessionKey = 5
trackedConnectionErrorKey ctx.SessionKey = 6
dispatcherKey ctx.SessionKey = 7
timeoutOnlyKey ctx.SessionKey = 8
allowedNetworkKey ctx.SessionKey = 9
handlerSessionKey ctx.SessionKey = 10
dispatcherKey ctx.SessionKey = 7
timeoutOnlyKey ctx.SessionKey = 8
allowedNetworkKey ctx.SessionKey = 9
handlerSessionKey ctx.SessionKey = 10
)
func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context {
@ -58,14 +58,14 @@ func ContentFromContext(ctx context.Context) *Content {
return nil
}
// ContextWithMuxPrefered returns a new context with the given bool
func ContextWithMuxPrefered(ctx context.Context, forced bool) context.Context {
return context.WithValue(ctx, muxPreferedSessionKey, forced)
// ContextWithMuxPreferred returns a new context with the given bool
func ContextWithMuxPreferred(ctx context.Context, forced bool) context.Context {
return context.WithValue(ctx, muxPreferredSessionKey, forced)
}
// MuxPreferedFromContext returns value in this context, or false if not contained.
func MuxPreferedFromContext(ctx context.Context) bool {
if val, ok := ctx.Value(muxPreferedSessionKey).(bool); ok {
// MuxPreferredFromContext returns value in this context, or false if not contained.
func MuxPreferredFromContext(ctx context.Context) bool {
if val, ok := ctx.Value(muxPreferredSessionKey).(bool); ok {
return val
}
return false

View file

@ -29,7 +29,7 @@ func TestActivityTimerUpdate(t *testing.T) {
timer.SetTimeout(time.Second * 1)
time.Sleep(time.Second * 2)
if ctx.Err() == nil {
t.Error("expcted some error, but got nil")
t.Error("expected some error, but got nil")
}
runtime.KeepAlive(timer)
}

View file

@ -174,7 +174,7 @@ func init() {
common.Must(err)
return loadProtobufConfig(data)
default:
return nil, errors.New("unknow type")
return nil, errors.New("unknown type")
}
},
}))

View file

@ -7,7 +7,7 @@ import (
// CommandEnvHolder is a struct holds the environment info of commands
type CommandEnvHolder struct {
// Excutable name of current binary
// Executable name of current binary
Exec string
// commands column width of current command
CommandsWidth int

View file

@ -43,7 +43,7 @@ func init() {
case io.Reader:
return serial.LoadJSONConfig(v)
default:
return nil, errors.New("unknow type")
return nil, errors.New("unknown type")
}
},
}))

View file

@ -43,7 +43,7 @@ func init() {
case io.Reader:
return serial.LoadTOMLConfig(v)
default:
return nil, errors.New("unknow type")
return nil, errors.New("unknown type")
}
},
}))

View file

@ -43,7 +43,7 @@ func init() {
case io.Reader:
return serial.LoadYAMLConfig(v)
default:
return nil, errors.New("unknow type")
return nil, errors.New("unknown type")
}
},
}))

View file

@ -243,7 +243,7 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
return w.Writer.WriteMultiBuffer(mb)
}
// ReshapeMultiBuffer prepare multi buffer for padding stucture (max 21 bytes)
// ReshapeMultiBuffer prepare multi buffer for padding structure (max 21 bytes)
func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer {
needReshape := 0
for _, b := range buffer {
@ -278,7 +278,7 @@ func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBu
return mb2
}
// XtlsPadding add padding to eliminate length siganature during tls handshake
// XtlsPadding add padding to eliminate length signature during tls handshake
func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer {
var contentLen int32 = 0
var paddingLen int32 = 0

View file

@ -26,7 +26,7 @@ const (
type AuthType int32
const (
// NO_AUTH is for anounymous authentication.
// NO_AUTH is for anonymous authentication.
AuthType_NO_AUTH AuthType = 0
// PASSWORD is for username/password authentication.
AuthType_PASSWORD AuthType = 1

View file

@ -17,7 +17,7 @@ message Account {
// AuthType is the authentication type of Socks proxy.
enum AuthType {
// NO_AUTH is for anounymous authentication.
// NO_AUTH is for anonymous authentication.
NO_AUTH = 0;
// PASSWORD is for username/password authentication.
PASSWORD = 1;

View file

@ -68,7 +68,7 @@ func TestReadUsernamePassword(t *testing.T) {
t.Error("for input: ", testCase.Input, " expect username ", testCase.Username, " but actually ", username)
}
if testCase.Password != password {
t.Error("for input: ", testCase.Input, " expect passowrd ", testCase.Password, " but actually ", password)
t.Error("for input: ", testCase.Input, " expect password ", testCase.Password, " but actually ", password)
}
}
}

View file

@ -9,7 +9,7 @@ import (
In the sock implementation of * ray, UDP authentication is flawed and can be bypassed.
Tracking a UDP connection may be a bit troublesome.
Here is a simple solution.
We creat a filter, add remote IP to the pool when it try to establish a UDP connection with auth.
We create a filter, add remote IP to the pool when it try to establish a UDP connection with auth.
And drop UDP packets from unauthorized IP.
After discussion, we believe it is not necessary to add a timeout mechanism to this filter.
*/

View file

@ -124,7 +124,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
return errors.New("failed to write A request payload").Base(err).AtWarning()
}
// Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer
// Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer
if err = bufferWriter.SetBuffered(false); err != nil {
return errors.New("failed to flush payload").Base(err).AtWarning()
}

View file

@ -223,14 +223,14 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
cs := tlsConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
} else if realityConn, ok := iConn.(*reality.Conn); ok {
cs := realityConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
}
name = strings.ToLower(name)
alpn = strings.ToLower(alpn)
@ -295,7 +295,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
}
if k == '?' || k == ' ' {
path = string(firstBytes[i:j])
errors.LogInfo(ctx, "realPath = " + path)
errors.LogInfo(ctx, "realPath = "+path)
if pfb[path] == nil {
path = ""
}
@ -524,7 +524,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1)
err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, ctx1)
} else {
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
}
@ -552,7 +552,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
if err := clientWriter.WriteMultiBuffer(multiBuffer); err != nil {
return err // ...
}
// Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer
// Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer
if err := bufferWriter.SetBuffered(false); err != nil {
return errors.New("failed to write A response payload").Base(err).AtWarning()
}
@ -561,7 +561,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
if requestAddons.Flow == vless.XRV {
err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, ctx)
} else {
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
}
if err != nil {

View file

@ -219,7 +219,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
} else {
errors.LogDebug(ctx, "Reader is not timeout reader, will send out vless header separately from first payload")
}
// Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer
// Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer
if err := bufferWriter.SetBuffered(false); err != nil {
return errors.New("failed to write A request payload").Base(err).AtWarning()
}
@ -238,7 +238,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice
err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, ctx1)
} else {
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
}
if err != nil {
@ -276,7 +276,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
if requestAddons.Flow == vless.XRV {
err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, ctx)
} else {
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
}

View file

@ -28,7 +28,7 @@ type Config struct {
// Path of the domain socket. This overrides the IP/Port parameter from
// upstream caller.
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
// Abstract speicifies whether to use abstract namespace or not.
// Abstract specifies whether to use abstract namespace or not.
// Traditionally Unix domain socket is file system based. Abstract domain
// socket can be used without acquiring file lock.
Abstract bool `protobuf:"varint,2,opt,name=abstract,proto3" json:"abstract,omitempty"`

View file

@ -10,7 +10,7 @@ message Config {
// Path of the domain socket. This overrides the IP/Port parameter from
// upstream caller.
string path = 1;
// Abstract speicifies whether to use abstract namespace or not.
// Abstract specifies whether to use abstract namespace or not.
// Traditionally Unix domain socket is file system based. Abstract domain
// socket can be used without acquiring file lock.
bool abstract = 2;

View file

@ -374,7 +374,7 @@ type Config struct {
unknownFields protoimpl.UnknownFields
// Settings for authenticating requests. If not set, client side will not send
// authenication header, and server side will bypass authentication.
// authentication header, and server side will bypass authentication.
Request *RequestConfig `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
// Settings for authenticating responses. If not set, client side will bypass
// authentication, and server side will not send authentication header.

View file

@ -56,7 +56,7 @@ message ResponseConfig {
message Config {
// Settings for authenticating requests. If not set, client side will not send
// authenication header, and server side will bypass authentication.
// authentication header, and server side will bypass authentication.
RequestConfig request = 1;
// Settings for authenticating responses. If not set, client side will bypass

View file

@ -2,18 +2,18 @@ package httpupgrade
import "net"
type connnection struct {
type connection struct {
net.Conn
remoteAddr net.Addr
}
func newConnection(conn net.Conn, remoteAddr net.Addr) *connnection {
return &connnection{
func newConnection(conn net.Conn, remoteAddr net.Addr) *connection {
return &connection{
Conn: conn,
remoteAddr: remoteAddr,
}
}
func (c *connnection) RemoteAddr() net.Addr {
func (c *connection) RemoteAddr() net.Addr {
return c.remoteAddr
}

View file

@ -1,6 +1,6 @@
package internet
// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing.
// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce the number of Protobuf parsings.
type MemoryStreamConfig struct {
ProtocolName string
ProtocolSettings interface{}

View file

@ -40,7 +40,7 @@ func ListenUnix(ctx context.Context, address net.Address, settings *MemoryStream
protocol := settings.ProtocolName
listenFunc := transportListenerCache[protocol]
if listenFunc == nil {
return nil, errors.New(protocol, " unix istener not registered.").AtError()
return nil, errors.New(protocol, " unix listener not registered.").AtError()
}
listener, err := listenFunc(ctx, address, net.Port(0), settings, handler)
if err != nil {