mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-24 06:06:05 +03:00
Run core/format.go
This commit is contained in:
parent
c9b6fc0104
commit
c4fbdf1b78
@ -7,8 +7,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/log"
|
|
||||||
"github.com/xtls/xray-core/common/errors"
|
"github.com/xtls/xray-core/common/errors"
|
||||||
|
"github.com/xtls/xray-core/common/log"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/session"
|
"github.com/xtls/xray-core/common/session"
|
||||||
"github.com/xtls/xray-core/core"
|
"github.com/xtls/xray-core/core"
|
||||||
|
@ -26,7 +26,8 @@ func MustFromContext(ctx context.Context) *Instance {
|
|||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
/* toContext returns ctx from the given context, or creates an Instance if the context doesn't find that.
|
/*
|
||||||
|
toContext returns ctx from the given context, or creates an Instance if the context doesn't find that.
|
||||||
|
|
||||||
It is unsupported to use this function to create a context that is suitable to invoke Xray's internal component
|
It is unsupported to use this function to create a context that is suitable to invoke Xray's internal component
|
||||||
in third party code, you shouldn't use //go:linkname to alias of this function into your own package and
|
in third party code, you shouldn't use //go:linkname to alias of this function into your own package and
|
||||||
@ -34,7 +35,6 @@ use this function in your third party code.
|
|||||||
|
|
||||||
For third party code, usage enabled by creating a context to interact with Xray's internal component is unsupported,
|
For third party code, usage enabled by creating a context to interact with Xray's internal component is unsupported,
|
||||||
and may break at any time.
|
and may break at any time.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
func toContext(ctx context.Context, v *Instance) context.Context {
|
func toContext(ctx context.Context, v *Instance) context.Context {
|
||||||
if FromContext(ctx) != v {
|
if FromContext(ctx) != v {
|
||||||
@ -43,7 +43,8 @@ func toContext(ctx context.Context, v *Instance) context.Context {
|
|||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ToBackgroundDetachedContext create a detached context from another context
|
/*
|
||||||
|
ToBackgroundDetachedContext create a detached context from another context
|
||||||
Internal API
|
Internal API
|
||||||
*/
|
*/
|
||||||
func ToBackgroundDetachedContext(ctx context.Context) context.Context {
|
func ToBackgroundDetachedContext(ctx context.Context) context.Context {
|
||||||
|
@ -107,7 +107,7 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) {
|
|||||||
config.Email = v.Email
|
config.Email = v.Email
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.Cipher == "" {
|
if v.Cipher == "" {
|
||||||
return nil, newError("shadowsocks 2022 (multi-user): missing server method")
|
return nil, newError("shadowsocks 2022 (multi-user): missing server method")
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) {
|
|||||||
config.Method = v.Cipher
|
config.Method = v.Cipher
|
||||||
config.Key = v.Password
|
config.Key = v.Password
|
||||||
config.Network = v.NetworkList.Build()
|
config.Network = v.NetworkList.Build()
|
||||||
|
|
||||||
for _, user := range v.Users {
|
for _, user := range v.Users {
|
||||||
if user.Cipher != "" {
|
if user.Cipher != "" {
|
||||||
return nil, newError("shadowsocks 2022 (multi-user): users must have empty method")
|
return nil, newError("shadowsocks 2022 (multi-user): users must have empty method")
|
||||||
@ -145,10 +145,10 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) {
|
|||||||
return nil, newError("shadowsocks 2022 (relay): all users must have relay address")
|
return nil, newError("shadowsocks 2022 (relay): all users must have relay address")
|
||||||
}
|
}
|
||||||
config.Destinations = append(config.Destinations, &shadowsocks_2022.RelayDestination{
|
config.Destinations = append(config.Destinations, &shadowsocks_2022.RelayDestination{
|
||||||
Key: user.Password,
|
Key: user.Password,
|
||||||
Email: user.Email,
|
Email: user.Email,
|
||||||
Address: user.Address.Build(),
|
Address: user.Address.Build(),
|
||||||
Port: uint32(user.Port),
|
Port: uint32(user.Port),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return config, nil
|
return config, nil
|
||||||
|
@ -533,7 +533,7 @@ type SocketConfig struct {
|
|||||||
DialerProxy string `json:"dialerProxy"`
|
DialerProxy string `json:"dialerProxy"`
|
||||||
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
|
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
|
||||||
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
|
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
|
||||||
TCPCongestion string `json:"tcpCongestion"`
|
TCPCongestion string `json:"tcpCongestion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
@ -582,7 +582,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
|||||||
DialerProxy: c.DialerProxy,
|
DialerProxy: c.DialerProxy,
|
||||||
TcpKeepAliveInterval: c.TCPKeepAliveInterval,
|
TcpKeepAliveInterval: c.TCPKeepAliveInterval,
|
||||||
TcpKeepAliveIdle: c.TCPKeepAliveIdle,
|
TcpKeepAliveIdle: c.TCPKeepAliveIdle,
|
||||||
TcpCongestion: c.TCPCongestion,
|
TcpCongestion: c.TCPCongestion,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
M "github.com/sagernet/sing/common/metadata"
|
M "github.com/sagernet/sing/common/metadata"
|
||||||
N "github.com/sagernet/sing/common/network"
|
N "github.com/sagernet/sing/common/network"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/log"
|
"github.com/xtls/xray-core/common/log"
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
M "github.com/sagernet/sing/common/metadata"
|
M "github.com/sagernet/sing/common/metadata"
|
||||||
N "github.com/sagernet/sing/common/network"
|
N "github.com/sagernet/sing/common/network"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/log"
|
"github.com/xtls/xray-core/common/log"
|
||||||
|
@ -31,10 +31,12 @@ const (
|
|||||||
Version = byte(0)
|
Version = byte(0)
|
||||||
)
|
)
|
||||||
|
|
||||||
var tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04}
|
var (
|
||||||
var tlsClientHandShakeStart = []byte{0x16, 0x03}
|
tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04}
|
||||||
var tlsServerHandShakeStart = []byte{0x16, 0x03, 0x03}
|
tlsClientHandShakeStart = []byte{0x16, 0x03}
|
||||||
var tlsApplicationDataStart = []byte{0x17, 0x03, 0x03}
|
tlsServerHandShakeStart = []byte{0x16, 0x03, 0x03}
|
||||||
|
tlsApplicationDataStart = []byte{0x17, 0x03, 0x03}
|
||||||
|
)
|
||||||
|
|
||||||
var addrParser = protocol.NewAddressParser(
|
var addrParser = protocol.NewAddressParser(
|
||||||
protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv4), net.AddressFamilyIPv4),
|
protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv4), net.AddressFamilyIPv4),
|
||||||
@ -247,9 +249,10 @@ func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XtlsRead filter and read xtls protocol
|
// XtlsRead filter and read xtls protocol
|
||||||
func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, rawConn syscall.RawConn,
|
func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, rawConn syscall.RawConn,
|
||||||
counter stats.Counter, ctx context.Context, userUUID []byte, numberOfPacketToFilter *int, enableXtls *bool,
|
counter stats.Counter, ctx context.Context, userUUID []byte, numberOfPacketToFilter *int, enableXtls *bool,
|
||||||
isTLS12orAbove *bool, isTLS *bool, cipher *uint16, remainingServerHello *int32) error {
|
isTLS12orAbove *bool, isTLS *bool, cipher *uint16, remainingServerHello *int32,
|
||||||
|
) error {
|
||||||
err := func() error {
|
err := func() error {
|
||||||
var ct stats.Counter
|
var ct stats.Counter
|
||||||
filterUUID := true
|
filterUUID := true
|
||||||
@ -326,9 +329,10 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XtlsWrite filter and write xtls protocol
|
// XtlsWrite filter and write xtls protocol
|
||||||
func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, counter stats.Counter,
|
func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, counter stats.Counter,
|
||||||
ctx context.Context, userUUID *[]byte, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool,
|
ctx context.Context, userUUID *[]byte, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool,
|
||||||
cipher *uint16, remainingServerHello *int32) error {
|
cipher *uint16, remainingServerHello *int32,
|
||||||
|
) error {
|
||||||
err := func() error {
|
err := func() error {
|
||||||
var ct stats.Counter
|
var ct stats.Counter
|
||||||
filterTlsApplicationData := true
|
filterTlsApplicationData := true
|
||||||
@ -354,7 +358,7 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate
|
|||||||
buffer[i] = XtlsPadding(b, command, userUUID, ctx)
|
buffer[i] = XtlsPadding(b, command, userUUID, ctx)
|
||||||
break
|
break
|
||||||
} else if !*isTLS12orAbove && *numberOfPacketToFilter <= 0 {
|
} else if !*isTLS12orAbove && *numberOfPacketToFilter <= 0 {
|
||||||
//maybe tls 1.1 or 1.0
|
// maybe tls 1.1 or 1.0
|
||||||
filterTlsApplicationData = false
|
filterTlsApplicationData = false
|
||||||
buffer[i] = XtlsPadding(b, 0x01, userUUID, ctx)
|
buffer[i] = XtlsPadding(b, 0x01, userUUID, ctx)
|
||||||
break
|
break
|
||||||
@ -399,8 +403,9 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XtlsFilterTls filter and recognize tls 1.3 and other info
|
// XtlsFilterTls filter and recognize tls 1.3 and other info
|
||||||
func XtlsFilterTls(buffer buf.MultiBuffer, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool,
|
func XtlsFilterTls(buffer buf.MultiBuffer, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool,
|
||||||
cipher *uint16, remainingServerHello *int32, ctx context.Context) {
|
cipher *uint16, remainingServerHello *int32, ctx context.Context,
|
||||||
|
) {
|
||||||
for _, b := range buffer {
|
for _, b := range buffer {
|
||||||
*numberOfPacketToFilter--
|
*numberOfPacketToFilter--
|
||||||
if b.Len() >= 6 {
|
if b.Len() >= 6 {
|
||||||
@ -411,8 +416,8 @@ func XtlsFilterTls(buffer buf.MultiBuffer, numberOfPacketToFilter *int, enableXt
|
|||||||
*isTLS = true
|
*isTLS = true
|
||||||
if b.Len() >= 79 && *remainingServerHello >= 79 {
|
if b.Len() >= 79 && *remainingServerHello >= 79 {
|
||||||
sessionIdLen := int32(b.Byte(43))
|
sessionIdLen := int32(b.Byte(43))
|
||||||
cipherSuite := b.BytesRange(43 + sessionIdLen + 1, 43 + sessionIdLen + 3)
|
cipherSuite := b.BytesRange(43+sessionIdLen+1, 43+sessionIdLen+3)
|
||||||
*cipher = uint16(cipherSuite[0]) << 8 | uint16(cipherSuite[1])
|
*cipher = uint16(cipherSuite[0])<<8 | uint16(cipherSuite[1])
|
||||||
} else {
|
} else {
|
||||||
newError("XtlsFilterTls short server hello, tls 1.2 or older? ", b.Len(), " ", *remainingServerHello).WriteToLog(session.ExportIDToError(ctx))
|
newError("XtlsFilterTls short server hello, tls 1.2 or older? ", b.Len(), " ", *remainingServerHello).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
@ -431,7 +436,7 @@ func XtlsFilterTls(buffer buf.MultiBuffer, numberOfPacketToFilter *int, enableXt
|
|||||||
v, ok := Tls13CipherSuiteDic[*cipher]
|
v, ok := Tls13CipherSuiteDic[*cipher]
|
||||||
if !ok {
|
if !ok {
|
||||||
v = "Old cipher: " + strconv.FormatUint(uint64(*cipher), 16)
|
v = "Old cipher: " + strconv.FormatUint(uint64(*cipher), 16)
|
||||||
} else if (v != "TLS_AES_128_CCM_8_SHA256") {
|
} else if v != "TLS_AES_128_CCM_8_SHA256" {
|
||||||
*enableXtls = true
|
*enableXtls = true
|
||||||
}
|
}
|
||||||
newError("XtlsFilterTls found tls 1.3! ", b.Len(), " ", v).WriteToLog(session.ExportIDToError(ctx))
|
newError("XtlsFilterTls found tls 1.3! ", b.Len(), " ", v).WriteToLog(session.ExportIDToError(ctx))
|
||||||
@ -582,9 +587,9 @@ func XtlsUnpadding(ctx context.Context, buffer buf.MultiBuffer, userUUID []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Tls13CipherSuiteDic = map[uint16]string{
|
var Tls13CipherSuiteDic = map[uint16]string{
|
||||||
0x1301 : "TLS_AES_128_GCM_SHA256",
|
0x1301: "TLS_AES_128_GCM_SHA256",
|
||||||
0x1302 : "TLS_AES_256_GCM_SHA384",
|
0x1302: "TLS_AES_256_GCM_SHA384",
|
||||||
0x1303 : "TLS_CHACHA20_POLY1305_SHA256",
|
0x1303: "TLS_CHACHA20_POLY1305_SHA256",
|
||||||
0x1304 : "TLS_AES_128_CCM_SHA256",
|
0x1304: "TLS_AES_128_CCM_SHA256",
|
||||||
0x1305 : "TLS_AES_128_CCM_8_SHA256",
|
0x1305: "TLS_AES_128_CCM_8_SHA256",
|
||||||
}
|
}
|
||||||
|
@ -493,8 +493,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
|||||||
}
|
}
|
||||||
case "", "none":
|
case "", "none":
|
||||||
if accountFlow == vless.XRV && !allowNoneFlow && request.Command == protocol.RequestCommandTCP {
|
if accountFlow == vless.XRV && !allowNoneFlow && request.Command == protocol.RequestCommandTCP {
|
||||||
return newError(account.ID.String() + " is not able to use " + vless.XRV +
|
return newError(account.ID.String() + " is not able to use " + vless.XRV +
|
||||||
". Note the pure tls proxy has certain tls in tls characters. Append \",none\" in flow to suppress").AtWarning()
|
". Note the pure tls proxy has certain tls in tls characters. Append \",none\" in flow to suppress").AtWarning()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return newError("unknown request flow " + requestAddons.Flow).AtWarning()
|
return newError("unknown request flow " + requestAddons.Flow).AtWarning()
|
||||||
@ -542,11 +542,11 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
|||||||
if statConn != nil {
|
if statConn != nil {
|
||||||
counter = statConn.ReadCounter
|
counter = statConn.ReadCounter
|
||||||
}
|
}
|
||||||
//TODO enable splice
|
// TODO enable splice
|
||||||
ctx = session.ContextWithInbound(ctx, nil)
|
ctx = session.ContextWithInbound(ctx, nil)
|
||||||
if requestAddons.Flow == vless.XRV {
|
if requestAddons.Flow == vless.XRV {
|
||||||
err = encoding.XtlsRead(clientReader, serverWriter, timer, netConn, rawConn, counter, ctx, account.ID.Bytes(),
|
err = encoding.XtlsRead(clientReader, serverWriter, timer, netConn, rawConn, counter, ctx, account.ID.Bytes(),
|
||||||
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
||||||
} else {
|
} else {
|
||||||
err = encoding.ReadV(clientReader, serverWriter, timer, iConn.(*xtls.Conn), rawConn, counter, ctx)
|
err = encoding.ReadV(clientReader, serverWriter, timer, iConn.(*xtls.Conn), rawConn, counter, ctx)
|
||||||
}
|
}
|
||||||
@ -600,7 +600,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s
|
|||||||
if statConn != nil {
|
if statConn != nil {
|
||||||
counter = statConn.WriteCounter
|
counter = statConn.WriteCounter
|
||||||
}
|
}
|
||||||
err = encoding.XtlsWrite(serverReader, clientWriter, timer, netConn, counter, ctx, &userUUID, &numberOfPacketToFilter,
|
err = encoding.XtlsWrite(serverReader, clientWriter, timer, netConn, counter, ctx, &userUUID, &numberOfPacketToFilter,
|
||||||
&enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
&enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
||||||
} else {
|
} else {
|
||||||
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
||||||
|
@ -220,7 +220,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
userUUID := account.ID.Bytes()
|
userUUID := account.ID.Bytes()
|
||||||
timeoutReader, ok := clientReader.(buf.TimeoutReader)
|
timeoutReader, ok := clientReader.(buf.TimeoutReader)
|
||||||
if ok {
|
if ok {
|
||||||
multiBuffer, err1 := timeoutReader.ReadMultiBufferTimeout(time.Millisecond*500)
|
multiBuffer, err1 := timeoutReader.ReadMultiBufferTimeout(time.Millisecond * 500)
|
||||||
if err1 == nil {
|
if err1 == nil {
|
||||||
if requestAddons.Flow == vless.XRV {
|
if requestAddons.Flow == vless.XRV {
|
||||||
encoding.XtlsFilterTls(multiBuffer, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello, ctx)
|
encoding.XtlsFilterTls(multiBuffer, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello, ctx)
|
||||||
@ -250,7 +250,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
if statConn != nil {
|
if statConn != nil {
|
||||||
counter = statConn.WriteCounter
|
counter = statConn.WriteCounter
|
||||||
}
|
}
|
||||||
err = encoding.XtlsWrite(clientReader, serverWriter, timer, netConn, counter, ctx, &userUUID, &numberOfPacketToFilter,
|
err = encoding.XtlsWrite(clientReader, serverWriter, timer, netConn, counter, ctx, &userUUID, &numberOfPacketToFilter,
|
||||||
&enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
&enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
||||||
} else {
|
} else {
|
||||||
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
||||||
@ -287,8 +287,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
counter = statConn.ReadCounter
|
counter = statConn.ReadCounter
|
||||||
}
|
}
|
||||||
if requestAddons.Flow == vless.XRV {
|
if requestAddons.Flow == vless.XRV {
|
||||||
err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, counter, ctx, account.ID.Bytes(),
|
err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, counter, ctx, account.ID.Bytes(),
|
||||||
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
||||||
} else {
|
} else {
|
||||||
if requestAddons.Flow != vless.XRS {
|
if requestAddons.Flow != vless.XRS {
|
||||||
ctx = session.ContextWithInbound(ctx, nil)
|
ctx = session.ContextWithInbound(ctx, nil)
|
||||||
|
@ -252,7 +252,9 @@ func (v *TimedUserValidator) BurnTaintFuse(userHash []byte) error {
|
|||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ShouldShowLegacyWarn will return whether a Legacy Warning should be shown
|
/*
|
||||||
|
ShouldShowLegacyWarn will return whether a Legacy Warning should be shown
|
||||||
|
|
||||||
Not guaranteed to only return true once for every inbound, but it is okay.
|
Not guaranteed to only return true once for every inbound, but it is okay.
|
||||||
*/
|
*/
|
||||||
func (v *TimedUserValidator) ShouldShowLegacyWarn() bool {
|
func (v *TimedUserValidator) ShouldShowLegacyWarn() bool {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// Package kcp - A Fast and Reliable ARQ Protocol
|
// Package kcp - A Fast and Reliable ARQ Protocol
|
||||||
//
|
//
|
||||||
// Acknowledgement:
|
// Acknowledgement:
|
||||||
// skywind3000@github for inventing the KCP protocol
|
//
|
||||||
// xtaci@github for translating to Golang
|
// skywind3000@github for inventing the KCP protocol
|
||||||
|
// xtaci@github for translating to Golang
|
||||||
package kcp
|
package kcp
|
||||||
|
|
||||||
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
||||||
|
@ -140,8 +140,8 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add
|
|||||||
}
|
}
|
||||||
|
|
||||||
quicConfig := &quic.Config{
|
quicConfig := &quic.Config{
|
||||||
ConnectionIDLength: 12,
|
ConnectionIDLength: 12,
|
||||||
KeepAlivePeriod: 0,
|
KeepAlivePeriod: 0,
|
||||||
HandshakeIdleTimeout: time.Second * 8,
|
HandshakeIdleTimeout: time.Second * 8,
|
||||||
MaxIdleTimeout: time.Second * 300,
|
MaxIdleTimeout: time.Second * 300,
|
||||||
Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser {
|
Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser {
|
||||||
|
@ -106,8 +106,8 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
quicConfig := &quic.Config{
|
quicConfig := &quic.Config{
|
||||||
ConnectionIDLength: 12,
|
ConnectionIDLength: 12,
|
||||||
KeepAlivePeriod: 0,
|
KeepAlivePeriod: 0,
|
||||||
HandshakeIdleTimeout: time.Second * 8,
|
HandshakeIdleTimeout: time.Second * 8,
|
||||||
MaxIdleTimeout: time.Second * 300,
|
MaxIdleTimeout: time.Second * 300,
|
||||||
MaxIncomingStreams: 32,
|
MaxIncomingStreams: 32,
|
||||||
MaxIncomingUniStreams: -1,
|
MaxIncomingUniStreams: -1,
|
||||||
Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser {
|
Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package internet
|
package internet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/xtls/xray-core/common/net"
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/xtls/xray-core/common/net"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -78,11 +78,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.TcpCongestion != "" {
|
if config.TcpCongestion != "" {
|
||||||
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
||||||
return newError("failed to set TCP_CONGESTION", err)
|
return newError("failed to set TCP_CONGESTION", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Tproxy.IsEnabled() {
|
if config.Tproxy.IsEnabled() {
|
||||||
@ -128,11 +128,11 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.TcpCongestion != "" {
|
if config.TcpCongestion != "" {
|
||||||
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
||||||
return newError("failed to set TCP_CONGESTION", err)
|
return newError("failed to set TCP_CONGESTION", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Tproxy.IsEnabled() {
|
if config.Tproxy.IsEnabled() {
|
||||||
|
@ -3,11 +3,12 @@ package tls
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
gotls "crypto/tls"
|
gotls "crypto/tls"
|
||||||
utls "github.com/refraction-networking/utls"
|
|
||||||
"google.golang.org/grpc/credentials"
|
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
utls "github.com/refraction-networking/utls"
|
||||||
|
"google.golang.org/grpc/credentials"
|
||||||
)
|
)
|
||||||
|
|
||||||
// grpcUtlsInfo contains the auth information for a TLS authenticated connection.
|
// grpcUtlsInfo contains the auth information for a TLS authenticated connection.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*Package websocket implements WebSocket transport
|
/*
|
||||||
|
Package websocket implements WebSocket transport
|
||||||
|
|
||||||
WebSocket transport implements an HTTP(S) compliable, surveillance proof transport method with plausible deniability.
|
WebSocket transport implements an HTTP(S) compliable, surveillance proof transport method with plausible deniability.
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,6 @@ package xtls
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
xtls "github.com/xtls/go"
|
xtls "github.com/xtls/go"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user