mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 08:31:28 +00: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 {
|
||||||
|
|
|
@ -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),
|
||||||
|
@ -249,7 +251,8 @@ 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
|
||||||
|
@ -328,7 +331,8 @@ 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
|
||||||
|
@ -400,7 +404,8 @@ 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 {
|
||||||
|
@ -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))
|
||||||
|
|
|
@ -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,6 +1,7 @@
|
||||||
// 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
|
// skywind3000@github for inventing the KCP protocol
|
||||||
// xtaci@github for translating to Golang
|
// xtaci@github for translating to Golang
|
||||||
package kcp
|
package kcp
|
||||||
|
|
|
@ -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 (
|
||||||
|
|
|
@ -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 a new issue