mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-24 13:49:19 +02:00
Fix typos (#3527)
This commit is contained in:
parent
c69d38ae82
commit
16de0937a8
|
@ -83,7 +83,7 @@ jobs:
|
||||||
- goarch: 386
|
- goarch: 386
|
||||||
goos: darwin
|
goos: darwin
|
||||||
include:
|
include:
|
||||||
# BEIGIN MacOS ARM64
|
# BEGIN MacOS ARM64
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
# END MacOS ARM64
|
# END MacOS ARM64
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -3,13 +3,13 @@ NAME = xray
|
||||||
VERSION=$(shell git describe --always --dirty)
|
VERSION=$(shell git describe --always --dirty)
|
||||||
|
|
||||||
# NOTE: This MAKEFILE can be used to build Xray-core locally and in Automatic workflows. It is \
|
# 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:\
|
# 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 \
|
- This file is not the main Makefile; it only accepts environment variables and builds the \
|
||||||
binary.\
|
binary.\
|
||||||
- Automatic building expects the correct binaries to be built by this Makefile. If you \
|
- 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 \
|
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 \
|
.github/workflows/release.yml \
|
||||||
Otherwise it is recommended to contact the project maintainers.
|
Otherwise it is recommended to contact the project maintainers.
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ func NewClient(
|
||||||
return errors.New("failed to create nameserver").Base(err).AtWarning()
|
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 {
|
if _, isLocalDNS := server.(*LocalNameServer); isLocalDNS {
|
||||||
ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...)
|
ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...)
|
||||||
ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule)
|
ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule)
|
||||||
|
|
|
@ -259,7 +259,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n
|
||||||
})
|
})
|
||||||
|
|
||||||
// forced to use mux for DOH
|
// forced to use mux for DOH
|
||||||
// dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
|
// dnsCtx = session.ContextWithMuxPreferred(dnsCtx, true)
|
||||||
|
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
|
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
|
||||||
|
|
|
@ -30,8 +30,8 @@ func New(ctx context.Context, config *Config) (*Instance, error) {
|
||||||
}
|
}
|
||||||
log.RegisterHandler(g)
|
log.RegisterHandler(g)
|
||||||
|
|
||||||
// start logger instantly on inited
|
// Start logger instantly on initialization
|
||||||
// other modules would log during init
|
// Other modules would log during initialization
|
||||||
if err := g.startInternal(); err != nil {
|
if err := g.startInternal(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ func (h *HealthPing) PutResult(tag string, rtt time.Duration) {
|
||||||
if !ok {
|
if !ok {
|
||||||
// validity is 2 times to sampling period, since the check are
|
// validity is 2 times to sampling period, since the check are
|
||||||
// distributed in the time line randomly, in extreme cases,
|
// 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
|
// on the right
|
||||||
validity := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) * 2
|
validity := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) * 2
|
||||||
r = NewHealthPingResult(h.Settings.SamplingCount, validity)
|
r = NewHealthPingResult(h.Settings.SamplingCount, validity)
|
||||||
|
|
|
@ -272,7 +272,7 @@ func TestServiceSubscribeSubsetOfFields(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSerivceTestRoute(t *testing.T) {
|
func TestServiceTestRoute(t *testing.T) {
|
||||||
c := stats.NewChannel(&stats.ChannelConfig{
|
c := stats.NewChannel(&stats.ChannelConfig{
|
||||||
SubscriberLimit: 1,
|
SubscriberLimit: 1,
|
||||||
BufferSize: 16,
|
BufferSize: 16,
|
||||||
|
|
|
@ -95,7 +95,7 @@ func TestStatsChannel(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatsChannelUnsubcribe(t *testing.T) {
|
func TestStatsChannelUnsubscribe(t *testing.T) {
|
||||||
c := NewChannel(&ChannelConfig{Blocking: true})
|
c := NewChannel(&ChannelConfig{Blocking: true})
|
||||||
common.Must(c.Start())
|
common.Must(c.Start())
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
|
@ -18,7 +18,7 @@ func TestStatsCounter(t *testing.T) {
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
if v := c.Add(1); v != 1 {
|
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 {
|
if v := c.Set(0); v != 1 {
|
||||||
|
|
|
@ -106,7 +106,7 @@ func TestMultiBufferReadAllToByte(t *testing.T) {
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
if l := len(b); l != 8*1024 {
|
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)
|
mb.Copy(lbdst)
|
||||||
|
|
||||||
if d := cmp.Diff(lb, lbdst); d != "" {
|
if d := cmp.Diff(lb, lbdst); d != "" {
|
||||||
t.Error("unexpceted different from MultiBufferCopy ", d)
|
t.Error("unexpected different from MultiBufferCopy ", d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ type BufferedReader struct {
|
||||||
Reader Reader
|
Reader Reader
|
||||||
// Buffer is the internal buffer to be read from first
|
// Buffer is the internal buffer to be read from first
|
||||||
Buffer MultiBuffer
|
Buffer MultiBuffer
|
||||||
// Spliter is a function to read bytes from MultiBuffer
|
// Splitter is a function to read bytes from MultiBuffer
|
||||||
Spliter func(MultiBuffer, []byte) (MultiBuffer, int)
|
Splitter func(MultiBuffer, []byte) (MultiBuffer, int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufferedBytes returns the number of bytes that is cached in this reader.
|
// 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.
|
// 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) {
|
func (r *BufferedReader) Read(b []byte) (int, error) {
|
||||||
spliter := r.Spliter
|
spliter := r.Splitter
|
||||||
if spliter == nil {
|
if spliter == nil {
|
||||||
spliter = SplitBytes
|
spliter = SplitBytes
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ func ConnectionOutputMulti(reader buf.Reader) ConnectionOption {
|
||||||
func ConnectionOutputMultiUDP(reader buf.Reader) ConnectionOption {
|
func ConnectionOutputMultiUDP(reader buf.Reader) ConnectionOption {
|
||||||
return func(c *connection) {
|
return func(c *connection) {
|
||||||
c.reader = &buf.BufferedReader{
|
c.reader = &buf.BufferedReader{
|
||||||
Reader: reader,
|
Reader: reader,
|
||||||
Spliter: buf.SplitFirstBytes,
|
Splitter: buf.SplitFirstBytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func GetToolLocation(file string) string {
|
||||||
return filepath.Join(toolPath, file+".exe")
|
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 {
|
func GetAssetLocation(file string) string {
|
||||||
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
|
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
|
||||||
return filepath.Join(assetPath, file)
|
return filepath.Join(assetPath, file)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
||||||
|
|
||||||
type Certificate struct {
|
type Certificate struct {
|
||||||
// Cerificate in ASN.1 DER format
|
// certificate in ASN.1 DER format
|
||||||
Certificate []byte
|
Certificate []byte
|
||||||
// Private key in ASN.1 DER format
|
// Private key in ASN.1 DER format
|
||||||
PrivateKey []byte
|
PrivateKey []byte
|
||||||
|
|
|
@ -147,7 +147,7 @@ func TestTLSHeaders(t *testing.T) {
|
||||||
header, err := SniffTLS(test.input)
|
header, err := SniffTLS(test.input)
|
||||||
if test.err {
|
if test.err {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("Exepct error but nil in test %v", test)
|
t.Errorf("Expect error but nil in test %v", test)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const (
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
// User is a generic user for all procotols.
|
// User is a generic user for all protocols.
|
||||||
type User struct {
|
type User struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
|
|
@ -8,7 +8,7 @@ option java_multiple_files = true;
|
||||||
|
|
||||||
import "common/serial/typed_message.proto";
|
import "common/serial/typed_message.proto";
|
||||||
|
|
||||||
// User is a generic user for all procotols.
|
// User is a generic user for all protocols.
|
||||||
message User {
|
message User {
|
||||||
uint32 level = 1;
|
uint32 level = 1;
|
||||||
string email = 2;
|
string email = 2;
|
||||||
|
|
|
@ -13,16 +13,16 @@ import (
|
||||||
func IndependentCancelCtx(parent context.Context) context.Context
|
func IndependentCancelCtx(parent context.Context) context.Context
|
||||||
|
|
||||||
const (
|
const (
|
||||||
inboundSessionKey ctx.SessionKey = 1
|
inboundSessionKey ctx.SessionKey = 1
|
||||||
outboundSessionKey ctx.SessionKey = 2
|
outboundSessionKey ctx.SessionKey = 2
|
||||||
contentSessionKey ctx.SessionKey = 3
|
contentSessionKey ctx.SessionKey = 3
|
||||||
muxPreferedSessionKey ctx.SessionKey = 4
|
muxPreferredSessionKey ctx.SessionKey = 4
|
||||||
sockoptSessionKey ctx.SessionKey = 5
|
sockoptSessionKey ctx.SessionKey = 5
|
||||||
trackedConnectionErrorKey ctx.SessionKey = 6
|
trackedConnectionErrorKey ctx.SessionKey = 6
|
||||||
dispatcherKey ctx.SessionKey = 7
|
dispatcherKey ctx.SessionKey = 7
|
||||||
timeoutOnlyKey ctx.SessionKey = 8
|
timeoutOnlyKey ctx.SessionKey = 8
|
||||||
allowedNetworkKey ctx.SessionKey = 9
|
allowedNetworkKey ctx.SessionKey = 9
|
||||||
handlerSessionKey ctx.SessionKey = 10
|
handlerSessionKey ctx.SessionKey = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context {
|
func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context {
|
||||||
|
@ -58,14 +58,14 @@ func ContentFromContext(ctx context.Context) *Content {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContextWithMuxPrefered returns a new context with the given bool
|
// ContextWithMuxPreferred returns a new context with the given bool
|
||||||
func ContextWithMuxPrefered(ctx context.Context, forced bool) context.Context {
|
func ContextWithMuxPreferred(ctx context.Context, forced bool) context.Context {
|
||||||
return context.WithValue(ctx, muxPreferedSessionKey, forced)
|
return context.WithValue(ctx, muxPreferredSessionKey, forced)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MuxPreferedFromContext returns value in this context, or false if not contained.
|
// MuxPreferredFromContext returns value in this context, or false if not contained.
|
||||||
func MuxPreferedFromContext(ctx context.Context) bool {
|
func MuxPreferredFromContext(ctx context.Context) bool {
|
||||||
if val, ok := ctx.Value(muxPreferedSessionKey).(bool); ok {
|
if val, ok := ctx.Value(muxPreferredSessionKey).(bool); ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestActivityTimerUpdate(t *testing.T) {
|
||||||
timer.SetTimeout(time.Second * 1)
|
timer.SetTimeout(time.Second * 1)
|
||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
if ctx.Err() == nil {
|
if ctx.Err() == nil {
|
||||||
t.Error("expcted some error, but got nil")
|
t.Error("expected some error, but got nil")
|
||||||
}
|
}
|
||||||
runtime.KeepAlive(timer)
|
runtime.KeepAlive(timer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ func init() {
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
return loadProtobufConfig(data)
|
return loadProtobufConfig(data)
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknow type")
|
return nil, errors.New("unknown type")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
// CommandEnvHolder is a struct holds the environment info of commands
|
// CommandEnvHolder is a struct holds the environment info of commands
|
||||||
type CommandEnvHolder struct {
|
type CommandEnvHolder struct {
|
||||||
// Excutable name of current binary
|
// Executable name of current binary
|
||||||
Exec string
|
Exec string
|
||||||
// commands column width of current command
|
// commands column width of current command
|
||||||
CommandsWidth int
|
CommandsWidth int
|
||||||
|
|
|
@ -43,7 +43,7 @@ func init() {
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
return serial.LoadJSONConfig(v)
|
return serial.LoadJSONConfig(v)
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknow type")
|
return nil, errors.New("unknown type")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -43,7 +43,7 @@ func init() {
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
return serial.LoadTOMLConfig(v)
|
return serial.LoadTOMLConfig(v)
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknow type")
|
return nil, errors.New("unknown type")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -43,7 +43,7 @@ func init() {
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
return serial.LoadYAMLConfig(v)
|
return serial.LoadYAMLConfig(v)
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknow type")
|
return nil, errors.New("unknown type")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -243,7 +243,7 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||||
return w.Writer.WriteMultiBuffer(mb)
|
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 {
|
func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer {
|
||||||
needReshape := 0
|
needReshape := 0
|
||||||
for _, b := range buffer {
|
for _, b := range buffer {
|
||||||
|
@ -278,7 +278,7 @@ func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBu
|
||||||
return mb2
|
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 {
|
func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer {
|
||||||
var contentLen int32 = 0
|
var contentLen int32 = 0
|
||||||
var paddingLen int32 = 0
|
var paddingLen int32 = 0
|
||||||
|
|
|
@ -26,7 +26,7 @@ const (
|
||||||
type AuthType int32
|
type AuthType int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NO_AUTH is for anounymous authentication.
|
// NO_AUTH is for anonymous authentication.
|
||||||
AuthType_NO_AUTH AuthType = 0
|
AuthType_NO_AUTH AuthType = 0
|
||||||
// PASSWORD is for username/password authentication.
|
// PASSWORD is for username/password authentication.
|
||||||
AuthType_PASSWORD AuthType = 1
|
AuthType_PASSWORD AuthType = 1
|
||||||
|
|
|
@ -17,7 +17,7 @@ message Account {
|
||||||
|
|
||||||
// AuthType is the authentication type of Socks proxy.
|
// AuthType is the authentication type of Socks proxy.
|
||||||
enum AuthType {
|
enum AuthType {
|
||||||
// NO_AUTH is for anounymous authentication.
|
// NO_AUTH is for anonymous authentication.
|
||||||
NO_AUTH = 0;
|
NO_AUTH = 0;
|
||||||
// PASSWORD is for username/password authentication.
|
// PASSWORD is for username/password authentication.
|
||||||
PASSWORD = 1;
|
PASSWORD = 1;
|
||||||
|
|
|
@ -68,7 +68,7 @@ func TestReadUsernamePassword(t *testing.T) {
|
||||||
t.Error("for input: ", testCase.Input, " expect username ", testCase.Username, " but actually ", username)
|
t.Error("for input: ", testCase.Input, " expect username ", testCase.Username, " but actually ", username)
|
||||||
}
|
}
|
||||||
if testCase.Password != password {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
In the sock implementation of * ray, UDP authentication is flawed and can be bypassed.
|
In the sock implementation of * ray, UDP authentication is flawed and can be bypassed.
|
||||||
Tracking a UDP connection may be a bit troublesome.
|
Tracking a UDP connection may be a bit troublesome.
|
||||||
Here is a simple solution.
|
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.
|
And drop UDP packets from unauthorized IP.
|
||||||
After discussion, we believe it is not necessary to add a timeout mechanism to this filter.
|
After discussion, we believe it is not necessary to add a timeout mechanism to this filter.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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()
|
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 {
|
if err = bufferWriter.SetBuffered(false); err != nil {
|
||||||
return errors.New("failed to flush payload").Base(err).AtWarning()
|
return errors.New("failed to flush payload").Base(err).AtWarning()
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,14 +223,14 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
||||||
cs := tlsConn.ConnectionState()
|
cs := tlsConn.ConnectionState()
|
||||||
name = cs.ServerName
|
name = cs.ServerName
|
||||||
alpn = cs.NegotiatedProtocol
|
alpn = cs.NegotiatedProtocol
|
||||||
errors.LogInfo(ctx, "realName = " + name)
|
errors.LogInfo(ctx, "realName = "+name)
|
||||||
errors.LogInfo(ctx, "realAlpn = " + alpn)
|
errors.LogInfo(ctx, "realAlpn = "+alpn)
|
||||||
} else if realityConn, ok := iConn.(*reality.Conn); ok {
|
} else if realityConn, ok := iConn.(*reality.Conn); ok {
|
||||||
cs := realityConn.ConnectionState()
|
cs := realityConn.ConnectionState()
|
||||||
name = cs.ServerName
|
name = cs.ServerName
|
||||||
alpn = cs.NegotiatedProtocol
|
alpn = cs.NegotiatedProtocol
|
||||||
errors.LogInfo(ctx, "realName = " + name)
|
errors.LogInfo(ctx, "realName = "+name)
|
||||||
errors.LogInfo(ctx, "realAlpn = " + alpn)
|
errors.LogInfo(ctx, "realAlpn = "+alpn)
|
||||||
}
|
}
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
alpn = strings.ToLower(alpn)
|
alpn = strings.ToLower(alpn)
|
||||||
|
@ -295,7 +295,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
||||||
}
|
}
|
||||||
if k == '?' || k == ' ' {
|
if k == '?' || k == ' ' {
|
||||||
path = string(firstBytes[i:j])
|
path = string(firstBytes[i:j])
|
||||||
errors.LogInfo(ctx, "realPath = " + path)
|
errors.LogInfo(ctx, "realPath = "+path)
|
||||||
if pfb[path] == nil {
|
if pfb[path] == nil {
|
||||||
path = ""
|
path = ""
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
||||||
clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1)
|
clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1)
|
||||||
err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, ctx1)
|
err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, ctx1)
|
||||||
} else {
|
} else {
|
||||||
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer
|
||||||
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
|
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 {
|
if err := clientWriter.WriteMultiBuffer(multiBuffer); err != nil {
|
||||||
return err // ...
|
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 {
|
if err := bufferWriter.SetBuffered(false); err != nil {
|
||||||
return errors.New("failed to write A response payload").Base(err).AtWarning()
|
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 {
|
if requestAddons.Flow == vless.XRV {
|
||||||
err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, ctx)
|
err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, ctx)
|
||||||
} else {
|
} else {
|
||||||
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer
|
||||||
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -219,7 +219,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
} else {
|
} else {
|
||||||
errors.LogDebug(ctx, "Reader is not timeout reader, will send out vless header separately from first payload")
|
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 {
|
if err := bufferWriter.SetBuffered(false); err != nil {
|
||||||
return errors.New("failed to write A request payload").Base(err).AtWarning()
|
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
|
ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice
|
||||||
err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, ctx1)
|
err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, ctx1)
|
||||||
} else {
|
} else {
|
||||||
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer
|
||||||
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
|
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -276,7 +276,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
if requestAddons.Flow == vless.XRV {
|
if requestAddons.Flow == vless.XRV {
|
||||||
err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, ctx)
|
err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, ctx)
|
||||||
} else {
|
} else {
|
||||||
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer
|
||||||
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ type Config struct {
|
||||||
// Path of the domain socket. This overrides the IP/Port parameter from
|
// Path of the domain socket. This overrides the IP/Port parameter from
|
||||||
// upstream caller.
|
// upstream caller.
|
||||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
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
|
// Traditionally Unix domain socket is file system based. Abstract domain
|
||||||
// socket can be used without acquiring file lock.
|
// socket can be used without acquiring file lock.
|
||||||
Abstract bool `protobuf:"varint,2,opt,name=abstract,proto3" json:"abstract,omitempty"`
|
Abstract bool `protobuf:"varint,2,opt,name=abstract,proto3" json:"abstract,omitempty"`
|
||||||
|
|
|
@ -10,7 +10,7 @@ message Config {
|
||||||
// Path of the domain socket. This overrides the IP/Port parameter from
|
// Path of the domain socket. This overrides the IP/Port parameter from
|
||||||
// upstream caller.
|
// upstream caller.
|
||||||
string path = 1;
|
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
|
// Traditionally Unix domain socket is file system based. Abstract domain
|
||||||
// socket can be used without acquiring file lock.
|
// socket can be used without acquiring file lock.
|
||||||
bool abstract = 2;
|
bool abstract = 2;
|
||||||
|
|
|
@ -374,7 +374,7 @@ type Config struct {
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Settings for authenticating requests. If not set, client side will not send
|
// 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"`
|
Request *RequestConfig `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
|
||||||
// Settings for authenticating responses. If not set, client side will bypass
|
// Settings for authenticating responses. If not set, client side will bypass
|
||||||
// authentication, and server side will not send authentication header.
|
// authentication, and server side will not send authentication header.
|
||||||
|
|
|
@ -56,7 +56,7 @@ message ResponseConfig {
|
||||||
|
|
||||||
message Config {
|
message Config {
|
||||||
// Settings for authenticating requests. If not set, client side will not send
|
// 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;
|
RequestConfig request = 1;
|
||||||
|
|
||||||
// Settings for authenticating responses. If not set, client side will bypass
|
// Settings for authenticating responses. If not set, client side will bypass
|
||||||
|
|
|
@ -2,18 +2,18 @@ package httpupgrade
|
||||||
|
|
||||||
import "net"
|
import "net"
|
||||||
|
|
||||||
type connnection struct {
|
type connection struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
remoteAddr net.Addr
|
remoteAddr net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConnection(conn net.Conn, remoteAddr net.Addr) *connnection {
|
func newConnection(conn net.Conn, remoteAddr net.Addr) *connection {
|
||||||
return &connnection{
|
return &connection{
|
||||||
Conn: conn,
|
Conn: conn,
|
||||||
remoteAddr: remoteAddr,
|
remoteAddr: remoteAddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connnection) RemoteAddr() net.Addr {
|
func (c *connection) RemoteAddr() net.Addr {
|
||||||
return c.remoteAddr
|
return c.remoteAddr
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package internet
|
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 {
|
type MemoryStreamConfig struct {
|
||||||
ProtocolName string
|
ProtocolName string
|
||||||
ProtocolSettings interface{}
|
ProtocolSettings interface{}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func ListenUnix(ctx context.Context, address net.Address, settings *MemoryStream
|
||||||
protocol := settings.ProtocolName
|
protocol := settings.ProtocolName
|
||||||
listenFunc := transportListenerCache[protocol]
|
listenFunc := transportListenerCache[protocol]
|
||||||
if listenFunc == nil {
|
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)
|
listener, err := listenFunc(ctx, address, net.Port(0), settings, handler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue